fix(cli): stream stdin/stdout for --run so interactive TUIs work#133
Merged
Conversation
`osprey <file> --run` executed the compiled program through the capture path (runRunProgram -> CompileAndCapture -> executeProgramWithCapture, which calls exec.Cmd.Output()). That path never wired the child's stdin, so Go connected it to /dev/null: the first termReadKey() / input() read returned EOF and any interactive loop exited immediately. It also buffered stdout until exit, so a TUI's frames only appeared after the program had already quit. That is why api_browser.osp printed one frame and then "Goodbye!". Switch the CLI run mode to the streaming path (CompileAndRun -> executeProgram) which now wires Stdin, Stdout and Stderr straight through, giving interactive programs a live stdin and incremental output. executeProgram already streamed stdout/stderr; it was missing Stdin, now added. Compilation diagnostics stay on stderr, so captured stdout for non-interactive use is unchanged and the run-mode tests still see an empty CommandResult.Output. The integration test harness is unaffected: it drives programs through captureJITOutput -> CompileAndRunJIT (os.Stdout redirection), not the CLI capture functions. Verified end to end by driving examples/tui/api_browser.osp through a real PTY with scripted keystrokes: arrow keys move the selection across repos, Enter opens the detail view, and the app only exits on 'q' - never instantly on startup. Full `make test` and lint pass.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Interactive
--runwas broken for TUIs (instant quit)osprey <file> --runran the compiled program through the capture path(
runRunProgram → CompileAndCapture → executeProgramWithCapture, i.e.exec.Cmd.Output()). That path never wired the child's stdin, so Go pointedit at
/dev/null: the firsttermReadKey()/input()read hit EOF and anyinteractive loop exited immediately. It also buffered stdout until exit, so a
TUI's frames only appeared after the program had already quit.
That's exactly the reported symptom —
examples/tui/api_browser.ospprinted oneframe and then
Goodbye!without accepting a single keystroke.Fix
Switch CLI run mode to the streaming path (
CompileAndRun → executeProgram),which now wires
Stdin,Stdout,Stderrstraight through.executeProgramalready streamed stdout/stderr; it was only missing
Stdin, now added.run-mode tests still see an empty
CommandResult.Output.captureJITOutput → CompileAndRunJIT(os.Stdout redirection), not the CLIcapture functions.
Verification
arrow moves across repos (
osprey → llvm → antlr), Enter opens the detailview (antlr description renders), and the app exits only on
q— neverinstantly on startup.
make test(lint + integration + unit + coverage) and run-mode unit tests allpass.