-
Notifications
You must be signed in to change notification settings - Fork 3k
fix(tui): suppress verbose CLI logging on Windows alt-screen to prevent TUI leak #1905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -276,6 +276,11 @@ pub async fn run_tui(config: &Config, options: TuiOptions) -> Result<()> { | |
| if use_alt_screen { | ||
| execute!(stdout, EnterAlternateScreen)?; | ||
| } | ||
| // On Windows, stderr cannot be redirected to the log file (no dup2). | ||
| // Suppress verbose CLI logging once the alt-screen is active so | ||
| // eprintln! calls from crate::logging don't leak into the TUI buffer. | ||
| #[cfg(windows)] | ||
| crate::logging::set_verbose(false); | ||
| // Initialize the file-backed TUI log and (on Unix) redirect raw stderr | ||
| // away from the alt-screen for the lifetime of this guard. Any | ||
| // `eprintln!`, panic message, or third-party stderr write that would | ||
|
|
@@ -6417,6 +6422,10 @@ fn resume_terminal( | |
| if use_alt_screen { | ||
| execute!(terminal.backend_mut(), EnterAlternateScreen)?; | ||
| } | ||
| // Re-entering alt-screen after mode recovery — suppress verbose | ||
| // CLI logging again so eprintln! doesn't leak into the TUI. | ||
| #[cfg(windows)] | ||
| crate::logging::set_verbose(false); | ||
|
Comment on lines
+6425
to
+6428
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This call to |
||
| recover_terminal_modes( | ||
| terminal.backend_mut(), | ||
| use_mouse_capture, | ||
|
|
@@ -7580,4 +7589,4 @@ fn extract_reasoning_header(text: &str) -> Option<String> { | |
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests; | ||
| mod tests; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic is duplicated in
resume_terminal(line 6428). To improve maintainability and follow the project's established patterns, consider moving this Windows-specific verbosity suppression intorecover_terminal_modes(line 6562). That function is already documented as the canonical location for terminal-mode setup and is called by bothrun_tuiandresume_terminal.