Skip to content

Commit 13bec96

Browse files
authored
fix(test-classifier): stream gate must test stderr (-t 2), not stdout (#56)
The live-progress streaming never engaged in a real terminal. should_stream checked `[[ -t 1 ]]`, but invoke_ai's stdout is captured by the dispatcher via `classifier_output="$(ai_review::invoke_ai)"` — so inside the function stdout is always a pipe, never a TTY, and `-t 1` was false even with a human watching. Test stderr (`-t 2`) instead: stderr is not captured (it flows to the terminal), so it's the correct "a terminal is watching" signal — and it's exactly where we narrate the ⏺/⏎ progress. CI / pipes (stderr not a TTY) still take the silent captured path. Logic verified inside a simulated `$(...)` capture; full live confirmation is a real-terminal check (this CI env has no TTY).
1 parent 525b30f commit 13bec96

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

testing/classifier/.skills/_lib/ai-classifier-dispatch.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,12 +349,18 @@ ai_review::timeout_prefix() {
349349
# terminal), and emit ONLY the final result text to STDOUT so the dispatcher's
350350
# marker/JSON parse is byte-identical to the plain `-p` path.
351351
#
352-
# Gated so CI is unaffected: stream only when stdout is a TTY, not CI, the user
353-
# hasn't opted out (AI_REVIEW_STREAM=0), and python3 is present to split the
354-
# stream. Otherwise fall back to plain `-p`.
352+
# Gated so CI is unaffected: stream only when a terminal is watching, not CI,
353+
# the user hasn't opted out (AI_REVIEW_STREAM=0), and python3 is present to split
354+
# the stream. Otherwise fall back to plain `-p`.
355+
#
356+
# We test STDERR (-t 2), NOT stdout. invoke_ai's stdout is captured by the
357+
# dispatcher via `$(...)`, so inside this function stdout is always a pipe —
358+
# `-t 1` would be false even in a real terminal and streaming would never engage.
359+
# stderr is not captured (it flows to the terminal), so `-t 2` is the correct
360+
# "a human is watching" signal, and stderr is exactly where we narrate progress.
355361
ai_review::should_stream() {
356362
[[ "${AI_REVIEW_STREAM:-1}" != "0" ]] || return 1
357-
[[ -t 1 ]] || return 1
363+
[[ -t 2 ]] || return 1
358364
[[ "${CI:-}" != "true" ]] || return 1
359365
command -v python3 &>/dev/null || return 1
360366
return 0

0 commit comments

Comments
 (0)