Skip to content

[codex] Fix Claude macOS PTY isolation with experimental ptyHost#165

Merged
parsakhaz merged 1 commit intomainfrom
codex/fix-claude-mac-pty-host
Apr 25, 2026
Merged

[codex] Fix Claude macOS PTY isolation with experimental ptyHost#165
parsakhaz merged 1 commit intomainfrom
codex/fix-claude-mac-pty-host

Conversation

@parsakhaz
Copy link
Copy Markdown
Member

Summary

This PR implements the macOS Claude PTY fix and introduces the experimental ptyHost path behind the existing settings checkbox / PANE_USE_PTY_HOST=1 flag.

Changes include:

  • Add Phase 0 Claude Unix wrapper via sh -c 'exec ...' to reduce inherited Electron process state for Claude Code v2.1.113+.
  • Add main/src/ptyHost/* UtilityProcess RPC host for PTY spawn/write/resize/kill/pause/resume/ack.
  • Route terminal panels, CLI panels, run commands, and legacy terminal sessions through ptyHost when enabled, with legacy fallback when disabled or unavailable.
  • Preserve main-side terminal semantics: DEC 2026 filtering, scrollback persistence, alt-screen/idle tracking, and flow-control bookkeeping.
  • Fix ptyHost MessagePort acks so main-side backpressure resumes correctly.
  • Add host-ready handshake and bounded restart behavior with a 60s stability reset window.
  • Preserve manager maps across ptyHost restart so respawn can snapshot stale handles and reinitialize live panels.
  • Keep the tester-facing settings checkbox and clarify restart behavior: existing terminals keep their backend; new terminals after restart use the selected PTY mode.
  • Add focused tests for the shared ptyHost flow-control state machine.

Follow-up

Tracked in #164:

  • Packaged macOS validation.
  • Windows/WSL validation.
  • Supervisor restart integration coverage.
  • Heavy-output and TUI regression validation.
  • Decision/work for true direct ptyHost-to-renderer byte delivery.
  • Cleanup of duplicated PTY handle shims after behavior stabilizes.

Validation

  • pnpm --filter main exec vitest run src/ptyHost/flowControl.test.ts
  • pnpm typecheck
  • pnpm lint
  • Pre-commit hook reran typecheck and lint successfully.

Notes:

  • Local environment prints the existing engine warning: repo expects Node >=22.14.0; current shell is Node v20.19.3.
  • pnpm lint passes with existing warnings.
  • ptyHost remains experimental and default-off unless enabled by config or PANE_USE_PTY_HOST=1.

@parsakhaz parsakhaz force-pushed the codex/fix-claude-mac-pty-host branch from faa4ca2 to 33d821c Compare April 25, 2026 20:06
@parsakhaz parsakhaz merged commit 33d821c into main Apr 25, 2026
1 check passed
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