fix(frontend): narrow tool items in todo metadata tests

Problem:
The full desktop frontend test suite failed TypeScript test-config checking because find() results remained the broad Item union before accessing tool args.

Root cause:
The todo panel regression tests checked kind and name without expressing the discriminated-union narrowing to TypeScript.

Fix:
Use explicit Extract<Item, { kind: "tool" }> predicates for both todo_write lookups and record the no-migration upgrade note in the v1.21.0 release catalog so the candidate remains bound to its reviewed Notes change.

Verification:
pnpm --dir desktop/frontend test:all
node scripts/release-notes.mjs validate
node --test scripts/release-notes.test.mjs
git diff --check
This commit is contained in:
SivanCola committed 2026-08-06 21:59:38 +08:00
1 parent c21f0d2ee3
commit e4b8a89e6b
2 files changed
+23 -4

No files matched your search

@@ -1,6 +1,6 @@
// Run: tsx src/__tests__/use-controller-meta.test.ts
import { currentTurnWaitMs, effortSwitchNoticeText, foregroundRunningFromRuntimeMeta, historyMessagesToItems, initialState, localizedBackendNoticeText, localizedNoticeText, metaFromTab, modelSwitchNoticeText, reducer, sameMeta, shouldReconcileStaleTurn, tokenModeSwitchNoticeText } from "../lib/useController";
import { currentTurnWaitMs, effortSwitchNoticeText, foregroundRunningFromRuntimeMeta, historyMessagesToItems, initialState, localizedBackendNoticeText, localizedNoticeText, metaFromTab, modelSwitchNoticeText, reducer, sameMeta, shouldReconcileStaleTurn, tokenModeSwitchNoticeText, type Item } from "../lib/useController";
import { parseTodos } from "../lib/tools";
import { resolveTodoPanelTodos } from "../lib/todoVisibility";
import type { HistoryMessage, Meta, TabMeta, WireUsage } from "../lib/types";
@@ -424,7 +424,9 @@ console.log("\nuse controller meta");
],
});
const hydrated = reducer({ ...initialState, meta: delayedLiveMeta }, { type: "meta", meta: delayedLiveMeta });
const noLiveTodo = hydrated.items.find((item) => item.kind === "tool" && item.name === "todo_write");
const noLiveTodo = hydrated.items.find(
(item): item is Extract<Item, { kind: "tool" }> => item.kind === "tool" && item.name === "todo_write",
);
eq(
resolveTodoPanelTodos(hydrated.meta?.canonicalTodos, noLiveTodo ? parseTodos(noLiveTodo.args) : undefined),
delayedLiveMeta.canonicalTodos,
@@ -452,7 +454,9 @@ console.log("\nuse controller meta");
type: "event",
e: { kind: "tool_result", tool: { id: "todo-live", name: "todo_write", readOnly: true, output: "Todos updated" } },
});
const liveTodo = liveState.items.find((item) => item.kind === "tool" && item.name === "todo_write");
const liveTodo = liveState.items.find(
(item): item is Extract<Item, { kind: "tool" }> => item.kind === "tool" && item.name === "todo_write",
);
eq(
JSON.stringify(resolveTodoPanelTodos(liveState.meta?.canonicalTodos, liveTodo ? parseTodos(liveTodo.args) : undefined)),
JSON.stringify(JSON.parse(liveArgs).todos),
+16 -1
View File
@@ -348,7 +348,22 @@
}
]
},
"upgrade": [],
"upgrade": [
{
"level": "info",
"title": {
"en": "No manual migration is required",
"zh": "无需手动迁移"
},
"body": {
"en": "Upgrade to v1.21.0 normally; existing configuration and sessions remain compatible.",
"zh": "可直接升级到 v1.21.0;现有配置与会话保持兼容。"
},
"refs": [
7773
]
}
],
"risks": [],
"contributors": [
"SivanCola",