Skip to content

[codex] Fix issue 957 long paste display#959

Merged
binaricat merged 5 commits into
mainfrom
codex/fix-issue-957-long-paste-display
May 12, 2026
Merged

[codex] Fix issue 957 long paste display#959
binaricat merged 5 commits into
mainfrom
codex/fix-issue-957-long-paste-display

Conversation

@binaricat
Copy link
Copy Markdown
Owner

@binaricat binaricat commented May 12, 2026

Summary

  • Fixes the Debian bash long-paste display artifacts where stale text remains after the cursor.
  • Removes the pasted command echo highlight that looks like a terminal selection.
  • Routes user paste actions through a shared path so context-menu, keyboard, and middle-click paste behave consistently.
  • Preserves serial line mode behavior when a paste arrives as one multi-line input chunk.

Validation

  • Reproduced the reported docker command in an 80-column Debian-style bash shell before and after the fix.
  • node --test --import tsx components/terminal/runtime/terminalUserPaste.test.ts
  • node --test --import tsx components/terminal/runtime/serialLineInput.test.ts
  • npm run lint
  • npm test
  • npm run build

Addresses the long-paste display part of #957.

@binaricat binaricat marked this pull request as ready for review May 12, 2026 08:03
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 54dc1dd625

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +90 to +92
if (hasReadlineActiveRegion(data)) {
state.clearPending = Math.max(state.clearPending, 3);
return stripReadlineActiveRegion(data);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Scope readline escape stripping to actual paste echoes

After any long paste, this branch strips every \x1b[7m/\x1b[27m pair from all terminal output while the 4-second fix window is active. Those are normal SGR reverse-video codes used by full-screen tools and prompts, so running something like less, vim, or other ncurses output immediately after a long paste will lose intended styling and can leave display state mismatched. The filter should be constrained to the specific readline echo pattern instead of globally removing these sequences during the window.

Useful? React with 👍 / 👎.

@binaricat
Copy link
Copy Markdown
Owner Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ebcab8c4ba

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +180 to +182
if (hasReadlineActiveRegion(data) && isPasteEcho) {
state.clearPending = Math.max(state.clearPending, 3);
return stripReadlineActiveRegion(data);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Strip readline markers only from matched paste-echo segment

When the paste-fix window is active, this branch removes \x1b[7m/\x1b[27m from the entire data chunk as soon as any line in that chunk looks like paste echo. If bash combines the echoed pasted line with other reverse-video content in the same write (for example prompt/mode indicators or TUI status text), the unrelated styling is also stripped, which is a visible rendering regression introduced by this fix path. Restricting marker removal to just the matched paste-echo span avoids clobbering unrelated output.

Useful? React with 👍 / 👎.

@binaricat
Copy link
Copy Markdown
Owner Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 60ae9fbc0c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +534 to +536
pasteTextIntoTerminal(term, text, {
scrollOnPaste: shouldScrollOnTerminalPaste(ctx.terminalSettingsRef.current),
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve scrollOnPaste=false when routing through term.paste

Calling pasteTextIntoTerminal here routes clipboard text through term.paste, which emits onData as regular user input; in createXTermRuntime that path still runs scrollToBottomAfterInput(data). In sessions where bracketed paste bytes are not added (for example disableBracketedPaste/ignoreBracketedPasteMode is enabled), pasted text is treated as printable input and will scroll even when scrollOnPaste is false, so the new paste path no longer honors the paste-specific scroll setting that the previous direct writeToSession path respected.

Useful? React with 👍 / 👎.

@binaricat
Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@binaricat binaricat merged commit 84416d0 into main May 12, 2026
16 checks passed
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.

1 participant