fix: detect TTY with real isatty check instead of char-device test#45
Merged
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
WalkthroughThe ChangesTTY detection refactor
Sequence Diagram(s)sequenceDiagram
participant runCmd as run command
participant runShell
participant isTTYAvailable
participant term as golang.org/x/term
runCmd->>isTTYAvailable: isTTYAvailable(os.Stdin)
runShell->>isTTYAvailable: isTTYAvailable(os.Stdin)
isTTYAvailable->>term: term.IsTerminal(int(f.Fd()))
term-->>isTTYAvailable: bool
isTTYAvailable-->>runCmd: tty flag
isTTYAvailable-->>runShell: tty flag
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Why
devbox run <scenario>anddevbox shellfail in any non-interactive environment — CI,background jobs,
nohup, or stdin redirected from/dev/null— with:This happens even for scenarios that rely on TTY auto-detection (no explicit
tty:set).The root cause is a too-loose terminal check.
isTTYAvailabletreated any character deviceas a terminal:
But
/dev/null— what a detached/headless process gets on stdin — is a character devicethat is not a terminal. devbox then forced
tty=trueon the composeexec, and thedocker/cli layer below correctly refused it. devbox's own detection and docker/cli's
enforcement disagreed exactly on
/dev/null.What
ModeCharDevicetest withgolang.org/x/term'sterm.IsTerminal(int(f.Fd())). It performs the sametcgetioctl docker/cli usesdownstream, so devbox's detection and the compose layer's enforcement now agree.
isTTYAvailable(f *os.File)— so the detection is unittestable instead of reaching for the global
os.Stdin./dev/null, a regular file,and a pipe. The
/dev/nullcase is the one that failed under the old logic.Notes
tty:in a scenario config still takesprecedence and is untouched.
golang.org/x/termwas already a direct dependency (used byinternal/table), so no newmodules —
go.mod/go.sumare unchanged.Summary by CodeRabbit