tui output corrupted when using plugins #4161

Closed
opened 2026-02-16 17:42:50 -05:00 by yindo · 5 comments
Owner

Originally created by @elithrar on GitHub (Jan 4, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

When using plugins - e.g. my own git-worktree here - I see plugin output polluting the TUI.

  • This goes away when I resize the terminal itself (Ghostty version 1c2db85aa - nightly build)
  • It is reproducible 100% of the time - just re-invoke the plugin via prompt.
  • How can I get TUI logs or state to share here / investigate further?
Image Image

plugins all load correctly:

➜ opencode run hey --print-logs

INFO  2026-01-04T13:42:41 +279ms service=default version=0.0.0-dev-202601041317 args=["run","hey","--print-logs"] opencode
INFO  2026-01-04T13:42:41 +1ms service=default directory=/Users/matt/repos/dotfiles creating instance
INFO  2026-01-04T13:42:41 +0ms service=project directory=/Users/matt/repos/dotfiles fromDirectory
INFO  2026-01-04T13:42:41 +28ms service=default directory=/Users/matt/repos/dotfiles bootstrapping
INFO  2026-01-04T13:42:41 +2ms service=config path=/Users/matt/.config/opencode/config.json loading
INFO  2026-01-04T13:42:41 +0ms service=config path=/Users/matt/.config/opencode/opencode.json loading
INFO  2026-01-04T13:42:41 +0ms service=config path=/Users/matt/.config/opencode/opencode.jsonc loading
INFO  2026-01-04T13:42:42 +218ms service=bun cmd=["/Users/matt/.bun/install/global/node_modules/opencode-darwin-arm64/bin/opencode","add","@opencode-ai/plugin@0.0.0-dev-202601041317","--exact"] cwd=/Users/matt/.config/opencode running
INFO  2026-01-04T13:42:42 +17ms service=config path=/Users/matt/repos/dotfiles/.opencode/opencode.jsonc loading
INFO  2026-01-04T13:42:42 +0ms service=config path=/Users/matt/repos/dotfiles/.opencode/opencode.json loading
INFO  2026-01-04T13:42:42 +0ms service=bun cmd=["/Users/matt/.bun/install/global/node_modules/opencode-darwin-arm64/bin/opencode","add","@opencode-ai/plugin@0.0.0-dev-202601041317","--exact"] cwd=/Users/matt/repos/dotfiles/.opencode running
INFO  2026-01-04T13:42:42 +5ms service=plugin path=file:///Users/matt/repos/dotfiles/.opencode/plugin/git-worktree.ts loading plugin
INFO  2026-01-04T13:42:42 +27ms service=plugin path=opencode-copilot-auth@0.0.9 loading plugin
INFO  2026-01-04T13:42:42 +0ms service=bun code=0 stdout=bun add v1.3.5 (1e86cebd)

installed @opencode-ai/plugin@0.0.0-dev-202601041317

[5.00ms] done
 stderr=Saved lockfile
 done
INFO  2026-01-04T13:42:42 +0ms service=bun cmd=["/Users/matt/.bun/install/global/node_modules/opencode-darwin-arm64/bin/opencode","install"] cwd=/Users/matt/.config/opencode running
INFO  2026-01-04T13:42:42 +1ms service=bun code=0 stdout=bun add v1.3.5 (1e86cebd)

Plugins

git-worktree

OpenCode version

0.0.0-dev-202601041317

Steps to reproduce

  1. Install/copy over https://github.com/elithrar/dotfiles/blob/main/.config/opencode/plugin/git-worktree.ts
  2. Run opencode + ask it to create worktrees
  3. Observe what appears to be polluted TUI rendering?
Originally created by @elithrar on GitHub (Jan 4, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description When using plugins - e.g. my own `git-worktree` here - I see plugin output polluting the TUI. * This goes away when I resize the terminal itself (Ghostty version `1c2db85aa` - nightly build) * It is reproducible 100% of the time - just re-invoke the plugin via prompt. * How can I get TUI logs or state to share here / investigate further? <img width="976" height="1195" alt="Image" src="https://github.com/user-attachments/assets/7c037432-7798-4d22-b4e5-8826bc9e4b53" /> <img width="877" height="150" alt="Image" src="https://github.com/user-attachments/assets/32e01dc3-146c-4333-863b-b95050608b4c" /> plugins all load correctly: ``` ➜ opencode run hey --print-logs INFO 2026-01-04T13:42:41 +279ms service=default version=0.0.0-dev-202601041317 args=["run","hey","--print-logs"] opencode INFO 2026-01-04T13:42:41 +1ms service=default directory=/Users/matt/repos/dotfiles creating instance INFO 2026-01-04T13:42:41 +0ms service=project directory=/Users/matt/repos/dotfiles fromDirectory INFO 2026-01-04T13:42:41 +28ms service=default directory=/Users/matt/repos/dotfiles bootstrapping INFO 2026-01-04T13:42:41 +2ms service=config path=/Users/matt/.config/opencode/config.json loading INFO 2026-01-04T13:42:41 +0ms service=config path=/Users/matt/.config/opencode/opencode.json loading INFO 2026-01-04T13:42:41 +0ms service=config path=/Users/matt/.config/opencode/opencode.jsonc loading INFO 2026-01-04T13:42:42 +218ms service=bun cmd=["/Users/matt/.bun/install/global/node_modules/opencode-darwin-arm64/bin/opencode","add","@opencode-ai/plugin@0.0.0-dev-202601041317","--exact"] cwd=/Users/matt/.config/opencode running INFO 2026-01-04T13:42:42 +17ms service=config path=/Users/matt/repos/dotfiles/.opencode/opencode.jsonc loading INFO 2026-01-04T13:42:42 +0ms service=config path=/Users/matt/repos/dotfiles/.opencode/opencode.json loading INFO 2026-01-04T13:42:42 +0ms service=bun cmd=["/Users/matt/.bun/install/global/node_modules/opencode-darwin-arm64/bin/opencode","add","@opencode-ai/plugin@0.0.0-dev-202601041317","--exact"] cwd=/Users/matt/repos/dotfiles/.opencode running INFO 2026-01-04T13:42:42 +5ms service=plugin path=file:///Users/matt/repos/dotfiles/.opencode/plugin/git-worktree.ts loading plugin INFO 2026-01-04T13:42:42 +27ms service=plugin path=opencode-copilot-auth@0.0.9 loading plugin INFO 2026-01-04T13:42:42 +0ms service=bun code=0 stdout=bun add v1.3.5 (1e86cebd) installed @opencode-ai/plugin@0.0.0-dev-202601041317 [5.00ms] done stderr=Saved lockfile done INFO 2026-01-04T13:42:42 +0ms service=bun cmd=["/Users/matt/.bun/install/global/node_modules/opencode-darwin-arm64/bin/opencode","install"] cwd=/Users/matt/.config/opencode running INFO 2026-01-04T13:42:42 +1ms service=bun code=0 stdout=bun add v1.3.5 (1e86cebd) ``` ### Plugins git-worktree ### OpenCode version 0.0.0-dev-202601041317 ### Steps to reproduce 1. Install/copy over https://github.com/elithrar/dotfiles/blob/main/.config/opencode/plugin/git-worktree.ts 2. Run opencode + ask it to create worktrees 3. Observe what appears to be polluted TUI rendering?
yindo added the opentuibug labels 2026-02-16 17:42:50 -05:00
yindo closed this issue 2026-02-16 17:42:50 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 4, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #6210: [BUG] When using emojis, terminal output changes/shifts during scrolling - relates to terminal output shifting/display corruption
  • #5801: Tokens use percentage show corrupted in TUI - TUI output corruption issue
  • #3567: Help window glitches out when i scroll - TUI rendering glitches during interaction

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 4, 2026): This issue might be a duplicate of existing issues. Please check: - #6210: [BUG] When using emojis, terminal output changes/shifts during scrolling - relates to terminal output shifting/display corruption - #5801: Tokens use percentage show corrupted in TUI - TUI output corruption issue - #3567: Help window glitches out when i scroll - TUI rendering glitches during interaction Feel free to ignore if none of these address your specific case.
Author
Owner

@kommander commented on GitHub (Jan 4, 2026):

When spawning or excuting a command the stdio needs to be captured and handled instead of just inheriting stdio from the parent, which then just writes to stdout, wherever the cursor currently is. You can use console.log then it will land in the dev console, or parse the output and show it in the UI.

@kommander commented on GitHub (Jan 4, 2026): When spawning or excuting a command the stdio needs to be captured and handled instead of just inheriting stdio from the parent, which then just writes to stdout, wherever the cursor currently is. You can use console.log then it will land in the dev console, or parse the output and show it in the UI.
Author
Owner

@rekram1-node commented on GitHub (Jan 4, 2026):

@elithrar if change this to use the oc sdk logger itll go away as a workaround:

function log(sessionID: string, action: string, detail: string): void {
  console.log(`[git-worktree] session=${sessionID} action=${action} ${detail}`)
}

Becomes:

function log(sessionID: string, action: string, detail: string): void {
  ctx.client.app.log({
    body: {
      service: "git-worktree",
      level: "info",
      message: detail
      extra: {
        sessionID,
        action,
      }
    }
  })
}
 

If you prefer u can write to the opencode log files using sdk instead, I suppose we should prolly be capturing this on our end tho and not letting it leak through

@rekram1-node commented on GitHub (Jan 4, 2026): @elithrar if change this to use the oc sdk logger itll go away as a workaround: ``` function log(sessionID: string, action: string, detail: string): void { console.log(`[git-worktree] session=${sessionID} action=${action} ${detail}`) } ``` Becomes: ``` function log(sessionID: string, action: string, detail: string): void { ctx.client.app.log({ body: { service: "git-worktree", level: "info", message: detail extra: { sessionID, action, } } }) } ``` If you prefer u can write to the opencode log files using sdk instead, I suppose we should prolly be capturing this on our end tho and not letting it leak through
Author
Owner

@elithrar commented on GitHub (Jan 4, 2026):

TIL! got it - thanks both.

Added a docs PR here to help: https://github.com/anomalyco/opencode/pull/6833

@elithrar commented on GitHub (Jan 4, 2026): TIL! got it - thanks both. Added a docs PR here to help: https://github.com/anomalyco/opencode/pull/6833
Author
Owner

@elithrar commented on GitHub (Jan 4, 2026):

Working on a more comprehensive change in #6852 b/c ctx.client.app.log isn't available to tools (only plugins)

@elithrar commented on GitHub (Jan 4, 2026): Working on a more comprehensive change in #6852 b/c `ctx.client.app.log` isn't available to tools (only plugins)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4161