Repository navigation
fix: intercept plugin console output to prevent TUI corruption - #19109
Closed
RaviTharuma wants to merge 1 commit into
Closed
RaviTharuma wants to merge 1 commit into
RaviTharuma wants to merge 1 commit into
Conversation
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Plugins and their dependencies using console.log/warn/error write directly to stdout, corrupting the TUI display. The logLevel config only controls OpenCode's own slog-based logging. This intercepts global console before loading plugins and routes all output through the structured Log system (service: plugin:console), which respects the configured logLevel. Fixes #19108
RaviTharuma
force-pushed
the
fix/plugin-console-intercept
branch
from
March 25, 2026 12:30
630179b to
3b14c8c
Compare
RaviTharuma
force-pushed
the
fix/plugin-console-intercept
branch
from
April 3, 2026 14:06
45eaeb4 to
3b14c8c
Compare
3 of 6 tasks
Collaborator
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
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
Closes #19108
Type of change
What does this PR do?
Plugins and their npm dependencies call
console.log/warn/errorwhich writes directly to stdout, corrupting the TUI display. ThelogLevelconfig only controls OpenCode's own slog-based logging and has zero effect on plugin console output.This is a problem I hit daily with
@rehydra/opencode(its dependencyrehydracallsconsole.warn("Validation warnings:", ...)on every anonymization pass) and custom.opencode/plugins/scripts. The TUI becomes unreadable with JSON objects and warning messages mixed into the chat.The fix adds
interceptConsole()inpackages/opencode/src/plugin/index.tsthat replaces globalconsolemethods right before plugins load. All output is routed throughLog.create({ service: "plugin:console" }), so it respectslogLeveland goes to the log file instead of stdout.This works because plugins run in the same Bun process — they share the global
consoleobject. Intercepting it once catches both plugin code and their transitive dependencies (which is why adding alogproperty toPluginInputalone wouldn't solve this — third-party deps will always useconsole.*).Related to #12931 but distinct: that issue covers uncaught errors in event handlers, this covers normal console output from working plugins.
How did you verify your code works?
rehydra/dist/core/anonymizer.js:315and.opencode/plugins/memorix.js)console.warnin plugins goes directly to TUI stdout (confirmed by screenshot evidence)plugin/index.ts— plugins are loaded viaimport()with no console interceptionLog.create()API is already used throughout the codebase (e.g.const log = Log.create({ service: "plugin" })on the same file's line 17)Screenshots / recordings
Before (TUI corrupted by plugin console output):
Checklist