fix: hide unknown backend enum labels
This commit is contained in:
@@ -54,21 +54,21 @@ export function formatSourceKind(kind) {
|
||||
if (!kind) {
|
||||
return '来源未知'
|
||||
}
|
||||
return SOURCE_KIND_LABELS[kind] ?? kind
|
||||
return SOURCE_KIND_LABELS[kind] ?? '来源未知'
|
||||
}
|
||||
|
||||
export function formatConfidence(confidence) {
|
||||
if (!confidence) {
|
||||
return '低'
|
||||
}
|
||||
return CONFIDENCE_LABELS[confidence] ?? confidence
|
||||
return CONFIDENCE_LABELS[confidence] ?? '低'
|
||||
}
|
||||
|
||||
export function formatStatus(status) {
|
||||
if (!status) {
|
||||
return '未知'
|
||||
}
|
||||
return STATUS_LABELS[status] ?? status
|
||||
return STATUS_LABELS[status] ?? '未知'
|
||||
}
|
||||
|
||||
export function formatParseStatus(status) {
|
||||
@@ -100,7 +100,7 @@ export function normalizeProject(project) {
|
||||
path,
|
||||
status: project?.directoryExists ? 'complete' : 'unknown',
|
||||
statusZh: project?.directoryExists ? '目录存在' : '目录不可用',
|
||||
trust: TRUST_LABELS[project?.trustLevel] ?? project?.trustLevel ?? '未知',
|
||||
trust: TRUST_LABELS[project?.trustLevel] ?? '未知',
|
||||
directoryExists: Boolean(project?.directoryExists),
|
||||
source: source.label,
|
||||
confidence: source.confidenceLabel,
|
||||
|
||||
@@ -4,7 +4,9 @@ import assert from 'node:assert/strict'
|
||||
import {
|
||||
formatConfidence,
|
||||
formatSourceKind,
|
||||
formatStatus,
|
||||
normalizeAgent,
|
||||
normalizeProject,
|
||||
normalizeRuntime,
|
||||
normalizeWorkflow,
|
||||
} from './normalizers.js'
|
||||
@@ -20,6 +22,26 @@ test('maps source kind and confidence to Chinese display text', () => {
|
||||
assert.equal(formatConfidence('low'), '低')
|
||||
})
|
||||
|
||||
test('hides unknown backend enum values from UI labels', () => {
|
||||
const project = normalizeProject({
|
||||
path: '/Users/yoilun/Code/unknown',
|
||||
displayName: '未知项目',
|
||||
trustLevel: 'trusted_workspace_owner',
|
||||
directoryExists: true,
|
||||
source: {
|
||||
kind: 'sqlite_locked_internal',
|
||||
confidence: 'partial_high_confidence',
|
||||
},
|
||||
})
|
||||
|
||||
assert.equal(formatSourceKind('sqlite_locked_internal'), '来源未知')
|
||||
assert.equal(formatConfidence('partial_high_confidence'), '低')
|
||||
assert.equal(formatStatus('in_progress'), '未知')
|
||||
assert.equal(project.source, '来源未知')
|
||||
assert.equal(project.confidence, '低')
|
||||
assert.equal(project.trust, '未知')
|
||||
})
|
||||
|
||||
test('normalizes invalid agent TOML as readonly error display', () => {
|
||||
const agent = normalizeAgent({
|
||||
id: 'broken',
|
||||
|
||||
Reference in New Issue
Block a user