Skip to content

Fix Windows ConPTY OSC color reply leak#6975

Open
brennanb2025 wants to merge 2 commits into
mainfrom
brennanb2025/windows-conpty-osc-color-reply-leak
Open

Fix Windows ConPTY OSC color reply leak#6975
brennanb2025 wants to merge 2 commits into
mainfrom
brennanb2025/windows-conpty-osc-color-reply-leak

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary\n- suppress OSC 10/11 color-query replies for local native Windows ConPTY panes\n- keep OSC color replies enabled for POSIX-like paths such as WSL, SSH, and remote runtimes\n- add regression coverage for startup spawn metadata and hidden Codex startup output on Windows ConPTY\n\n## Root Cause\nThe startup color-query work added replies that are written back as PTY input. Native Windows ConPTY can treat those bytes like keyboard input, swallowing ESC and echoing the printable remainder into Codex's prompt (for example, ]10;rgb:...).\n\n## Tests\n- pnpm test src/renderer/src/components/terminal-pane/pty-connection.test.ts\n- pnpm test src/renderer/src/components/terminal-pane/terminal-capability-replies.test.ts\n- pnpm run typecheck:web

Made with Orca 🐋


Open in Stage

Co-authored-by: Orca <help@stably.ai>
@stage-review

stage-review Bot commented Jul 1, 2026

Copy link
Copy Markdown

Ready to review this PR? Stage has broken it down into 4 individual chapters for you:

Title
1 Add OSC color reply suppression to capability handlers
2 Determine ConPTY environment and suppression state
3 Apply color reply suppression to PTY connection
4 Test Windows ConPTY color reply suppression
Open in Stage

Chapters generated by Stage for commit 3991e00 on Jul 1, 2026 4:46am UTC.

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This change adds OSC color query reply gating for terminal panes. terminal-capability-replies.ts now accepts disableOscColorReplies and uses a shared OSC 10/11 handler helper. pty-connection.ts derives reply eligibility from Windows ConPTY and SSH runtime state, then gates startup and pending foreground OSC color replies accordingly. The test suites add Windows-specific coverage for startup queries, hidden Codex queries, and handler consumption behavior.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR includes Summary and Tests, but it omits the required Screenshots, AI Review Report, Security Audit, and Notes sections. Add the missing template sections and briefly document screenshots/no visual change, the AI review with cross-platform checks, the security audit, and any platform-specific notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately describes the main change: fixing the Windows ConPTY OSC color reply leak.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: cc4221d8-45e1-4b6c-9065-491c166dd548

📥 Commits

Reviewing files that changed from the base of the PR and between 4638cfc and 3991e00.

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

Comment on lines +2114 to +2115
const isSshWindowsConpty =
runtimeEnvironmentId === null && sshRemotePlatform === 'win32' && !isWslShellName(shellOverride)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Base SSH ConPTY gating on effectiveWindowsShellOverride.

Line 2115 still checks shellOverride, so Windows SSH panes that enter WSL via inherited/default shell settings are classified as ConPTY and stop answering OSC 10/11 queries. That regresses the new WSL-safe path this block just computed.

Suggested fix
   const isSshWindowsConpty =
-    runtimeEnvironmentId === null && sshRemotePlatform === 'win32' && !isWslShellName(shellOverride)
+    runtimeEnvironmentId === null &&
+    sshRemotePlatform === 'win32' &&
+    !isWslShellName(effectiveWindowsShellOverride)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const isSshWindowsConpty =
runtimeEnvironmentId === null && sshRemotePlatform === 'win32' && !isWslShellName(shellOverride)
const isSshWindowsConpty =
runtimeEnvironmentId === null &&
sshRemotePlatform === 'win32' &&
!isWslShellName(effectiveWindowsShellOverride)

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