Skip to content

Add Windows support (portable-pty / ConPTY)#8

Merged
L-jasmine merged 8 commits into
mainfrom
feat/support-windows
Jun 22, 2026
Merged

Add Windows support (portable-pty / ConPTY)#8
L-jasmine merged 8 commits into
mainfrom
feat/support-windows

Conversation

@L-jasmine

Copy link
Copy Markdown
Collaborator

Summary

Replaces the Unix-only pty-process with portable-pty-psmux so vibetty can spawn terminals on Windows (ConPTY) while keeping macOS/Linux working. The terminal API consumed by ws.rs is unchanged.

Why the fork

Stock portable-pty 0.9.0 (the latest published release) has a known Windows ConPTY bug (wez/wezterm#1396): the spawned process produces no output. The fix lives in wezterm's master but was never published to crates.io. portable-pty-psmux is an API-compatible fork that includes it.

Changes

  • PTY backend: pty-processportable-pty-psmux. Its blocking std I/O is bridged to async via two spawn_blocking threads — a reader that pumps output to an mpsc channel, and a writer that drains an mpsc channel (each write ack'd via a one-shot).
  • read() returns Vec<u8> (owned chunks) rather than filling a caller buffer, removing the partial-read buffering the bridge would otherwise need.
  • cwd: portable-pty defaults the working directory to $HOME; fall back to vibetty's own cwd so the child launches where vibetty was started.
  • env: inherited explicitly instead of relying on the implicit snapshot.
  • ConPTY handshake: Windows ConPTY sends ESC[6n (cursor position report) on startup and stalls until the host replies. The reader thread answers ESC[1;1R, scanned only on the first read.
  • Version bumped to 0.3.3.

Tested

  • macOS: builds clean; terminal spawns, echoes, and returns command output.
  • Windows: cmd / pwsh show banner, prompt, and command output in the TUI after the ESC[6n fix.

🤖 Generated with Claude Code

L-jasmine and others added 8 commits June 22, 2026 23:08
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Upstream portable-pty 0.9.0 (latest published) has a known Windows
ConPTY bug (wezterm/wezterm#1396): spawned process produces no output and
ignores input. The fix lives in wezterm master but was never published
to crates.io. portable-pty-psmux is an API-compatible fork (v0.9.5)
that addresses ConPTY correctness on Windows 10/11.

Co-Authored-By: Claude <noreply@anthropic.com>
Windows ConPTY sends ESC[6n (cursor position report request) on startup
and stalls until the host terminal replies ESC[row;colR. vibetty never
replied, so the spawned shell (cmd/pwsh/claude) produced no output and
ignored input. Unix shells don't send it, so macOS was unaffected.

The reader thread now watches output for ESC[6n and replies ESC[1;1R
through the writer thread. Also drops the temporary reader/writer
debug logging.

Co-Authored-By: Claude <noreply@anthropic.com>
ConPTY sends the cursor-position report request exactly once at
startup, so checking every output chunk was wasted work. Scan only the
first read, then stream subsequent output straight through.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
@L-jasmine L-jasmine merged commit 69d85c6 into main Jun 22, 2026
2 checks passed
@L-jasmine L-jasmine deleted the feat/support-windows branch June 22, 2026 17:18
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