Commit 738e85f
fix(ai): sniff the accumulated tail, not the raw chunk (PR #35 review)
1. runCommand streams arbitrary stdout slices, so a dev server's address
routinely arrives split across a boundary — "http://local" + "host:5173/" —
and neither half matches. The preview would then silently never open, which is
the worst failure mode for this feature because there is nothing to point at.
Simulated against the real streaming path:
per-chunk (old): null
tail (new): "http://localhost:5173/"
The sniffs now read a bounded tail of entry.ring, which was already being
maintained for read_command_output. 8 KB is far more than any single log line
needs, and bounding it keeps the rescan cheap for a noisy watcher that never
prints an address at all.
Applied to ALL THREE sniffs, not just the preview: port and ready had the same
latent gap, and fixing only the new one would have left the identical bug in
place next to it.
2. ctx.openPreview is async and was called bare. Now wrapped so a rejection can
never escape into a live stream handler — showing a browser tab must not be
able to disturb a running command's output.
3. The junk-input test asserted only doesNotThrow. For a stdout handler that is
necessary but not sufficient: a non-null return would still pop a browser tab.
It now asserts the value is null, over a wider set of junk.
Verified: 23 suites, 0 failures; verify.test.js is 16 cases. The split-chunk case
is pinned with the real sniffer — each half must not match, the join must.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent e0c87b4 commit 738e85f
2 files changed
Lines changed: 40 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
72 | 77 | | |
73 | 78 | | |
74 | 79 | | |
| |||
392 | 397 | | |
393 | 398 | | |
394 | 399 | | |
395 | | - | |
396 | | - | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
397 | 408 | | |
398 | 409 | | |
399 | 410 | | |
400 | 411 | | |
401 | 412 | | |
402 | | - | |
403 | | - | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
404 | 421 | | |
405 | 422 | | |
406 | 423 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
83 | 87 | | |
84 | 88 | | |
85 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
86 | 101 | | |
87 | 102 | | |
88 | 103 | | |
| |||
0 commit comments