Skip to content

fix(windows): detect ConPTY fallback and show warning toast (#9299)#9336

Open
harshjainnn wants to merge 2 commits into
stablyai:mainfrom
harshjainnn:wrllfix/9299-windows-conpty-fallback-warning
Open

fix(windows): detect ConPTY fallback and show warning toast (#9299)#9336
harshjainnn wants to merge 2 commits into
stablyai:mainfrom
harshjainnn:wrllfix/9299-windows-conpty-fallback-warning

Conversation

@harshjainnn

Copy link
Copy Markdown

Summary

Adds detection for Windows builds where node-pty silently falls back from ConPTY to WinPTY (build < 18309, e.g. Windows Server 2019 / Windows 10 LTSC 2019), and surfaces a one-time, non-fatal toast warning instead of letting full-screen TUI apps (tmux, vim, htop) render broken with no explanation. Fixes #9299.

Screenshots

No visual change under normal conditions (ConPTY available). On affected Windows builds, a toast now appears once per session:

Terminal compatibility warning
This Windows version doesn't support ConPTY — full-screen terminal apps (tmux, vim, htop) may not render correctly.

(Not able to capture a live screenshot from this environment — no Windows build < 18309 available to trigger it; verified via unit/integration tests instead.)

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

New/updated tests:

  • windows-pty-backend.test.ts — build-number boundary cases (>=18309, <18309, unparseable release string), non-win32 platforms
  • local-pty-provider.test.ts, pty-subprocess.test.ts, preflight-handler.test.ts — warning attached/omitted correctly through spawn and preflight paths
  • windows-terminal-capabilities.test.ts — toast fires once per owner key, does not fire on non-win32 hosts or when ConPTY is available

pnpm build not run in this environment (no Electron build target available here) — flagging for CI to confirm before merge.

AI Review Report

Reviewed with an AI coding agent focused on: (1) correctness of the ConPTY/WinPTY detection threshold against node-pty's own source, (2) whether the warning is non-fatal and doesn't block spawn on any platform, (3) consistency of the warning field threading through the existing spread-based result patterns already used in this codebase (daemon-pty-adapter.ts, terminal-host.ts, etc.), (4) test coverage at each layer the field passes through.

Findings and what was changed/verified:

  • Duplicate warning trigger (open follow-up, not yet fixed): two independent sites can fire the same toast — spawn-time in pty-connection.ts (gated by a single module-level boolean) and capability-load-time in windows-terminal-capabilities.ts (gated by a per-owner-key Set). Flagged as a known follow-up rather than blocking this PR; the per-owner-key site is the more robust of the two and is the one intended to remain long-term.
  • Stray let statement between imports in pty-connection.ts (let conptyWarningShown = false sitting mid-import-block) — flagged for cleanup, should be moved below the import block.
  • Detection threshold correctness: confirmed isConptyAvailable()'s >= 18309 check exactly mirrors node-pty's internal WindowsPtyAgent logic (this._useConpty = this._getWindowsBuildNumber() >= 18309), so the warning fires precisely when node-pty would actually be using WinPTY — not an approximation.

Cross-platform compatibility check: explicitly reviewed for macOS, Linux, and Windows.

  • isConptyAvailable() returns false immediately on any non-win32 platform (covered by test), so macOS/Linux code paths are unaffected — no new branches execute for them.
  • All new spawn-path changes (local-pty-provider.ts, pty-subprocess.ts) gate the warning behind process.platform === 'win32', consistent with existing platform-branch conventions already used throughout those files (e.g. windowsConptyDllOptions()).
  • No shortcuts, keybindings, or path-handling logic were touched.
  • The renderer-side toast and IPC/preload plumbing are additive fields (warning?, conptyAvailable?) on existing result types, so non-Windows and non-Electron (web) consumers degrade safely to undefined/false rather than breaking.
  • One residual gap: web-preload-api.ts's isConptyAvailable stub is hardcoded to Promise.resolve(false) regardless of actual remote host state — flagged for verification that this matches how sibling capabilities (wsl, pwsh, gitBash) are stubbed in that same file, since if it doesn't, remote Windows web clients could see a false-positive warning.

Security Audit

  • Input handling: the only new input is os.release() output, parsed with parseInt and defaulting to 0 on failure (verified by the "unparseable release string" test) — no unvalidated external input reaches this path.
  • Command execution: no new shell/process execution introduced. isConptyAvailable() performs no spawning; it only reads os.release().
  • Path handling: not applicable — no filesystem paths introduced or modified in this change.
  • IPC: one new IPC handler, preflight:isConptyAvailable, registered following the exact pattern of existing preflight handlers (preflight:detectRemoteWindowsTerminalCapabilities) — takes no arguments, returns a boolean, no user-controlled data crosses the boundary.
  • Auth/secrets/dependencies: no changes to authentication, secrets, or third-party dependencies. No new packages added.
  • Follow-up: none identified beyond the cross-platform stub gap noted above (web-preload-api.ts).

Notes

  • This PR is detection-and-messaging only — it does not and cannot force ConPTY on Windows builds where it doesn't exist (pre-1809/18309); that's an OS limitation, not something Orca can work around. Making WinPTY itself render full-screen TUI apps correctly is out of scope.
  • Known follow-up: consolidate the two toast-trigger sites (pty-connection.ts spawn-time vs. windows-terminal-capabilities.ts capability-load-time) to avoid a possible duplicate toast in one session.
  • Known follow-up: confirm web-preload-api.ts's hardcoded false for isConptyAvailable is intentional/consistent with how other capability stubs behave for web/remote clients, or wire it to the real remote check.
  • Primarily affects Windows Server 2019 and Windows 10 LTSC 2019 (build 17763) environments, and any other Windows install below build 18309 — most current Windows 10/11 consumer installs are unaffected and will see no behavior change.

@coderabbitai

coderabbitai Bot commented Jul 18, 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: cf51e6b4-2535-4fde-9651-d5f21ff08c23

📥 Commits

Reviewing files that changed from the base of the PR and between 4b01c2c and 86d58c4.

📒 Files selected for processing (3)
  • src/main/providers/windows-pty-backend.ts
  • src/relay/preflight-handler.test.ts
  • src/relay/preflight-handler.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/providers/windows-pty-backend.ts

📝 Walkthrough

Walkthrough

The change detects ConPTY support from the Windows platform and build number, attaches non-fatal warnings to PTY spawn results, and propagates them through daemon RPC and renderer transport paths. Preflight capability APIs now expose conptyAvailable across Electron, relay, preload, and web fallback implementations. Renderer capability publishing and fresh PTY connections display localized one-time warnings when ConPTY is unavailable. Tests cover platform detection, spawn warnings, capability reporting, and toast behavior.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the Windows ConPTY-detection and warning-toast change.
Description check ✅ Passed The PR description matches the template and covers summary, screenshots, testing, AI review, security, and notes.
Linked Issues check ✅ Passed The PR addresses the linked issue’s PTY capability-gap objective by detecting affected Windows builds and surfacing a clear warning.
Out of Scope Changes check ✅ Passed The changes stay within ConPTY detection, warning propagation, and test coverage; no unrelated functionality appears added.

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: c4bfe858-4ee1-4c16-a491-d4bd0b18fa2a

📥 Commits

Reviewing files that changed from the base of the PR and between d8629c4 and 4b01c2c.

📒 Files selected for processing (26)
  • src/main/daemon/daemon-pty-adapter.ts
  • src/main/daemon/daemon-server.ts
  • src/main/daemon/pty-subprocess.test.ts
  • src/main/daemon/pty-subprocess.ts
  • src/main/daemon/session.ts
  • src/main/daemon/terminal-host-create-contract.ts
  • src/main/daemon/terminal-host.ts
  • src/main/daemon/types.ts
  • src/main/ipc/preflight-remote-windows-terminal-capabilities.ts
  • src/main/ipc/preflight.ts
  • src/main/providers/local-pty-provider.test.ts
  • src/main/providers/local-pty-provider.ts
  • src/main/providers/types.ts
  • src/main/providers/windows-pty-backend.test.ts
  • src/main/providers/windows-pty-backend.ts
  • src/preload/api-types.ts
  • src/preload/index.ts
  • src/relay/preflight-handler.test.ts
  • src/relay/preflight-handler.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/renderer/src/components/terminal-pane/pty-transport-types.ts
  • src/renderer/src/components/terminal-pane/pty-transport.ts
  • src/renderer/src/lib/windows-terminal-capabilities.test.ts
  • src/renderer/src/lib/windows-terminal-capabilities.ts
  • src/renderer/src/lib/windows-terminal-capability-read.ts
  • src/renderer/src/web/web-preload-api.ts

Comment thread src/relay/preflight-handler.ts Outdated
@AmethystLiang AmethystLiang self-assigned this Jul 18, 2026
@AmethystLiang
AmethystLiang self-requested a review July 18, 2026 16:47
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.

Windows: tmux-style terminal multiplexers fail on some Windows versions

2 participants