Commit fcd8b7b
committed
fix(cli/exp_agents_diff): degrade oversized watcher payloads gracefully
Addresses Codex P2 on head 0d3f417: the local chat git watcher set a
4 MiB websocket read limit but agentgit caps each repository's
UnifiedDiff at 3 MiB (maxTotalDiffSize), so a Changes message
aggregating two or more maxed-out repos legitimately exceeds 4 MiB and
triggers a coder/websocket close with StatusMessageTooBig. Because
wsjson.Decoder swallowed the read error (log at Debug, close the
channel), fetchLocalChatDiffContents surfaced a generic
"git watch connection closed" error and the diff drawer crashed with
a hard error in exactly the large-multi-repo case the local fallback
was meant to improve: a regression from the pre-fallback behavior.
Fix it with a narrowly scoped, two-layered degrade path:
1. Bump the client-side read limit from 4 MiB to 32 MiB
(localChatDiffReadLimit), which covers ~10 maxed-out repos and makes
realistic multi-repo worktrees just work without any fallback.
2. For pathological payloads beyond 32 MiB, treat the specific
StatusMessageTooBig close as ignorable. fetchLocalChatDiffContents
now reads from the websocket directly (bypassing wsjson.NewStream)
so it can inspect websocket.CloseStatus(err), returning the narrow
errLocalDiffMessageTooLarge sentinel on read-limit violations.
shouldIgnoreLocalDiffFallbackError maps that sentinel onto the
same remote-empty-diff fallback we already use for 404/403/400.
Generic websocket close / decode / protocol errors continue to
surface as hard errors so real regressions do not silently
disappear behind the fallback.
Tests:
- IgnoresWatcherMessageTooBigCloses accepts the websocket, reads the
refresh, then closes with StatusMessageTooBig. The client must
degrade to the empty remote diff without error.
- SurfacesUnexpectedWatcherCloseErrors closes with StatusInternalError
instead and pins that the fallback is scoped to MessageTooBig only,
so a future attempt to blanket-ignore every close reason immediately
breaks the test.
Pre-commit (gen/fmt/lint/build) passed. Full cli/ tests pass in 60.9s.
> Mux is Mike's coding agent. This commit was made on Mike's behalf.1 parent 0d3f417 commit fcd8b7b
2 files changed
Lines changed: 162 additions & 28 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | | - | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
22 | 41 | | |
23 | 42 | | |
24 | 43 | | |
| |||
74 | 93 | | |
75 | 94 | | |
76 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
77 | 107 | | |
78 | 108 | | |
79 | 109 | | |
| |||
89 | 119 | | |
90 | 120 | | |
91 | 121 | | |
92 | | - | |
| 122 | + | |
93 | 123 | | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
| 124 | + | |
99 | 125 | | |
100 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
101 | 131 | | |
102 | 132 | | |
103 | 133 | | |
104 | | - | |
105 | 134 | | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
115 | 150 | | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
126 | 168 | | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
127 | 173 | | |
128 | 174 | | |
129 | 175 | | |
| |||
220 | 266 | | |
221 | 267 | | |
222 | 268 | | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
223 | 278 | | |
224 | 279 | | |
225 | 280 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
406 | 406 | | |
407 | 407 | | |
408 | 408 | | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
409 | 488 | | |
410 | 489 | | |
411 | 490 | | |
| |||
0 commit comments