fix: clarify readonly api status labels

This commit is contained in:
Yoilun
2026-05-25 20:35:35 +08:00
parent 5cbf4f8b3d
commit 10f1beb3c8
5 changed files with 44 additions and 5 deletions

View File

@@ -137,9 +137,9 @@ export function normalizeAgent(agent = {}) {
fileName,
name,
description,
role: agent.developerInstructions || '没有 developer_instructions 字段',
role: agent.developerInstructions || '没有角色设定字段',
status: isInvalid ? 'unknown' : 'complete',
statusLabel: isInvalid ? 'TOML 无效' : '已读取',
statusLabel: isInvalid ? 'TOML 无效' : 'TOML 有效',
parseStatus,
parseStatusLabel: formatParseStatus(parseStatus),
parseError: agent.parseError || '',
@@ -245,6 +245,7 @@ export function normalizeWorkflow(payload = {}) {
isEmpty: events.length === 0 && phases.length === 0 && handoffs.length === 0,
emptyTitle: '没有工作流事件',
emptyText: source.message || '后端返回了空的工作流事件流;这里不会回退到伪装真实的示例关系。',
emptyHandoffsText: '后端没有返回交接边;当前保持空状态。',
}
}
@@ -259,7 +260,7 @@ function synthesizeAgentPreview(agent, { isInvalid, description }) {
`description = ${quote(agent.description || '')}`,
]
if (agent.developerInstructions) {
lines.push(`developer_instructions = ${quote(agent.developerInstructions)}`)
lines.push(`角色设定 = ${quote(agent.developerInstructions)}`)
}
for (const [key, value] of Object.entries(agent.extraFields || {})) {
lines.push(`${key} = ${quote(value)}`)

View File

@@ -39,6 +39,25 @@ test('normalizes invalid agent TOML as readonly error display', () => {
assert.match(agent.toml, /只读展示/)
})
test('normalizes valid agent TOML with visible parse status', () => {
const agent = normalizeAgent({
id: 'frontend',
filePath: '/Users/yoilun/.codex/agents/frontend.toml',
fileName: 'frontend.toml',
name: '前端开发者',
description: '构建界面',
developerInstructions: '实现 UI',
parseStatus: 'valid',
draftStatus: 'clean',
})
assert.equal(agent.statusLabel, 'TOML 有效')
assert.equal(agent.parseStatusLabel, '解析通过')
assert.equal(agent.role, '实现 UI')
assert.doesNotMatch(agent.toml, /developer_instructions/)
assert.match(agent.toml, /角色设定/)
})
test('normalizes empty runtime without falling back to fake real data', () => {
const runtime = normalizeRuntime({
items: [],
@@ -73,6 +92,17 @@ test('normalizes empty workflow with source evidence and no sample edges', () =>
assert.deepEqual(workflow.edges, [])
})
test('normalizes workflow empty handoff copy in Chinese', () => {
const workflow = normalizeWorkflow({
items: [{ kind: 'thread', label: '线程' }],
handoffEdges: [],
phases: [],
source: { kind: 'sqlite_readonly', confidence: 'high' },
})
assert.equal(workflow.emptyHandoffsText, '后端没有返回交接边;当前保持空状态。')
})
test('filters non-phase rows from workflow phase display', () => {
const workflow = normalizeWorkflow({
items: [],

View File

@@ -79,7 +79,7 @@ async function loadWorkflow() {
<div v-if="loading" class="load-state">加载中</div>
<div v-else-if="!error && workflowState.handoffs.length === 0" class="empty-state compact">
<strong>没有交接边</strong>
<p>后端没有返回 handoffEdges当前保持空状态</p>
<p>{{ workflowState.emptyHandoffsText }}</p>
</div>
<HandoffTimeline v-else :items="error ? sampleWorkflow.handoffs.map((item) => ({ ...item, from: `示例:${item.from}` })) : workflowState.handoffs" />
</div>
@@ -100,7 +100,7 @@ async function loadWorkflow() {
<aside class="panel supervision-panel">
<div class="panel-heading">
<p class="eyebrow">监管</p>
<h2> agent 监管状态</h2>
<h2>智能体监管状态</h2>
</div>
<StatusBadge
:label="error ? '连接失败' : (workflowState.isEmpty ? '空数据' : '已读取')"