Fix WATCH_DETAIL silently falling back to default

An inline comment on the WATCH_DETAIL value line (e.g.
`WATCH_DETAIL=balanced  # ...`) parsed as the literal "balanced  # ..."
value, failed validation, and silently reverted to the default mode.

- setup.py: move the allowed-values list off the value line in the env
  template so the wizard no longer models a trailing inline comment.
- config.py: strip a whitespace-preceded inline comment from unquoted
  values so a stray comment can't silently break selection again
  (preserves '#' inside quotes / API keys).
- SKILL.md: note to write the bare key with no trailing comment.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
bradautomates
2026-06-30 17:20:07 +10:00
parent a1e7c4128b
commit 83da59fa78
3 changed files with 14 additions and 3 deletions
+1 -1
View File
@@ -93,7 +93,7 @@ On macOS with Homebrew, it auto-installs `ffmpeg` and `yt-dlp`. On Linux/Windows
- `balanced` (recommended) — scene-aware frames (cap 100, default). - `balanced` (recommended) — scene-aware frames (cap 100, default).
- `token-burner` — scene-aware, uncapped (maximum fidelity; high token cost). - `token-burner` — scene-aware, uncapped (maximum fidelity; high token cost).
Write the answer directly into `~/.config/watch/.env` by setting: Write the answer directly into `~/.config/watch/.env` by setting the bare key on its own line — **no trailing inline comment** (a `# note` after the value can break parsing):
```bash ```bash
WATCH_DETAIL=balanced WATCH_DETAIL=balanced
+9
View File
@@ -32,6 +32,15 @@ def read_env_file(path: Path | None = None) -> dict[str, str]:
value = value.strip() value = value.strip()
if len(value) >= 2 and value[0] in ('"', "'") and value[-1] == value[0]: if len(value) >= 2 and value[0] in ('"', "'") and value[-1] == value[0]:
value = value[1:-1] value = value[1:-1]
else:
# Strip an inline comment (a '#' preceded by whitespace) from an
# unquoted value. Without this, `WATCH_DETAIL=balanced # note`
# parses as "balanced # note", fails validation, and silently
# falls back to the default. Keeps '#' inside quotes / API keys.
for i, ch in enumerate(value):
if ch == "#" and i > 0 and value[i - 1] in " \t":
value = value[:i].rstrip()
break
values[key.strip()] = value values[key.strip()] = value
return values return values
+4 -2
View File
@@ -52,8 +52,10 @@ ENV_TEMPLATE = """# /watch API configuration
GROQ_API_KEY= GROQ_API_KEY=
OPENAI_API_KEY= OPENAI_API_KEY=
# Default watch behavior (the /watch first-run wizard sets this for you): # Default watch behavior (the /watch first-run wizard sets this for you).
# WATCH_DETAIL=balanced # transcript | efficient | balanced | token-burner # Allowed values: transcript | efficient | balanced | token-burner
# Keep the value on its own line with no trailing comment.
# WATCH_DETAIL=balanced
""" """