tui3: guard against non-interactive stdin with TTY check

Add _stdin_is_tty() helper and check at start of _launch_tui3_or_exit.
When stdin is not a TTY, emit a clear error message and exit 1 instead
of propagating an EOF exception from seed setup prompts.
Add test for non-interactive stdin error path; patch _stdin_is_tty in
existing tests that expect tui3 launch to proceed.

Fixes SeedPass-6d26
This commit is contained in:
thePR0M3TH3AN committed 2026-03-09 12:45:34 -04:00
1 parent 0cf1d58c9c
commit 96f64d00bc
2 files changed
+21

No files matched your search

+10
View File
@@ -154,11 +154,21 @@ def _launch_legacy_tui(*, fingerprint: Optional[str]) -> typer.Exit:
return typer.Exit(legacy_main(fingerprint=fingerprint))
def _stdin_is_tty() -> bool:
return sys.stdin.isatty()
def _launch_tui3_or_exit(
*,
fingerprint: Optional[str],
services: Optional[dict[str, object]] = None,
) -> None:
if not _stdin_is_tty():
typer.echo(
"seedpass tui3: requires an interactive terminal (stdin is not a TTY).",
err=True,
)
raise typer.Exit(1)
kwargs: dict[str, object] = {"fingerprint": fingerprint}
if services is not None:
kwargs.update(