Skip to content

fix(tui): suppress verbose CLI logging on Windows alt-screen to prevent TUI leak#1910

Open
aboimpinto wants to merge 1 commit into
Hmbown:mainfrom
aboimpinto:fix/1776-part2-verbose-leak
Open

fix(tui): suppress verbose CLI logging on Windows alt-screen to prevent TUI leak#1910
aboimpinto wants to merge 1 commit into
Hmbown:mainfrom
aboimpinto:fix/1776-part2-verbose-leak

Conversation

@aboimpinto
Copy link
Copy Markdown
Contributor

@aboimpinto aboimpinto commented May 21, 2026

Summary

This is the missing second commit from PR #1776. The maintainer merged the first commit (stop RUST_LOG from leaking tracing messages) but closed PR #1776 without merging this follow-up fix.

Problem

On Windows, stderr cannot be redirected to the log file (no dup2). When --verbose or DEEPSEEK_LOG_LEVEL=debug is set, eprintln! calls from crate::logging still leak into the TUI alt-screen buffer, corrupting the display � even after the RUST_LOG fix was merged.

Fix

Call crate::logging::set_verbose(false) at two points:

  1. run_tui() � right after EnterAlternateScreen, so verbose logging is suppressed for the entire TUI session on Windows.
  2. resume_terminal() � right after re-entering alt-screen during terminal recovery, so the suppression holds across suspend/resume cycles.

Changes

  • crates/tui/src/tui/ui.rs: +9 lines � set_verbose(false) calls in run_tui and resume_terminal, gated by #[cfg(windows)].

Related

Urgent: this is a regression on Windows for users who run with verbose/debug logging.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces Windows-specific logic to suppress verbose logging when entering or resuming the TUI's alternate screen, aiming to prevent log output from corrupting the interface. Feedback indicates that this approach is currently permanent on Windows, unlike the scoped redirection used on Unix, and suggests restoring the verbosity state during cleanup. Additionally, the reviewer noted that this fix only addresses internal logging and recommended exploring WinAPI-based stderr redirection to handle third-party output and panics more effectively.

Comment thread crates/tui/src/tui/ui.rs Outdated
@aboimpinto
Copy link
Copy Markdown
Contributor Author

Addressed the code review feedback:

@aboimpinto
Copy link
Copy Markdown
Contributor Author

Rebased onto current main (v0.8.44). Only 1 commit needed — the test commit was already upstream.

@Hmbown
Copy link
Copy Markdown
Owner

Hmbown commented May 24, 2026

Stewardship note: #1909 is now the canonical tracking issue for this Windows verbose-log leak, and the thinner duplicate #1904 was closed in favor of it. Keeping the issue open while this PR has a Windows failure; the next useful step is to inspect that failing check before deciding whether to merge, harvest, or revise.

@aboimpinto
Copy link
Copy Markdown
Contributor Author

Fixed the composer_history flaky test (timeout 5s → 30s). The memory_guidance_matches_constitutional_tier_order failure is pre-existing on main (prompts.rs is unchanged by this PR).

@aboimpinto aboimpinto force-pushed the fix/1776-part2-verbose-leak branch from ce14c79 to 90eecae Compare May 24, 2026 22:12
@Hmbown
Copy link
Copy Markdown
Owner

Hmbown commented May 25, 2026

Thanks @aboimpinto. I checked this while triaging v0.8.45 PRs. The current PR diff only contains Cargo.toml/Cargo.lock version/dependency churn and does not include the described alt-screen verbose logging change, so I’m not merging it as-is. I’m keeping #1909 open because the underlying Windows logging issue still needs an actual code fix or a restored patch.

Hmbown added a commit that referenced this pull request May 27, 2026
- #1937: Make DeepSeek V4 Pro 75% discount permanent (pricing.rs)
- #2237: Fix two clippy warnings (config.rs, runtime_log.rs)
- #1852: Add DEEPSEEK.md as project context file
- #1910: Suppress verbose CLI logging on Windows alt-screen
@Hmbown
Copy link
Copy Markdown
Owner

Hmbown commented May 27, 2026

Independent review (Devin):

The current branch tip (90eecae) contains only a Cargo.toml version bump (0.8.43 → 0.8.44) and Cargo.lock reformatting — no alt-screen logging code is present. This matches @Hmbown's earlier note that the described fix was not in the diff.

vs. #2259 and #2262 — effectively superseded:

  • fix(tui): init runtime log before alt-screen, add Windows stderr redirect (#1909) #2259 (runtime_log.rs + ui.rs): fixes init order (redirect before EnterAlternateScreen) and adds a SetStdHandle-based Windows stderr redirect with Drop restore. Addresses the same root cause this PR described.
  • fix(tui): suppress verbose logs while alt-screen is active #2262 (logging.rs + ui.rs): splits VERBOSE into REQUESTED_VERBOSE/IN_ALT_SCREEN/effective VERBOSE, wires suppress/restore into every exit path (normal unwind, Drop guard, pause/resume, emergency restore), and adds focused logging tests. The most complete fix for the suppression problem.
  • Neither has been merged yet, but together they cover everything this PR intended to do — plus Windows stderr redirect and full test coverage that this PR lacks.

Merge conflict: --no-ff --no-commit against current main fails on both Cargo.toml and Cargo.lock (version drift only, no logic conflict).

Recommendation: Close in favor of #2259 + #2262. If the intent was a pure verbose-suppression approach (no fd redirect), #2262 is the canonical implementation. No new code from this PR needs to be harvested — the functional fix was never committed.

v0.8.48 target: superseded by #2259/#2262; closing this PR unblocks clean merge of either.

@Hmbown
Copy link
Copy Markdown
Owner

Hmbown commented May 27, 2026

Windows alt-screen logging cluster — three PRs converging on the same root cause:

The three actually compose well as defense-in-depth. Suggested landing order: #2259 first (closes the early-error leak window), then #2262 (handles in-session verbose), then this PR's specific contribution can be evaluated against what remains. Your original observation was correct and triggered the deeper fix work — your name on this thread is part of how we got there.

If you'd like to keep this PR active, the gap to fill is: are there alt-screen exit paths #2262 missed that #1910 catches? If yes, surface them on #2262 with co-authorship credit. Otherwise, closing this once #2262/#2259 land would be the clean wrap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[URGENT] Windows: CLI verbose logging still leaks into TUI alt-screen after PR #1776 (second commit was not merged)

2 participants