Commit 74cfca5
committed
fix(todo): Refetch session after TodoWrite tool completes
Problem: Todo tool updates database but client's currentSession.todos
remains stale, causing TodoList UI to show no todos.
Root cause: Todo tool only returns summary (not actual todos), and there's
no mechanism to update client state after database update.
Solution: Refetch session from server when TodoWrite tool completes.
Changes:
1. toolHandlers.ts: Added refetch logic in handleToolResult()
- Detects when TodoWrite tool completes
- Calls refetchCurrentSession() to fetch fresh data
2. Created refetch-session.ts utility
- Fetches session from server via tRPC
- Updates currentSession signal with fresh data
- TodoList component re-renders with new todos
Flow:
- LLM calls TodoWrite tool
- Tool updates database
- Tool returns summary result
- handleToolResult detects TodoWrite completion
- refetchCurrentSession fetches session from server
- currentSession signal updated with fresh todos
- TodoList component shows todos
Result: Todo UI now displays after tool execution1 parent 802a512 commit 74cfca5
File tree
2 files changed
+31
-0
lines changed- packages/code/src
- screens/chat/streaming/handlers
- utils
2 files changed
+31
-0
lines changedLines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
208 | 217 | | |
209 | 218 | | |
210 | 219 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
0 commit comments