fix(tui): route console output to log file to protect TUI display - #48517
Open
thomas-bw wants to merge 1 commit into
Open
fix(tui): route console output to log file to protect TUI display#48517thomas-bw wants to merge 1 commit into
thomas-bw wants to merge 1 commit into
Conversation
Library console output (Ajv compiling third-party MCP schemas, plugin dependencies, ...) wrote raw lines into the TUI's alternate screen and corrupted the display. In TUI mode the console methods are now redirected into the opencode log file in all TUI entrypoints and the server worker, respecting OPENCODE_LOG_LEVEL. anomalyco#31002
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Potential Related PRs Found:
Conclusion: These are related PRs addressing similar TUI protection concerns, but they're complementary fixes rather than duplicates. #48517 is distinct in focusing on console output redirection to log files with log-level filtering across all TUI entrypoints. |
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.
Issue for this PR
Fixes #48520
Type of change
What does this PR do?
#31002 reports Ajv's
unknown format "uint64" ignoredwarnings from Rust/schemars MCP schemas reaching the terminal viaconsole.warnand polluting the TUI. PR #48331 fixes that specific source by disabling Ajv's logger through the MCP SDK'sClientOptionsseam.This PR is a complementary, systemic guardrail for the same problem: any library
console.*output — Ajv today, plugin dependencies or anything else tomorrow — writes raw lines straight into the TUI's alternate screen and corrupts the display. A smallConsoleGuardis installed in every TUI entrypoint (tui,attach,run) and the server worker, redirectingconsole.debug/info/log/warn/errorinto the opencode log file while respecting the minimum log level (OPENCODE_LOG_LEVEL). Non-TUI entrypoints (serve,mcp list, ...) keep normal console behavior.The two fixes are orthogonal: #48331 removes the Ajv warning at its source; this PR guarantees the TUI survives stray console output no matter where it comes from. Neither alone covers the full class of bug behind #31002.
How did you verify your code works?
packages/opencode/test/util/console-guard.test.ts: console output lands in the log file as aservice=consoleline, and entries below the minimum level are suppressed while errors still get logged.bun testandbun typecheckpass inpackages/opencode.uint32/uint64formats. Before: Ajv warnings overwrite the display. After: they only appear inopencode.log.Screenshots / recordings
Before:
After:
Log file:
Checklist