mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-25 01:42:09 +00:00
助手面板和画布显示 SQL 检查:自查与交付的问题写中文规则名、级别、涉及的表和列与 SQL 片段,不挡运行的提醒单列一组;问题面板、发布前检查和助手的「定位」落到调用工具参数里的 SQL
This commit is contained in:
@@ -77,9 +77,28 @@ export function revealField(nodeId: string, field?: FieldRef | string | null, op
|
||||
const to = target.querySelector<HTMLElement>(FILLABLE) ?? target.querySelector<HTMLElement>(PRESSABLE)
|
||||
to?.focus({ preventScroll: true })
|
||||
}
|
||||
// 子键没有自己的一行、字段是一段 JSON(调用工具的「参数」,问题落在 args.sql 上):在文字里找到那个键,
|
||||
// 框内滚到那一行,聚焦时光标放在它的值开头
|
||||
if (!part && at.sub) revealJsonKey(target, at.sub, !!opts.focus)
|
||||
}))
|
||||
}
|
||||
|
||||
/** JSON 文字框里的某个键:滚到它那一行;focus 时把光标放在值的开头(不选中,免得一敲键就把整段 SQL 换掉) */
|
||||
function revealJsonKey(field: HTMLElement, key: string, focus: boolean): void {
|
||||
const box = field.querySelector<HTMLTextAreaElement>('textarea')
|
||||
if (!box) return
|
||||
const m = new RegExp(`"${key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}"\\s*:\\s*"?`).exec(box.value)
|
||||
if (!m) return
|
||||
const line = box.value.slice(0, m.index).split('\n').length - 1
|
||||
const height = parseFloat(getComputedStyle(box).lineHeight) || 16
|
||||
box.scrollTop = Math.max(0, (line - 1) * height)
|
||||
if (focus) {
|
||||
const at = m.index + m[0].length
|
||||
box.focus({ preventScroll: true })
|
||||
box.setSelectionRange(at, at)
|
||||
}
|
||||
}
|
||||
|
||||
// 选中 → 面板开不开。放在模块级:选中可能来自别处(问题面板定位、发布弹窗、快捷键),
|
||||
// 规则只写这一份
|
||||
useStudio.subscribe((s, prev) => {
|
||||
|
||||
@@ -13,6 +13,7 @@ import { useCatalog } from '../store/catalog'
|
||||
import { Modal, Spinner, toast, useRadioGroup } from '../components/ui'
|
||||
import { humanizeError } from '../lib/errors'
|
||||
import { PUBLISH_FIX_TEXT as T, WORKFLOW_STATUS_HINT, WORKFLOW_STATUS_LABEL } from '../lib/terms'
|
||||
import { isSqlCheckCode, sqlRuleLabel } from '../lib/sqlcheck'
|
||||
import { setLocalActor, useLocalActor } from '../lib/actor'
|
||||
import {
|
||||
autoFixIds, choiceReady, contentSig, fixFieldLabel, fixFor, fixValueLines, fixValueText, isMissingEndpoint, mergeIssues,
|
||||
@@ -42,7 +43,8 @@ export function PublishDialog({ workflow, onClose, onDone, onLocate }: {
|
||||
workflow: Workflow
|
||||
onClose: () => void
|
||||
onDone: () => void
|
||||
onLocate: (nodeId: string) => void
|
||||
/** 定位一条问题:选中节点,能落到具体配置项(调用工具的 SQL)就落到那一项 */
|
||||
onLocate: (issue: ValidationIssue) => void
|
||||
}) {
|
||||
const load = useStudio((s) => s.load)
|
||||
const dirty = useStudio((s) => s.dirty)
|
||||
@@ -208,7 +210,7 @@ export function PublishDialog({ workflow, onClose, onDone, onLocate }: {
|
||||
</dl>
|
||||
|
||||
<div className="mt-3" data-preflight="dialog">
|
||||
<Preflight pf={pf} gate={gate} onLocate={(issue) => { if (issue.node_id) { onLocate(issue.node_id); onClose() } }} />
|
||||
<Preflight pf={pf} gate={gate} onLocate={(issue) => { if (issue.node_id) { onLocate(issue); onClose() } }} />
|
||||
</div>
|
||||
</Modal>
|
||||
)
|
||||
@@ -564,6 +566,8 @@ function PreflightRow({ issue, others, fix, where, pf, onLocate }: {
|
||||
aria-label={err ? '错误' : '提示'} />
|
||||
<span className="min-w-0 flex-1 [overflow-wrap:anywhere]">
|
||||
{where && !String(issue.message).includes(`「${where}」`) && <b className="font-semibold">「{where}」</b>}
|
||||
{/* 对照数据目录的 SQL 检查:先写中文规则名,不露规则编号 */}
|
||||
{isSqlCheckCode(issue.code) && <span className="font-medium" data-preflight-rule="">{sqlRuleLabel(issue.code)}:</span>}
|
||||
{issue.message}
|
||||
</span>
|
||||
{issue.node_id && <CornerDownRight size={10} className="mt-px shrink-0 text-faint" aria-hidden />}
|
||||
|
||||
Reference in New Issue
Block a user