Summary
Replace the current file watcher-based todo detection with a proper hook-based approach once Claude Code provides the necessary hooks.
Current Implementation (File Watcher - Unreliable)
| File |
Purpose |
apps/desktop/src/main/services/session-watcher/SessionFileWatcher.ts |
Uses fs.watch to monitor .jsonl session files |
packages/shared/src/parsers/todo-extractor.ts |
Parses JSONL files to find TodoWrite tool calls |
apps/desktop/src/renderer/hooks/useSessionFileWatcher.ts |
React hook subscribing to file change events |
apps/desktop/src/renderer/hooks/useSessionOverview.ts |
Integrates file watching with todo extraction |
How it works now:
SessionFileWatcher uses Node.js fs.watch to detect .jsonl file changes
- Debounces rapid writes (300ms base, 1000ms max) to handle streaming
- On change,
useSessionOverview re-reads and parses the entire JSONL file
extractLatestTodoList() scans from the end to find the latest TodoWrite tool_use block
- Converts to
TodoListProgress for UI rendering
Problems:
- Inefficient: Must re-parse entire session file on every change
- Complex debouncing: 300ms/1000ms timing to handle streaming writes
- No granularity: Can't distinguish message changes from todo updates
- No plan detection: No way to detect when a plan is created
- Timing issues: Missed updates or duplicate processing
Desired Solution
Use Claude Code's hook system with PostToolUse matcher for TodoWrite:
{
"hooks": {
"PostToolUse": [
{
"matcher": {
"tool_name": "TodoWrite"
},
"command": "notify-agent-base"
}
]
}
}
Benefits:
- Real-time notifications without file polling
- Todo content delivered directly in hook payload (no parsing needed)
- React only to todo changes, not every session update
- Cleaner, more reliable architecture
Blockers
Claude Code does not currently have a dedicated hook for todo/plan creation.
Available hooks per DeepWiki:
PreToolUse / PostToolUse - could work if payload includes tool input
- No dedicated
TodoCreated or PlanCreated hook
Questions for Anthropic:
- Does
PostToolUse include the tool's input (todo list content) in its payload?
- Is there a separate "plan" concept with its own tool, or is it all
TodoWrite?
Action Items
Related Files
apps/desktop/src/main/services/session-watcher/
├── SessionFileWatcher.ts
├── index.ts
└── ipc.ts
packages/shared/src/parsers/
├── todo-extractor.ts
└── types.ts
apps/desktop/src/renderer/hooks/
├── useSessionFileWatcher.ts
└── useSessionOverview.ts
Summary
Replace the current file watcher-based todo detection with a proper hook-based approach once Claude Code provides the necessary hooks.
Current Implementation (File Watcher - Unreliable)
apps/desktop/src/main/services/session-watcher/SessionFileWatcher.tsfs.watchto monitor.jsonlsession filespackages/shared/src/parsers/todo-extractor.tsTodoWritetool callsapps/desktop/src/renderer/hooks/useSessionFileWatcher.tsapps/desktop/src/renderer/hooks/useSessionOverview.tsHow it works now:
SessionFileWatcheruses Node.jsfs.watchto detect.jsonlfile changesuseSessionOverviewre-reads and parses the entire JSONL fileextractLatestTodoList()scans from the end to find the latestTodoWritetool_use blockTodoListProgressfor UI renderingProblems:
Desired Solution
Use Claude Code's hook system with
PostToolUsematcher forTodoWrite:{ "hooks": { "PostToolUse": [ { "matcher": { "tool_name": "TodoWrite" }, "command": "notify-agent-base" } ] } }Benefits:
Blockers
Claude Code does not currently have a dedicated hook for todo/plan creation.
Available hooks per DeepWiki:
PreToolUse/PostToolUse- could work if payload includes tool inputTodoCreatedorPlanCreatedhookQuestions for Anthropic:
PostToolUseinclude the tool's input (todo list content) in its payload?TodoWrite?Action Items
PostToolUsehook provides enough dataRelated Files