Skip to content
This repository was archived by the owner on Jun 23, 2026. It is now read-only.

Run local agent TUIs in a PTY so keyboard input works (opencode/kilocode on macOS) - #70

Merged
BarneyChambers merged 1 commit into
mainfrom
fix/local-agent-pty
Jun 16, 2026
Merged

Run local agent TUIs in a PTY so keyboard input works (opencode/kilocode on macOS)#70
BarneyChambers merged 1 commit into
mainfrom
fix/local-agent-pty

Conversation

@BarneyChambers

Copy link
Copy Markdown
Collaborator

Summary

Confirmed root cause of "can't type / Ctrl-C dead" in opencode and kilocode on local/macOS (both work remotely): OpenTUI agents only accept keyboard input when they own a controlling PTY. Remotely ssh -tt provides one; locally they were launched as a child sharing the CLI's terminal, so input was dead. (Verified it's not job control — the agent is foreground with the tty — and not opencode-specific — kilocode too.)

Fix

Wrap the local interactive launch in script so the agent gets its own PTY (BSD form on macOS, util-linux -e -c form on Linux), with a fallback to a direct launch when script is unavailable.

Reproduced AND verified (macOS, PTY harness)

  • Direct opencode in a PTY: keystrokes ignored.
  • opencode wrapped in script: keystrokes received. ✅
  • Full opencode local flow with this fix: TUI reacts to keystrokes. ✅
  • npm run typecheck clean; local in-process test passes.

Final confirmation in a real Terminal.app session pending (the harness can't 100% emulate a real terminal), but this is repro-backed, not a guess.

…nput

OpenTUI-based agents (OpenCode, Kilo Code) accept keyboard input only when they
own a controlling PTY. Remotely that's provided by `ssh -tt`; locally they were
launched as a child sharing the CLI's terminal, so on macOS typing and Ctrl-C
did nothing once the agent TUI started.

Wrap the local interactive launch in `script` to give the agent its own PTY
(BSD form on macOS, util-linux -e -c form on Linux), falling back to a direct
launch when `script` is unavailable.

Verified on macOS: opencode launched directly in a PTY harness ignores
keystrokes; the same agent wrapped in `script` reacts to them.
@BarneyChambers
BarneyChambers merged commit be4e721 into main Jun 16, 2026
2 checks passed
@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
grid-spawn-ui Ready Ready Preview, Comment Jun 16, 2026 12:18pm

Request Review

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant