fix(windows): handle redirected stdout in _cprint fallback

Wraps _pt_print in try/except with a print() fallback. When a
kanban worker's stdout is piped to a log file, prompt_toolkit
raises NoConsoleScreenBufferError (Windows) or OSError (other)
because there is no real console buffer. The fallback keeps
worker output flowing instead of crashing.
This commit is contained in:
Grogger
2026-05-18 20:00:01 -07:00
committed by Teknium
parent e3293c007f
commit 8bcb6082ac
+10 -1
View File
@@ -1785,7 +1785,16 @@ def _cprint(text: str):
# direct prompt_toolkit print is safe and matches existing behavior
# (spinner frames, streamed tokens, tool activity prefixes, …).
if app is None or not getattr(app, "_is_running", False):
_pt_print(_PT_ANSI(text))
try:
_pt_print(_PT_ANSI(text))
except Exception:
# Fallback when stdout is not a real console (e.g. subprocess
# worker logging to a file). prompt_toolkit raises
# NoConsoleScreenBufferError (Windows) or OSError (other).
try:
print(text)
except Exception:
pass
return
try: