Commit b109329
committed
🤖 refactor: Clear TODO/status on user message, not stream events
## Problem
Previous implementation cleared state at different times:
- TODOs: Cleared on stream-end (via cleanupStreamState)
- Status: Cleared on stream-start
This created historical/live disparity because stream events aren't persisted
in chat.jsonl. After page reload, TODOs would stick around (desirable!) but
the implementation was inconsistent.
## Solution
Clear BOTH todos and agentStatus when new user message arrives.
Why user messages?
- ✅ Persisted in chat.jsonl (unlike stream events)
- ✅ Consistent live/historical behavior
- ✅ Semantic: New question = new task = clear previous state
## Changes
1. Removed TODO clearing from cleanupStreamState()
2. Removed status clearing from handleStreamStart()
3. Added centralized clearing in handleMessage() when user message arrives
4. Updated test: 'stream-start' → 'new user message'
## Benefits
- Consistent behavior whether loading from history or processing live
- TODOs persist until next question (user preference!)
- Simpler: One place to clear state, not scattered across handlers
- Architecture: Relies on persisted data, not ephemeral events
## Testing
- All 842 tests pass
- Updated test reflects new clearing behavior
- Typecheck and lint pass1 parent 9eef8ae commit b109329
File tree
2 files changed
+24
-18
lines changed- src/utils/messages
2 files changed
+24
-18
lines changedLines changed: 10 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
202 | | - | |
| 202 | + | |
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
256 | 256 | | |
257 | | - | |
| 257 | + | |
258 | 258 | | |
259 | 259 | | |
260 | 260 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
170 | 174 | | |
171 | 175 | | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | 176 | | |
176 | 177 | | |
177 | 178 | | |
| |||
311 | 312 | | |
312 | 313 | | |
313 | 314 | | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
318 | 318 | | |
319 | 319 | | |
320 | 320 | | |
| |||
649 | 649 | | |
650 | 650 | | |
651 | 651 | | |
652 | | - | |
| 652 | + | |
653 | 653 | | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
654 | 660 | | |
655 | 661 | | |
656 | 662 | | |
| |||
0 commit comments