Skip to content

fix(web): keep interrupted terminal pastes free of stray Escape characters - #42916

Open
StiensWout wants to merge 2 commits into
pingdotgg:mainfrom
StiensWout:wf/find-1819614cabb59a8f871e2a1b
Open

StiensWout wants to merge 2 commits into
pingdotgg:mainfrom
StiensWout:wf/find-1819614cabb59a8f871e2a1b

Conversation

@StiensWout

Copy link
Copy Markdown
Contributor

Hiding the terminal drawer near the end of a large bracketed paste could leave an extra Escape character in the shell input. The terminal writer now keeps the closing marker in a single write, so recovery can send the full marker without duplicating a prefix.

Related: #36902, #35419, #37889, #42686, #30577

Reproduction on main

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

  1. Open the web app and a thread, then open the terminal drawer and wait until a Bash prompt is ready.
  2. Slow the browser's connection to the app so a large paste takes a few seconds to send.
  3. Paste 65,529 ASCII characters, such as the letter p repeated that many times, into the terminal.
  4. Close the terminal drawer before the paste finishes sending.
  5. Open the terminal drawer again and look at the end of the text on the Bash input line.

The input line shows those characters followed by ^[, an extra Escape left when the paste was closed. Expected: The input line shows those 65,529 characters and nothing after them.

The cause is at apps/web/src/components/terminal/terminalInputWriter.ts:64. Ran cd apps/web && pnpm exec vp test run src/components/terminal/terminalInputWriter.test.ts with the repro test added: it failed in 2 of 2 runs on a clean checkout, with expected '"\u001b\u001b[201~"' to be '"\u001b[201~"' // Object.is equality in the output.

Evidence

Environment: Linux x64, the repository's own tests.

Proven: the repro fails at the test commit c272c7df8c and passes on the head 0a0303c3f6, both on main b61af8a5d2.

Before After
Commit c272c7df8c 0a0303c3f6
Result failed with "expected '"\u001b\u001b[201~"' to be '"\u001b[201~"' // Object.is equality" passed

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

Tests

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

Not in this change

  • Native mobile paste uses a separate input path without this bracketed-paste recovery.
  • Recovery after a lost acknowledgment for a fully dispatched closing marker still depends on the existing write acknowledgment semantics.
  • Empty input and terminal settings are independent of bracketed-paste chunking.

Who did the work

  • Repro written by GPT 6.2 Sol, in Codex
  • Outside view by Grok 4.7, in Grok
  • 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, Grok 4.7, Claude Opus 5.5 and Gemini 4 Neon

StiensWout and others added 2 commits November 25, 2026 16:12
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
…cters

Co-authored-by: GPT 6.2 Sol <codex@openai.com>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 25, 2026
@coderabbitai

coderabbitai Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The terminal input writer now keeps the bracketed-paste closing marker intact when a chunk boundary would split it. A new test covers cancellation before dispatch of the next chunk.

Changes: Bracketed Paste Recovery

Layer / File(s) Summary
Chunk boundary recovery and test
apps/web/src/components/terminal/terminalInputWriter.ts, apps/web/src/components/terminal/terminalInputWriter.test.ts
The writer identifies bracketed paste input before sending chunks. If the final chunk is shorter than the closing marker, it rechunks the preceding data and sends the complete marker as the final chunk. A new test checks that the output retains the marker after cancellation before dispatch.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

  • pingdotgg/t3code#42897: This PR also addresses split bracketed-paste chunks and closing-marker handling during pending terminal writes.

Suggested reviewers: juliusmarminge, macroscopeapp

Merge Risk: Minimal · up to 0a030

This change keeps the bracketed-paste closing marker in one write, preventing a stray Escape character in shell input. It is narrowly scoped and covered by a regression test, and no merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix (interrupted terminal pastes no longer leave stray Escape characters) and matches the summarized change in terminalInputWriter.ts, which keeps the closing marker in one write d…
Description check Passed The description follows the template's main sections. Problem, Change, Scope, and Verification are all present. It gives a reproduction on main, links the related issues, and reports failing and passi…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the fix (interrupted terminal pastes no longer leave stray Escape characters) and matches the summarized change in terminalInputWriter.ts, which keeps the closing marker in one write during bracketed-paste recovery. It is specific and conventional, though it is a bit long at 74 characters.

Full details: Description check

Explanation

The description follows the template's main sections. Problem, Change, Scope, and Verification are all present. It gives a reproduction on main, links the related issues, and reports failing and passing test evidence at specific commits. Scope links related issues but does not clearly justify why no single primary issue is linked, and it does not state that the bug is an obvious fix. The Verification section includes checks and commit references. The 'Who did the work' section is extra, not required by the template, and it does not contain screenshots, which are required only for UI changes and this is not a UI change.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between b61af8a and 0a0303c.

Files selected for processing: 2

  • apps/web/src/components/terminal/terminalInputWriter.test.ts
  • apps/web/src/components/terminal/terminalInputWriter.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

This branch has not been deployed

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

Labels

size:S 10-29 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.

1 participant