Skip to content

fix(terminal): prevent focus prefix in startup drafts - #8433

Merged
OrcaWin merged 2 commits into
mainfrom
OrcaWin/fix-pasted-text-prefix
Jul 13, 2026
Merged

OrcaWin merged 2 commits into
mainfrom
OrcaWin/fix-pasted-text-prefix

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • route automatic agent startup drafts through the pane transport writer
  • preserve the existing direct runtime writer for callers without a live pane transport
  • cover xterm focus input followed by Codex composer readiness

Root cause

When Codex enabled terminal focus reporting, xterm could emit the focus-in sequence ESC[I. That input used the pane transport queue, while the generated PR draft bypassed the queue and wrote directly to the PTY. On Windows ConPTY the writes could race, leaving the focus sequence inside the bracketed paste and exposing a literal [I or [ prefix.

The startup draft now uses the same ordered, backpressured pane transport as xterm input.

Related work

This complements #8281. That PR improves Codex startup draft readiness, retry, and delivery ownership, but its startup paste still uses the direct PTY writer and does not address focus-input ordering.

Testing

  • pty-connection.test.ts: 422 passed
  • agent-paste-draft.test.ts: 30 passed
  • focused regression rerun after rebasing onto current main
  • pnpm run typecheck:web
  • targeted Oxlint and oxfmt checks
  • pnpm run check:max-lines-ratchet
  • git diff --check origin/main...HEAD

@coderabbitai

coderabbitai Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d606b99d-c95b-4a15-b229-5dcbd30d1a96

📥 Commits

Reviewing files that changed from the base of the PR and between 8399e16 and 5755f30.

📒 Files selected for processing (2)
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts

📝 Walkthrough

Walkthrough

Startup draft paste delivery now accepts an optional PTY writer and routes draft and bracketed-paste marker writes through it, with the runtime writer as fallback. The terminal pane passes a transport-backed writer for Codex startup drafts and records accepted input once. Tests verify delivery after xterm emits CSI I, using sendInputAccepted with bracketed-paste framing instead of window.api.pty.writeAccepted.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers summary, root cause, related work, and testing, but it omits required sections like Screenshots, AI Review Report, Security Audit, and Notes. Add the missing template sections, including Screenshots, AI Review Report with cross-platform checks, Security Audit, and Notes, or state no visual change where applicable.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: preventing focus-reporting prefixes from leaking into startup drafts.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@OrcaWin
OrcaWin merged commit d562763 into main Jul 13, 2026
2 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