fix(cli): fall back to plain print when prompt_toolkit has no Win32 console#22482
Closed
0x003600x wants to merge 1 commit into
Closed
fix(cli): fall back to plain print when prompt_toolkit has no Win32 console#224820x003600x wants to merge 1 commit into
0x003600x wants to merge 1 commit into
Conversation
Kanban worker subprocesses redirect stdout to log files on Windows, so prompt_toolkit Win32Output raises NoConsoleScreenBufferError. Centralize emission in _safe_pt_print and use it from _cprint paths and output-history replay. Fixes NousResearch#22445
Contributor
|
This is the canonical fix for NoConsoleScreenBufferError on Windows non-interactive contexts. Confirmed from kanban dispatcher logs: crashed=1 traces directly to this error. Closing my duplicate #25556 in favor of this PR. |
Contributor
|
Closing as superseded by #28330. Triage notes (high confidence): Thanks for the contribution — the underlying problem this PR addresses has been resolved by the linked PR on current main. If you believe this was closed in error, please comment and we'll reopen. (Bulk-closed during a CLI PR triage sweep.) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Kanban worker processes on Windows spawn with
stdout/stderrredirected to log files (subprocess.Popenin the Kanban dispatcher). In that setup there is no Win32 console buffer, soprompt_toolkit’sprint_formatted_textpath can raiseNoConsoleScreenBufferErrorand the worker exits before doing work.This change introduces
_safe_pt_printincli.py: try the existing ANSI →print_formatted_textpath, and on any failure fall back to plainprint(..., flush=True). All_cprintemission paths and output-history replay use this helper.Related issue
Fixes #22445
Changes
cli.py: add_safe_pt_print; route_cprintand_replay_output_historythrough it.tests/cli/test_cprint_redirect_fallback.py: regression tests when_pt_printraises and for replay history.Testing