Skip to content

feat: TTY detection and fail-fast for non-interactive mode#31

Merged
aaearon merged 1 commit intomainfrom
feat/tty-detection
Feb 21, 2026
Merged

feat: TTY detection and fail-fast for non-interactive mode#31
aaearon merged 1 commit intomainfrom
feat/tty-detection

Conversation

@aaearon
Copy link
Owner

@aaearon aaearon commented Feb 21, 2026

Summary

  • Adds internal/ui/tty.go with IsTerminalFunc, IsInteractive(), and ErrNotInteractive using go-isatty
  • Guards all 6 interactive prompt functions (SelectTarget, SelectSessions, ConfirmRevocation, SelectGroup, uiUnifiedSelector.SelectItem, surveyNamePrompter.PromptName) with TTY checks
  • Each guard returns a descriptive error suggesting the appropriate non-interactive flag (e.g., --target/--role, --all, --yes, --group, --favorite)
  • Promotes go-isatty v0.0.20 from indirect to direct dependency

Motivation

Prevents the CLI from hanging on interactive prompts when stdin isn't a TTY (pipes, CI, LLM agents). Instead, the CLI fails fast with actionable guidance.

Test plan

  • TestIsInteractive_WhenTerminal / TestIsInteractive_WhenNotTerminal — unit tests for TTY detection
  • TestSelectTarget_NonTTY — verifies ErrNotInteractive with --target suggestion
  • TestSelectSessions_NonTTY — verifies ErrNotInteractive with --all suggestion
  • TestConfirmRevocation_NonTTY — verifies ErrNotInteractive with --yes suggestion
  • TestSelectGroup_NonTTY — verifies ErrNotInteractive with --group suggestion
  • TestUnifiedSelector_NonTTY — verifies ErrNotInteractive with --target/--role, --group, --favorite suggestions
  • TestSurveyNamePrompter_NonTTY — verifies ErrNotInteractive with argument suggestion
  • All existing tests pass (make test)
  • Lint clean (make lint)

Introduce internal/ui/tty.go with IsInteractive() and ErrNotInteractive
so all interactive prompts fail fast with helpful error messages when
stdin is not a terminal, preventing hangs in LLM/CI/pipe contexts.

Guarded functions: SelectTarget, SelectSessions, ConfirmRevocation,
SelectGroup, uiUnifiedSelector.SelectItem, surveyNamePrompter.PromptName.

Promoted go-isatty v0.0.20 from indirect to direct dependency.
@aaearon aaearon merged commit 1ba4f5b into main Feb 21, 2026
1 check passed
@aaearon aaearon deleted the feat/tty-detection branch February 21, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant