Commit 6fd14c2
committed
fix(chat): closing the tab tears the conversation down, not just seals it
Both review points on #82. They landed on that PR's stale diff — I branched the wordmark
off feat/chat-editor-only instead of develop, so #82 carried #81's commits until #81
merged. Both are real, and both are about code that is now on develop, so they are fixed
here rather than in the wordmark PR (whose diff is now the two files it should always
have been).
1. SEALING WAS ONLY HALF THE TEARDOWN
sealLiveSession ends the SESSION — liveId() goes null, so the next chat opens visually
empty — while `conversation` and `agentMessages` still held every previous turn. The next
message therefore shipped the old history to the model. An empty-looking chat that secretly
remembers is worse than either honest option.
The out-of-process half was worse: background commands and MCP servers are DETACHED
children, so they outlived the surface that was reporting on them, and an in-flight agent
run kept editing files with nothing left to show for it.
newChat's teardown moves into resetConversationState() and the close path calls it. One
implementation, or the close path drifts — and it is the path nobody watches. It
deliberately does NOT post: New Chat re-renders afterwards because it has a surface to
re-render; the close path is tearing one down.
2. A LEGACY `secondarySidebar` SETTING PRODUCED A LYING LOG
The value was valid until the chat became editor-only, so it is still sitting in real
settings.json files. chatStartLocation still accepted it, so revealChatAtStartup logged
`where: secondarySidebar` and then opened the editor tab. Right behaviour, wrong story —
and the accepted set no longer matched the enum the package ships. Now mapped explicitly.
Guards, each bypass-verified by reverting the fix:
- the close sealing but leaving history loaded (the reported bug)
- conversation, checkpoints, abort, reapCommands and reapMcp each removed individually
- newChat growing its own copy of the teardown
- the shared teardown starting to post, which is wrong on the close path
- the legacy value no longer mapped; the removed surface accepted again
Two bypasses initially looked like misses: commenting out `reapMcp()` and neutering the
abort with `if (false)` both left the strings present, and these are presence checks. Redone
as deletions — which is how they would actually regress — they fail correctly. Worth stating
plainly: these guards catch removal, not disabling.
21 tests in chatSurface, 34 suites green.1 parent df1046d commit 6fd14c2
2 files changed
Lines changed: 87 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1106 | 1106 | | |
1107 | 1107 | | |
1108 | 1108 | | |
1109 | | - | |
1110 | | - | |
1111 | | - | |
1112 | | - | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
1113 | 1126 | | |
1114 | 1127 | | |
1115 | 1128 | | |
1116 | 1129 | | |
1117 | 1130 | | |
1118 | | - | |
| 1131 | + | |
1119 | 1132 | | |
1120 | 1133 | | |
1121 | | - | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
1122 | 1142 | | |
1123 | 1143 | | |
1124 | 1144 | | |
| |||
2341 | 2361 | | |
2342 | 2362 | | |
2343 | 2363 | | |
| 2364 | + | |
2344 | 2365 | | |
2345 | 2366 | | |
2346 | 2367 | | |
| |||
2358 | 2379 | | |
2359 | 2380 | | |
2360 | 2381 | | |
2361 | | - | |
| 2382 | + | |
| 2383 | + | |
| 2384 | + | |
| 2385 | + | |
| 2386 | + | |
| 2387 | + | |
2362 | 2388 | | |
2363 | 2389 | | |
2364 | 2390 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
221 | | - | |
| 221 | + | |
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
| |||
348 | 348 | | |
349 | 349 | | |
350 | 350 | | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
351 | 404 | | |
0 commit comments