Skip to content

fix(terminal): keep other input out of large bracketed pastes - #42948

Merged
juliusmarminge merged 13 commits into
pingdotgg:mainfrom
StiensWout:wf/find-75dd068e4703d91ccc01ef08
Nov 25, 2026
Merged

juliusmarminge merged 13 commits into
pingdotgg:mainfrom
StiensWout:wf/find-75dd068e4703d91ccc01ef08

Conversation

@StiensWout

Copy link
Copy Markdown
Contributor

Typing from another client could insert characters into a large paste in a shared terminal. Web, desktop, and mobile now mark split writes so the server holds competing input until a paste finishes or is interrupted. Mobile also keeps keystrokes behind pastes already in its local queue.

Related: #37937, #36352

Reproduction on main

Commit b61af8a5d2 (main), in the running web app:

  1. Start the web app and open it in a browser.
  2. Open a thread and open its terminal, and wait until a shell prompt is visible.
  3. Open that same thread and its terminal in a second browser window.
  4. Slow the first window's connection to the app so a large upload takes more than a second.
  5. Paste more than 65,536 ordinary letters into the shell prompt in the first window, and do not press Enter.
  6. While that paste is still sending, type a short distinctive word in the second window.
  7. Look at the shell line in either window.

The word typed in the second window appears in the middle of the pasted letters. Expected: The pasted letters appear as one uninterrupted block, and the word typed in the second window is not mixed into them.

The cause is at apps/server/src/terminal/Manager.ts:3895. Ran pnpm scenarios:prove scripts/scenarios/terminal-paste-keeps-input-from-other-client-out.e2e.ts --target web with the repro scenario added: it failed in 2 of 2 runs on a clean checkout, with expected "Other input landed inside the paste" to be "Paste arrived intact" in the output.

Evidence

Environment: The web app in Chromium on Linux x64, a fresh checkout.

Proven: the repro fails at the test commit 4e16da56ff and passes on the head 64c53ece33, both on main a76e554784.

Before After
Commit 4e16da56ff 64c53ece33
Result ASSERTION_FAILED: expected "Other input landed inside the paste" to be "Paste arrived intact" passed
paste after input from second connection Before: paste after input from second connection After: paste after input from second connection
failure Before: failure

Before the fix, recorded:

https://pub-b182a4071edc4521829926b34990540b.r2.dev/files/bb4792e8-bd86-49f5-94ab-b1d025049ed8/before-recording.webm

After the fix, recorded:

https://pub-b182a4071edc4521829926b34990540b.r2.dev/files/ae3d0f90-a297-405c-a050-394a65be6890/after-recording.webm

Outside view: a person sees it in the running web app by following the steps under Reproduction on main.

Tests

  • 4e16da56ff adds the failing test, alone, before the fix.
  • pnpm exec vp run check:changed a76e5547844b11688454f8f41095597d196eccfe passed on head.

Not in this change

  • Cross-client ordering requires support for split-write framing on both the sending client and the server.
  • The browser scenario checks paste integrity. Terminal manager tests explicitly queue a competing write and assert that it reaches the shell after the final chunk for both bracketed and plain writes.

Who did the work

  • Repro written by GPT 6.2 Sol, in Codex
  • Outside view by Grok 4.7, in Grok
  • Duplicate check judged by Claude Opus 5.5, in Claude Code
  • Written by GPT 6.2 Sol, in Codex
  • Trimmed by Claude Opus 5.5, in Claude Code
  • Reviewed by Claude Opus 5.5, in Claude Code, and by GPT 6.2 Sol, in Codex, and by Gemini 4 Neon, in Antigravity
  • Reproduction, checks and proof run by a program on base and head, not by an agent

Made in T3 Code by GPT 6.2 Sol, Claude Opus 5.5, Grok 4.7 and Gemini 4 Neon

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants