Files
oh-my-pi/packages/coding-agent/src/tools/bash-pty-selection.ts
T
Sanskar Singh 5d1a14e72a fix(coding-agent,pi-natives): Windows PTY hang root-cause fix with opt-out
Replaces the blanket PTY disable on Windows (PR #1105) with a targeted fix:

- TypeScript: PI_FORCE_PTY env var allows explicit Windows PTY opt-in.
  PTY is still disabled by default on Windows to prevent hangs, but power
  users who need interactive workflows can override.

- Rust: Adds ct.heartbeat() checks during PTY setup (openpty, spawn, reader
  creation) so the existing timeout mechanism works even during setup.

- Rust (Windows): Wraps openpty() in a 5-second startup timeout thread.
  If ConPTY hangs during pseudo-console creation, the Promise rejects with
  a clear error instead of hanging forever.

Fixes #1103 #1106
2026-05-16 05:03:23 +05:30

16 lines
600 B
TypeScript

import { $env } from "@oh-my-pi/pi-utils/env";
/** Minimal UI-capability fields needed to decide whether bash can use the local PTY overlay. */
export interface BashPtyContext {
hasUI?: boolean;
ui?: unknown;
}
/** Return whether a bash tool call should use the local interactive PTY overlay. */
export function canUseInteractiveBashPty(pty: boolean, ctx: BashPtyContext | undefined): boolean {
if (!pty) return false;
if ($env.PI_NO_PTY === "1") return false;
if (process.platform === "win32" && $env.PI_FORCE_PTY !== "1") return false;
return ctx?.hasUI === true && ctx.ui !== undefined;
}