Skip to content

fix: error on non-interactive terminals without --quiet#173

Open
Skn0tt wants to merge 2 commits intomicrosoft:mainfrom
Skn0tt:agents-non-tty-guard
Open

fix: error on non-interactive terminals without --quiet#173
Skn0tt wants to merge 2 commits intomicrosoft:mainfrom
Skn0tt:agents-non-tty-guard

Conversation

@Skn0tt
Copy link
Copy Markdown
Member

@Skn0tt Skn0tt commented Apr 2, 2026

When a non-interactive terminal (e.g. a coding agent spawning with stdio: ['pipe', ...]) runs create-playwright without --quiet, enquirer prompts hang indefinitely because stdin never closes.

This adds a process.stdin.isTTY check after the --quiet early return. If the terminal is non-interactive and --quiet wasn't passed, we print an actionable error message and exit instead of hanging.

Split out from #172 for easier revert.

@Skn0tt Skn0tt requested a review from dgozman April 2, 2026 13:19
Comment on lines +98 to +101
if (!process.stdin.isTTY) {
console.error('Non-interactive terminal detected. See --help for options, then run again with --quiet.');
process.exit(1);
}
Copy link
Copy Markdown
Contributor

@karlhorky karlhorky Apr 2, 2026

Choose a reason for hiding this comment

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

@Skn0tt hmm this seems like an antipattern 🤔

  1. after fix: ensure non-TTY agents dont hang #172, --quiet is only one way to pass in all options. if options are passed in, the questions could be skipped below
  2. if I remember correctly, --quiet overrides all options passed in (which makes it less useful)

actually with all of the flags, --quiet isn't really needed, unless you want to silence the stdout (that's probably what a --quiet flag should do, not modify any options or read anything related to TTY)

if the enquirer questions are skipped, the --quiet flag is no longer needed. it's a simpler mental model - if you pass all answers via flags, it skips all questions

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It respects all options passed in: https://github.com/Skn0tt/create-playwright/blob/88b15eb00ff1d63618791b4cfe54da6b40bfdb3d/src/generator.ts#L90-L95

Can you elaborate on what you think will be broken by this?

Copy link
Copy Markdown
Contributor

@karlhorky karlhorky Apr 2, 2026

Choose a reason for hiding this comment

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

what would be broken: passing in all answers via flags without the --quiet flag

it's less obvious what this does:

pnpm create playwright --browser=chromium --test-dir=playwright --quiet

it would be easier to understand if you can see the option in the command (either of these would break after your PR):

pnpm create playwright --browser=chromium --test-dir=playwright --no-gha

pnpm create playwright --browser=chromium --test-dir=playwright --gha

that's why I was asking for a --no-gha flag, to be able to just exhaustively pass in all options


once you can exhaustively pass all options (and they skip the questions), then it works non-interactively already, and the --quiet flag can be dropped / deprecated

Copy link
Copy Markdown
Contributor

@karlhorky karlhorky Apr 2, 2026

Choose a reason for hiding this comment

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

@Skn0tt alternative PR of what I mean with my proposal:

Copy link
Copy Markdown
Member Author

@Skn0tt Skn0tt Apr 7, 2026

Choose a reason for hiding this comment

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

Thanks for elaborating. With the approach you're outlining, some agent implementations will start hanging if they forget both --no-gha and --gha. My approach where non-interactive terminals need to use --quiet is a little more cumbersome for humans with non-interactive terminals, but one less footgun for agents. Since humans use interactive terminals, this seems to be the right approach.

Copy link
Copy Markdown
Contributor

@karlhorky karlhorky Apr 7, 2026

Choose a reason for hiding this comment

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

Hm, but the --quiet flag is worse UX for humans

some agent implementations will start hanging if they forget both --no-gha and --gha

Good point - so my PR #174 could check for non-interactive (same as your PR) and then short-circuit like --quiet currently does

Better behavior than erroring out for both AI and humans

Edit: added over in my PR #174

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.

2 participants