feat: add todo tracking and custom tool views

Adds todo tracking infrastructure with TodoWrite tool integration to extract
and persist todos in sessions. Refactors ToolCard component to support
custom tool view rendering and displays todo progress in SessionList.
This commit is contained in:
weishu
2025-12-17 11:45:17 +08:00
parent 031116bfce
commit 9cc13b51be
21 changed files with 1103 additions and 277 deletions
+12 -3
View File
@@ -176,6 +176,11 @@ function ensureToolBlock(
): ToolCallBlock {
const existing = toolBlocksById.get(id)
if (existing) {
const isPlaceholderToolName = (name: string): boolean => {
const normalized = name.trim().toLowerCase()
return normalized === '' || normalized === 'tool' || normalized === 'unknown'
}
// Preserve earliest createdAt for stable ordering.
if (seed.createdAt < existing.createdAt) {
existing.createdAt = seed.createdAt
@@ -187,11 +192,15 @@ function ensureToolBlock(
existing.tool.state = 'pending'
}
}
if (seed.name) {
if (seed.name && (!isPlaceholderToolName(seed.name) || isPlaceholderToolName(existing.tool.name))) {
existing.tool.name = seed.name
}
existing.tool.input = seed.input
existing.tool.description = seed.description
if (seed.input !== null && seed.input !== undefined) {
existing.tool.input = seed.input
}
if (seed.description !== null) {
existing.tool.description = seed.description
}
return existing
}