Skip to content

Allow CLI commands to run without a TTY#5854

Open
ashitaka1 wants to merge 3 commits into
viamrobotics:mainfrom
ashitaka1:ashitaka1/fix-module-generate-tty
Open

Allow CLI commands to run without a TTY#5854
ashitaka1 wants to merge 3 commits into
viamrobotics:mainfrom
ashitaka1:ashitaka1/fix-module-generate-tty

Conversation

@ashitaka1
Copy link
Copy Markdown
Member

Summary

  • viam module generate and fragment removal use charmbracelet/huh forms and spinners that require a terminal, making them unusable from CI, scripts, or automation tools even when all flags are provided
  • Adds isInteractive() check (via os.Stdin fd) and returns clear errors when interactive input would be needed (missing flags, unauthenticated)
  • Replaces the huh spinner with plain status line output in non-interactive mode
  • All interactive (TTY) behavior is unchanged

Test plan

  • viam module generate --name foo without TTY → clear "missing required flags" error
  • viam module generate unauthenticated without TTY → clear "authentication required" error
  • viam module generate with all flags, authenticated, without TTY → runs successfully with status line output
  • Existing CLI tests pass with race detector

🤖 Generated with Claude Code

@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Mar 17, 2026
`viam module generate` and fragment removal use charmbracelet/huh
forms and spinners that require a terminal. This makes them unusable
from CI, scripts, or tools like Claude Code even when all flags are
provided.

Detect non-interactive environments via os.Stdin and:
- Return clear errors when interactive input would be needed
  (missing flags, unauthenticated)
- Replace the huh spinner with plain status line output
- Leave all interactive (TTY) behavior unchanged
@ashitaka1 ashitaka1 force-pushed the ashitaka1/fix-module-generate-tty branch from f947db1 to 6200142 Compare March 17, 2026 12:41
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Mar 17, 2026
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Mar 17, 2026
…generate-tty

# Conflicts:
#	cli/module_generate.go
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Apr 28, 2026
@njooma njooma requested a review from stuqdog April 28, 2026 19:36
Comment thread cli/module_generate.go
Comment on lines +168 to +169
// logTitle updates the spinner in interactive mode, prints a status line
// in non-interactive mode, and is a no-op in debug mode.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little confused, why do we want this to be a no-op in debug mode? I would think that debug mode should have no impact on behavior other than providing additional log messages, at least when we're in interactive mode.

Comment thread cli/module_generate.go
if globalArgs.Debug {
action()
} else {
if interactive && !globalArgs.Debug {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SImilar question here, why do treat the debug case and the non-interactive case the same?

@viamrobotics-overwatch
Copy link
Copy Markdown

Hey @ashitaka1 — this PR has been approved and CI has been green for 3+ business days. Ready to merge?

Auto-comment from overwatch. Will not re-nudge for 7 days.

@viamrobotics-overwatch
Copy link
Copy Markdown

Hey @ashitaka1 — this PR has been approved and CI has been green for 8+ business days. Ready to merge?

Auto-comment from overwatch. Will not re-nudge for 7 days.

@viamrobotics-overwatch
Copy link
Copy Markdown

Hey @ashitaka1 — this PR has been approved and CI has been green for 13+ business days. Ready to merge?

Auto-comment from overwatch. Will not re-nudge for 7 days.

@viamrobotics-overwatch
Copy link
Copy Markdown

Hey @ashitaka1 — this PR has been approved and CI has been green for 18+ business days. Ready to merge?

Auto-comment from overwatch. Will not re-nudge for 7 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test This pull request is marked safe to test from a trusted zone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants