Repository navigation
Conversation
|
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. |
|
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. |
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
db94e69 to
235c26c
Compare
|
This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2. — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊 |
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