FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(ui): propagate readline/TTY errors as quick exit by tusharmath · Pull Request #2570 · tailcallhq/forgecode · GitHub

fix(ui): propagate readline/TTY errors as quick exit - #2570

Merged
tusharmath merged 5 commits into
mainfrom
quick-exit
Mar 15, 2026
Merged

fix(ui): propagate readline/TTY errors as quick exit#2570
tusharmath merged 5 commits into
mainfrom
quick-exit

Conversation

tusharmath commented Mar 15, 2026
edited
Loading

Copy link
Copy Markdown
Collaborator

Summary

Fix readline/TTY errors to propagate as quick exits instead of being silently swallowed or displayed as inline errors, ensuring the process terminates cleanly when the terminal is unavailable.

Context

When Forge runs in a non-TTY environment (e.g., piped input, CI, or other headless contexts), the readline prompt fails with an I/O error. Previously, these errors were treated identically to recoverable runtime errors — they were displayed inline and the loop continued, leading to confusing behavior or infinite error loops. This fix ensures that readline failures cause a clean, immediate exit with the error propagated to the caller.

Changes

  • Introduced a dedicated ReadLineError wrapper type (using thiserror) to distinguish readline/TTY failures from other runtime errors
  • Updated ForgeEditor::prompt to wrap I/O errors in ReadLineError so they can be identified downstream
  • Updated the UI error-handling loop to detect ReadLineError and return early (quick exit) instead of displaying the error inline
  • Added all errors to tracker and tracing before the readline type check so nothing is lost
  • Added a comment explaining the TTY failure behavior on the first prompt call

Key Implementation Details

The error discrimination uses error.downcast::<ReadLineError>() after logging/tracking the error. If the downcast succeeds, the error is re-returned immediately via Err(error)?, causing the entire UI task to exit. If it fails (a normal recoverable error), the existing inline display path is used. This ensures zero behavioral change for non-readline errors.

Testing

# Run crate-specific tests
cargo insta test --accept -p forge_main

# Simulate a non-TTY environment to trigger readline error path
echo "hello" | cargo run -- --help

# Verify clean exit code on TTY failure
echo $?

Links

github-actions Bot added the type: fix Iterations on existing features or infrastructure. label Mar 15, 2026
tusharmath changed the title fix(ui): propagate prompt error with early exit using anyhow::Ok fix(ui): propagate readline/TTY errors as quick exit Mar 15, 2026
tusharmath merged commit 92321fe into main Mar 15, 2026
10 checks passed
tusharmath deleted the quick-exit branch March 15, 2026 11:48
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

Labels

type: fix Iterations on existing features or infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL