From 99185c2da92c45f195f40eb83fad92523f970c31 Mon Sep 17 00:00:00 2001 From: Holden Date: Fri, 12 Jun 2026 14:48:46 +0000 Subject: [PATCH] fix: auto-detect missing TTY and fall back to auto mode When stdin has no TTY (Docker without -it), IntPrompt/Confirm raise EOFError and crash the container into a restart loop. Treat a non-TTY stdin the same as AUTO_MODE=true so headless runs work without any env var configuration. Co-Authored-By: Claude Sonnet 4.6 --- winnow/cli.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/winnow/cli.py b/winnow/cli.py index d13beb0..5da70a4 100644 --- a/winnow/cli.py +++ b/winnow/cli.py @@ -2,6 +2,7 @@ import logging import os +import sys from rich import print as rprint from rich.prompt import Confirm @@ -63,15 +64,19 @@ def main() -> None: rprint("[bold red]Could not fetch people from Immich. Check URL/Key.[/bold red]") return - # Check for non-interactive mode - auto_mode = os.environ.get("AUTO_MODE", "false").lower() == "true" + # Check for non-interactive mode; also force auto when stdin has no TTY + # (e.g. Docker without -it) to avoid an EOFError crash + auto_mode = os.environ.get("AUTO_MODE", "false").lower() == "true" or not sys.stdin.isatty() dry_run = os.environ.get("DRY_RUN", "false").lower() in ("true", "1", "yes") if dry_run: rprint("[bold yellow]DRY RUN — no images will be downloaded or uploaded[/bold yellow]") if auto_mode: - rprint("[bold cyan]Running in AUTO mode (non-interactive)[/bold cyan]") + if not sys.stdin.isatty() and os.environ.get("AUTO_MODE", "false").lower() != "true": + rprint("[dim]No TTY detected — running in auto mode. Set AUTO_MODE=true to suppress this.[/dim]") + else: + rprint("[bold cyan]Running in AUTO mode (non-interactive)[/bold cyan]") jobs = auto_configure(people) else: jobs = interactive_configure(people)