fix: keep unknown workflow phases visible

This commit is contained in:
Yoilun
2026-05-25 20:52:26 +08:00
parent dcf5e727e7
commit ba975112de
4 changed files with 34 additions and 3 deletions

View File

@@ -48,8 +48,6 @@ const TRUST_LABELS = {
unknown: '未知',
}
const PHASE_STATUSES = new Set(['blocked', 'complete', 'done', 'failed', 'pending', 'running', 'unknown'])
export function formatSourceKind(kind) {
if (!kind) {
return '来源未知'
@@ -308,7 +306,18 @@ function quote(value) {
}
function isDisplayPhase(phase) {
return PHASE_STATUSES.has(phase?.status || 'unknown')
const name = String(phase?.name ?? '').trim().toLowerCase()
const status = String(phase?.status ?? '').trim().toLowerCase()
if (!name) {
return false
}
if (name === 'phase' || status === 'status') {
return false
}
if (name === 'time' && status === 'phase') {
return false
}
return true
}
function normalizePhaseName(name) {

View File

@@ -149,3 +149,18 @@ test('filters non-phase rows from workflow phase display', () => {
assert.equal(workflow.phases[0].name, '阶段 5')
assert.equal(workflow.phases[0].label, '待处理')
})
test('keeps workflow phases with unknown backend status visible', () => {
const workflow = normalizeWorkflow({
items: [],
handoffEdges: [],
phases: [
{ name: '5', status: 'in_progress', source: { kind: 'plan_file', confidence: 'medium' } },
],
source: { kind: 'plan_file', confidence: 'medium' },
})
assert.equal(workflow.phases.length, 1)
assert.equal(workflow.phases[0].name, '阶段 5')
assert.equal(workflow.phases[0].label, '未知')
})