Skip to content

Fix duplicated helper command echo in Argos snapshots - #922

Merged
nedtwigg merged 2 commits into
mainfrom
fix-helper-snapshot-echo
Oct 2, 2026
Merged

nedtwigg merged 2 commits into
mainfrom
fix-helper-snapshot-echo

Conversation

@nedtwigg

@nedtwigg nedtwigg commented Oct 2, 2026

Copy link
Copy Markdown
Member

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 status echo before capture.

Validation:

  • A real-xterm regression forces the resize interleaving and reproduces two command echoes on the original code; it passes with this fix.
  • 52 focused unit tests passed.
  • All 28 helper-placement story tests passed across Chromium and WebKit.
  • Library typecheck, spec lint, and diff whitespace checks passed.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Deploying mouseterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: b7c0f85
Status: ✅  Deploy successful!
Preview URL: https://cee19414.mouseterm.pages.dev
Branch Preview URL: https://fix-helper-snapshot-echo.mouseterm.pages.dev

View logs

@dormouse-bot dormouse-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@nedtwigg
nedtwigg merged commit 67bd52e into main Oct 2, 2026
14 of 15 checks passed

This branch is waiting to be deployed

1 waiting deployment
hosted-preview — b7c0f852 Waiting Oct 2, 2026 by nedtwigg via deploy #775
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants