mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-20 05:12:02 +00:00
界面跟上点名接入的新规矩:设置页标出已停用的接入、选不了别的停用接入,接入表变了画布重新校验,问题面板和修复预览不露键名
点名停用的接入以前照常调用,现在运行时照实报错,界面要提前说: - 设置页门控、裁判、核查三格:存着的接入已停用和「不存在」一样在那一格下面写明后果;下拉里别的停用接入列着但选不了(只留已选着的那个);模型一格不再写「留空则使用」一个调不了的接入的默认模型。服务端按项拒收(422 带 field)时整句落到那一格下面、焦点移过去,保存条连同原因一起写,不再截掉「请在……中启用它」。 - 画布校验现在读接入表:编排页记下校验时的接入表签名(id、名称、启用与否),从设置里改完接入回来、或目录刷新后接入表变了,就重新校验一次,不再停着一句过时的「已停用」。 - 问题面板、修复预览里点名接入的字段写「模型接入」「成员「分析师」的模型接入」「工作流默认设置 · 模型」,不露 provider、model 键名;修复预览给列表项写名字。同一节点上自己的接入和成员的接入是两处问题,合并、找修复都连字段一起认,计数不再少算。 检查:check-publish 加点名接入的修复(一处一行、候选、预览、应用、390px 不溢出)、问题面板字段叫法、在设置里删了接入回到画布重新校验;check-manage 加设置页已停用接入的三格说明、选项、按项拒收;check-evidence 里全图默认的 model 改按「模型」核对(不借裁判叫法的原意不变)。
This commit is contained in:
@@ -13,7 +13,7 @@ import {
|
||||
import { PublishPreflightPane } from './PublishDialog'
|
||||
import { humanizeError } from '../lib/errors'
|
||||
import { formatShortcut } from '../lib/keys'
|
||||
import { PUBLISH_FIX_TEXT, UPGRADE_TEXT } from '../lib/terms'
|
||||
import { PROVIDER_REF_TEXT, PUBLISH_FIX_TEXT, UPGRADE_TEXT } from '../lib/terms'
|
||||
import { useCatalog } from '../store/catalog'
|
||||
import { EDIT_LOCK_TEXT, upgradeUnsaved, useEditLock, useStudio, type UpgradeFlow } from '../store/studio'
|
||||
import { Spinner, useRadioGroup } from '../components/ui'
|
||||
@@ -232,7 +232,7 @@ function ProblemRow({ problem: p, active, onLocate, onDeleteEdge }: {
|
||||
aria-label={err ? '错误' : '提示'} />
|
||||
<span className={clsx('min-w-0 flex-1', err ? 'text-fg' : 'text-dim')}>{p.message}</span>
|
||||
{where && (
|
||||
<span className="flex shrink-0 items-center gap-0.5 text-faint">
|
||||
<span className="flex shrink-0 items-center gap-0.5 text-faint" data-problem-field="">
|
||||
<CornerDownRight size={9} aria-hidden />{where}
|
||||
</span>
|
||||
)}
|
||||
@@ -615,13 +615,17 @@ function UpgradeValue({ value, field, nameOf, className, ...data }: {
|
||||
)
|
||||
}
|
||||
|
||||
const SUB_LABEL: Record<string, string> = { condition: '的条件', key: '的标识', tools: '的工具', system: '的系统提示' }
|
||||
const SUB_LABEL: Record<string, string> = {
|
||||
condition: '的条件', key: '的标识', tools: '的工具', system: '的系统提示', provider: PROVIDER_REF_TEXT.memberField,
|
||||
}
|
||||
/** 节点定义里没有、问题却会落上去的字段:点名的模型接入(多数节点的检查器里没有这一栏)。不写的话露出键名 */
|
||||
const FIELD_FALLBACK: Record<string, string> = { provider: PROVIDER_REF_TEXT.field }
|
||||
|
||||
function fieldLabel(field: FieldRef | null | undefined, type?: string, config?: Record<string, any>): string {
|
||||
if (!field) return ''
|
||||
if (field.key === 'label') return '节点名称'
|
||||
const def = type ? NODE_DEFS[type as keyof typeof NODE_DEFS] : undefined
|
||||
const base = def?.fields.find((f) => f.key === field.key)?.label ?? field.key
|
||||
const base = def?.fields.find((f) => f.key === field.key)?.label ?? FIELD_FALLBACK[field.key] ?? field.key
|
||||
if (field.index == null) return base
|
||||
const sub = (field.sub && SUB_LABEL[field.sub]) || ''
|
||||
// 成员有名字就叫名字:「第 2 个成员」还得数,「成员 writer」一眼就知道是谁
|
||||
|
||||
@@ -272,12 +272,13 @@ const unsavedApply = (a: ApplyState) => a.status === 'failed' || (a.status === '
|
||||
const unsavedFix = (pf: PreflightState) => !!pf.apply && unsavedApply(pf.apply)
|
||||
|
||||
/**
|
||||
* 节点 id → 名字和类型。跟着 issues 换新(改名、改配置之后校验都会重跑),不订阅 nodes:
|
||||
* 问题面板开着时拖一下节点,这一整块不必跟着每帧重渲染
|
||||
* 节点 id → 名字、类型和配置。跟着 issues 换新(改名、改配置之后校验都会重跑),不订阅 nodes:
|
||||
* 问题面板开着时拖一下节点,这一整块不必跟着每帧重渲染。配置给修复预览认列表里的那一项(成员「分析师」)
|
||||
*/
|
||||
function useNodeLookup(): (id: string) => { label: string; type: string } | undefined {
|
||||
function useNodeLookup(): (id: string) => { label: string; type: string; config?: Record<string, any> } | undefined {
|
||||
const tick = useStudio((s) => s.issues)
|
||||
const map = useMemo(() => new Map(useStudio.getState().nodes.map((n) => [n.id, { label: n.data.label, type: n.data.nodeType }])),
|
||||
const map = useMemo(() => new Map(useStudio.getState().nodes.map((n) => [n.id,
|
||||
{ label: n.data.label, type: n.data.nodeType, config: n.data.config }])),
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
[tick])
|
||||
return useCallback((id: string) => map.get(id), [map])
|
||||
@@ -544,7 +545,8 @@ export function Preflight({ pf, gate, onLocate, stale }: {
|
||||
)}
|
||||
|
||||
{pf.preview && <FixPreview pf={pf} labelOf={labelOf} nameOf={nameOf}
|
||||
typeOf={(id) => (id ? nodeOf(id)?.type : undefined)} />}
|
||||
typeOf={(id) => (id ? nodeOf(id)?.type : undefined)}
|
||||
configOf={(id) => (id ? nodeOf(id)?.config : undefined)} />}
|
||||
{/* 修复落到画布上却没存上,预览又已经收起了(换过等级):「重试保存」照样得在 */}
|
||||
{pf.preview?.status !== 'ready' && unsavedFix(pf) && <SaveTrouble pf={pf} />}
|
||||
|
||||
@@ -656,9 +658,11 @@ function FixControl({ fix, pf }: { fix: PublishFix; pf: PreflightState }) {
|
||||
}
|
||||
|
||||
/** 修复预览:逐项「节点 · 字段:原值 → 新值」,没采用的写原因,Copilot 的问题原样摆出来 */
|
||||
function FixPreview({ pf, labelOf, nameOf, typeOf }: {
|
||||
function FixPreview({ pf, labelOf, nameOf, typeOf, configOf }: {
|
||||
pf: PreflightState; labelOf: (id?: string | null) => string; nameOf: NodeNameOf
|
||||
typeOf: (id?: string | null) => string | undefined
|
||||
/** 列表里的某一项(agents[0]、fields[1])写那一项的名字,不写「第 1 项」 */
|
||||
configOf?: (id?: string | null) => Record<string, any> | undefined
|
||||
}) {
|
||||
const dirty = useStudio((s) => s.dirty)
|
||||
const p = pf.preview!
|
||||
@@ -703,7 +707,7 @@ function FixPreview({ pf, labelOf, nameOf, typeOf }: {
|
||||
<ul className="space-y-1" data-fix-changes="">
|
||||
{result.changes.map((c, i) => {
|
||||
const where = c.node_title || labelOf(c.node_id) || T.whole
|
||||
const field = fixFieldLabel(c.field, typeOf(c.node_id))
|
||||
const field = fixFieldLabel(c.field, typeOf(c.node_id), configOf?.(c.node_id))
|
||||
return (
|
||||
<li key={i} className="leading-snug" data-fix-change={c.fix_id}>
|
||||
<span className="[overflow-wrap:anywhere]">
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
* 那一栏,定位落到工具上(见 toolBindingOf)。
|
||||
*/
|
||||
import { ApiError } from '../api/client'
|
||||
import { APPROVAL_POLICY_LABEL, JUDGE_FIELD_LABEL, JUDGE_ON_UNSUPPORTED_LABEL, UPGRADE_TEXT, nodeTypeLabel } from '../lib/terms'
|
||||
import {
|
||||
APPROVAL_POLICY_LABEL, JUDGE_FIELD_LABEL, JUDGE_ON_UNSUPPORTED_LABEL, PROVIDER_REF_TEXT, UPGRADE_TEXT, nodeTypeLabel,
|
||||
} from '../lib/terms'
|
||||
import { NODE_DEFS } from './nodeDefs'
|
||||
import type { FlowNode } from '../store/studio'
|
||||
import type {
|
||||
@@ -244,6 +246,12 @@ function normalizeIssue(raw: any): ValidationIssue | null {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 点名的模型接入不存在或已停用(后端 engine/provider_refs.py)。一处一条问题、一条修复:同一个协作节点上自己的接入和
|
||||
* 成员的接入是两处,合并、找修复都要连字段一起认
|
||||
*/
|
||||
export const isProviderRefCode = (code?: string | null): boolean => code === 'provider.missing' || code === 'provider.disabled'
|
||||
|
||||
function normalizeFix(raw: any): PublishFix | null {
|
||||
if (!raw || typeof raw !== 'object' || typeof raw.id !== 'string' || !raw.id) return null
|
||||
const kind = raw.kind === 'choice' || raw.kind === 'assist' ? raw.kind : raw.kind === 'auto' ? 'auto' : null
|
||||
@@ -259,6 +267,7 @@ function normalizeFix(raw: any): PublishFix | null {
|
||||
code: asText(raw.code),
|
||||
kind,
|
||||
node_id: raw.node_id ?? null,
|
||||
...(typeof raw.field === 'string' && raw.field ? { field: raw.field } : {}),
|
||||
label: asText(raw.label) || raw.id,
|
||||
preview: raw.preview && typeof raw.preview === 'object' ? raw.preview : null,
|
||||
options,
|
||||
@@ -318,7 +327,10 @@ export function fixFor(issue: ValidationIssue, fixes: PublishFix[]): PublishFix
|
||||
if (issue.fix) return fixes.find((f) => f.id === issue.fix)
|
||||
if (!issue.code) return undefined
|
||||
const same = fixes.filter((f) => f.code === issue.code)
|
||||
const exact = same.find((f) => (f.node_id ?? null) === (issue.node_id ?? null))
|
||||
// 点名的接入一处一条修复:同一节点上的几处按字段认
|
||||
const exact = (isProviderRefCode(issue.code)
|
||||
? same.find((f) => (f.node_id ?? null) === (issue.node_id ?? null) && (f.field ?? null) === (issue.field ?? null))
|
||||
: undefined) ?? same.find((f) => (f.node_id ?? null) === (issue.node_id ?? null))
|
||||
if (exact) return exact
|
||||
return issue.node_id == null ? same[0] : same.find((f) => f.node_id == null)
|
||||
}
|
||||
@@ -326,13 +338,16 @@ export function fixFor(issue: ValidationIssue, fixes: PublishFix[]): PublishFix
|
||||
/**
|
||||
* 同一处问题只列一行:validate 和门禁常对同一处各报一条(同 code、同节点,说法不同),
|
||||
* 列两行就是两组一样的修复控件、「会被拦下 2 处」。合成的那一行取最重的级别、第一条 error 的说法,
|
||||
* 其余说法收进 others(悬停可见)。没有 code 的认不出是不是同一处,照原样各列一行
|
||||
* 其余说法收进 others(悬停可见)。没有 code 的认不出是不是同一处,照原样各列一行。
|
||||
* 点名的模型接入连字段一起认:协作节点自己的接入和成员的接入是两处问题、各有各的修复,不合成一行
|
||||
*/
|
||||
export function mergeIssues(issues: ValidationIssue[]): { issue: ValidationIssue; others: string[] }[] {
|
||||
const out: { issue: ValidationIssue; others: string[] }[] = []
|
||||
const at = new Map<string, number>()
|
||||
for (const issue of issues) {
|
||||
const key = issue.code ? `${issue.code}\u0000${issue.node_id ?? ''}` : null
|
||||
const key = issue.code
|
||||
? `${issue.code}\u0000${issue.node_id ?? ''}${isProviderRefCode(issue.code) ? `\u0000${issue.field ?? ''}` : ''}`
|
||||
: null
|
||||
const i = key != null ? at.get(key) : undefined
|
||||
if (i == null) {
|
||||
if (key != null) at.set(key, out.length)
|
||||
@@ -382,11 +397,15 @@ const CONTRACT_KEYS: Record<string, string> = {
|
||||
/** 不在节点定义的字段表里、由检查器自己画的几项(子工作流钉的版本、升版处置),以及图级的全图默认 */
|
||||
const EXTRA_FIELDS: Record<string, string> = {
|
||||
workflow_version: '固定版本', upgrade_policy: '上游发布新版本时', defaults: '工作流默认设置',
|
||||
// 多数节点的检查器里没有接入这一栏(只有双盲复算、反方审稿有),修复点名接入时照样要写得出叫法
|
||||
provider: PROVIDER_REF_TEXT.field,
|
||||
}
|
||||
/** 点号后面那一段的叫法:契约里的键,全图默认里的审批策略,列表项里的名称、取值、表达式 */
|
||||
const SUB_KEYS: Record<string, string> = {
|
||||
...CONTRACT_KEYS, approval: '审批策略', claims: '未附依据的结论句', on_uncited: '未附依据时',
|
||||
name: '名称', value: '取值', expression: '表达式',
|
||||
// 点名的接入:成员的、全图默认里的(连同全图默认里结论句裁判的那一份)
|
||||
provider: PROVIDER_REF_TEXT.field, model: PROVIDER_REF_TEXT.model, judge: PROVIDER_REF_TEXT.judge,
|
||||
}
|
||||
/** 契约 claims 的 on_uncited:没挂依据的结论句怎么算 */
|
||||
const ON_UNCITED_LABEL: Record<string, string> = {
|
||||
|
||||
Reference in New Issue
Block a user