fix(windows): detect ConPTY fallback and show warning toast (#9299)#9336
fix(windows): detect ConPTY fallback and show warning toast (#9299)#9336harshjainnn wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe 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 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: c4bfe858-4ee1-4c16-a491-d4bd0b18fa2a
📒 Files selected for processing (26)
src/main/daemon/daemon-pty-adapter.tssrc/main/daemon/daemon-server.tssrc/main/daemon/pty-subprocess.test.tssrc/main/daemon/pty-subprocess.tssrc/main/daemon/session.tssrc/main/daemon/terminal-host-create-contract.tssrc/main/daemon/terminal-host.tssrc/main/daemon/types.tssrc/main/ipc/preflight-remote-windows-terminal-capabilities.tssrc/main/ipc/preflight.tssrc/main/providers/local-pty-provider.test.tssrc/main/providers/local-pty-provider.tssrc/main/providers/types.tssrc/main/providers/windows-pty-backend.test.tssrc/main/providers/windows-pty-backend.tssrc/preload/api-types.tssrc/preload/index.tssrc/relay/preflight-handler.test.tssrc/relay/preflight-handler.tssrc/renderer/src/components/terminal-pane/pty-connection.tssrc/renderer/src/components/terminal-pane/pty-transport-types.tssrc/renderer/src/components/terminal-pane/pty-transport.tssrc/renderer/src/lib/windows-terminal-capabilities.test.tssrc/renderer/src/lib/windows-terminal-capabilities.tssrc/renderer/src/lib/windows-terminal-capability-read.tssrc/renderer/src/web/web-preload-api.ts
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:
(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 lintpnpm typecheckpnpm testpnpm buildNew/updated tests:
windows-pty-backend.test.ts— build-number boundary cases (>=18309, <18309, unparseable release string), non-win32 platformslocal-pty-provider.test.ts,pty-subprocess.test.ts,preflight-handler.test.ts— warning attached/omitted correctly through spawn and preflight pathswindows-terminal-capabilities.test.ts— toast fires once per owner key, does not fire on non-win32 hosts or when ConPTY is availablepnpm buildnot 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
warningfield 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:
pty-connection.ts(gated by a single module-level boolean) and capability-load-time inwindows-terminal-capabilities.ts(gated by a per-owner-keySet). 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.letstatement between imports inpty-connection.ts(let conptyWarningShown = falsesitting mid-import-block) — flagged for cleanup, should be moved below the import block.isConptyAvailable()'s>= 18309check exactly mirrors node-pty's internalWindowsPtyAgentlogic (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()returnsfalseimmediately on any non-win32platform (covered by test), so macOS/Linux code paths are unaffected — no new branches execute for them.local-pty-provider.ts,pty-subprocess.ts) gate the warning behindprocess.platform === 'win32', consistent with existing platform-branch conventions already used throughout those files (e.g.windowsConptyDllOptions()).warning?,conptyAvailable?) on existing result types, so non-Windows and non-Electron (web) consumers degrade safely toundefined/falserather than breaking.web-preload-api.ts'sisConptyAvailablestub is hardcoded toPromise.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
os.release()output, parsed withparseIntand defaulting to0on failure (verified by the "unparseable release string" test) — no unvalidated external input reaches this path.isConptyAvailable()performs no spawning; it only readsos.release().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.web-preload-api.ts).Notes
pty-connection.tsspawn-time vs.windows-terminal-capabilities.tscapability-load-time) to avoid a possible duplicate toast in one session.web-preload-api.ts's hardcodedfalseforisConptyAvailableis intentional/consistent with how other capability stubs behave for web/remote clients, or wire it to the real remote check.