Fix duplicated helper command echo in Argos snapshots - #922
Conversation
Deploying mouseterm with
|
| Latest commit: |
b7c0f85
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://cee19414.mouseterm.pages.dev |
| Branch Preview URL: | https://fix-helper-snapshot-echo.mouseterm.pages.dev |
dormouse-bot
left a comment
There was a problem hiding this comment.
The duplicated echo is an xterm bug that also hits production terminals; this PR stops it only in the fake adapter. WriteBuffer.flushSync drains with this._writeBuffer.shift() from index 0 and ignores _bufferOffset. After _innerWrite yields partway through a batch, the chunks it has already parsed are still in the array, so the flushSync() that resize runs parses them a second time. The pinned 6.1.0-beta.304 ships the same code, and so does current xterm master. A real PTY stream can arrive split across many chunks, so a pane resize during a burst of output (dragging a divider, the helper placing itself, a window resize) can duplicate text in a user's terminal too. I found no upstream issue for it; the closest is xtermjs/xterm.js#6154, which is a different resize/flushSync failure. Batching the fake output is the right fix for the snapshot. The production fix belongs in xterm: an upstream report, or a patch that has flushSync start at _bufferOffset. The regression test here already reproduces the bug with a real Terminal, so it could serve as the repro.
The narrow helper-placement snapshot intermittently renders
git statusgit status. The fake shell emits the echo one character per PTY chunk; when xterm yields after the echo, resizing flushes its pending queue and replays the already-parsed prefix.Batch each fake-helper input's echo, command output, and returned prompt into one chunk. Placement stories also drain queued xterm writes and assert exactly one
git statusecho before capture.Validation: