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
Merged
Conversation
…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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 -ttprovides 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
scriptso the agent gets its own PTY (BSD form on macOS, util-linux-e -cform on Linux), with a fallback to a direct launch whenscriptis unavailable.Reproduced AND verified (macOS, PTY harness)
script: keystrokes received. ✅opencode localflow with this fix: TUI reacts to keystrokes. ✅npm run typecheckclean; 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.