Skip to content

Windows support — Phase 1: ConPTY backend + un-gate terminal - #11

Merged
wess merged 1 commit into
mainfrom
windows/conpty
Jul 8, 2026
Merged

Windows support — Phase 1: ConPTY backend + un-gate terminal#11
wess merged 1 commit into
mainfrom
windows/conpty

Conversation

@wess

@wess wess commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Phase 1 of Windows support (builds on the merged Phase 0 spike). Gives the terminal an actual backend on Windows.

What's here

  • pty now has two backends behind one Pty API. Deps split by target: rustix on Unix, the windows crate on Windows.
    • windows/conpty.rs — creates two anonymous pipes + an HPCON (CreatePseudoConsole/ResizePseudoConsole/ClosePseudoConsole); keeps the input-write and output-read ends.
    • windows/spawn.rsCreateProcessW with PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE + EXTENDED_STARTUPINFO_PRESENT; handle inheritance off; proper command-line quoting and a merged UTF-16 environment block; kill/wait/try_wait over the process handle.
    • windows/mod.rs — the Pty type mirroring the Unix one (spawn/read/write/try_clone_reader/try_clone_writer/resize/child_pid/foreground_running/kill/wait/try_wait).
  • default_shell() resolves %COMSPEC%cmd.exe on Windows.
  • terminal loses its #![cfg(unix)] gate — the reader thread is all File I/O, so it's portable as-is.

Verification

  • cargo check --target x86_64-pc-windows-gnu passes for pty and terminal (local cross-check).
  • Full Unix suite still green: pty 20, terminal 10 tests; macOS --workspace build clean; clippy clean.
  • The Windows CI job on this PR is the authoritative check (MSVC) — it also re-runs the informational full-workspace build, which should now show a smaller remaining surface (the terminal::* / pty::* errors in app are resolved; notes, relay, and app's IPC/titlebar cluster remain for Phases 2–3).

Known Windows limitations (documented, deferred)

  • foreground_running() returns false on Windows (ConPTY has no controlling-terminal foreground-group query) — callers treat it as "not busy".
  • Runtime behavior (actually rendering + driving a shell) can't be exercised in CI; needs a Windows machine to validate interactively once app compiles (Phase 2).

Not in scope

app portability (named-pipe IPC, Windows window chrome), relay, and packaging — Phases 2–4.

Phase 1 of Windows support. Add a pseudoconsole (ConPTY) backend to the
pty crate behind the same Pty API the Unix pty pair exposes, and drop the
#![cfg(unix)] gates from pty and terminal so both build on Windows.

- pty splits by target: rustix on Unix, the windows crate on Windows.
  windows/{conpty,spawn,mod}.rs wire two anonymous pipes to an HPCON,
  spawn the child via CreateProcessW + PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE,
  and drive read/write/resize/kill/wait through it.
- default_shell() resolves %COMSPEC%/cmd.exe on Windows.
- Winsize::to_termios stays Unix-only.

Verified: cargo check --target x86_64-pc-windows-gnu for pty + terminal,
and the full Unix test suite (pty 20, terminal 10) still green.
@wess
wess merged commit fead064 into main Jul 8, 2026
3 checks passed
@wess
wess deleted the windows/conpty branch July 8, 2026 19:07
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