anomalyco / anomalyco/opencode

TUI silently drops pasted input during startup capability queries (tmux)

Open
#42,915 0 comments 1 reaction 1 assignee View on GitHub

@simonklee is already working on this.

Since Aug 16, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Describe the bug

Pasting text into the TUI prompt input is silently dropped if the paste arrives while the TUI is still running its startup terminal-capability queries (OSC 4/10/11 palette, XTVERSION, XTGETTCAP, DECRPM, CPR). The paste never appears in the input box, with no error or notification. This makes "paste right after starting opencode" (e.g. an API key, an initial prompt) fail reliably in tmux.

Reproduction (deterministic)

Environment: opencode 1.18.18, Linux VPS over SSH, tmux 3.4, TERM=xterm-256color.

  1. Start a tmux session and launch opencode in a pane.
  2. Within the first ~10 seconds (while the pane is still doing capability queries), run:
    tmux set-buffer "hello" && tmux paste-buffer -p
    
  3. Observe: the text never appears in the input box.

Timing matrix measured with fresh sessions (paste-buffer -p then tmux capture-pane):

paste at result
t=3s dropped
t=5s dropped
t=7s dropped
t=9s dropped
t=10s dropped
t=12s pasted
t=14s pasted

Bracketed paste sent from the "outer" terminal through tmux in steady state works fine; only the startup window drops input.

Root cause (from the bundled source in 1.18.18)

During startup the terminal query session (packages/tui SZ class, detectOSCSupport/queryPalette/querySpecialColors + waitForXtVersion) subscribes to stdin data and consumes everything that arrives while queries are pending:

subscribeInput($) {
  if (this.oscSource) return this.oscSource.subscribeOsc((Z) => { $(Z) })
  return this.stdin.on("data", $), () => { ... }
}

Any bytes that are not OSC replies (i.e. ordinary typed/pasted input) are read by the query listener and discarded. In tmux, which does not answer the OSC color queries, this window lasts ~10-11s. On a real terminal over SSH it is shorter but still nonzero, and any paste in that window is lost silently.

Expected behavior

Input arriving during startup should be buffered and applied once the TUI is ready (or at least not silently eaten) - the same way the app buffers its own output until the renderer attaches.

OpenCode version

1.18.18 (also affects earlier versions - the query-session stdin subscription predates it)

Environment

  • OS: Linux (Ubuntu 24.04) VPS, accessed over SSH
  • Terminal: tmux 3.4 inside xterm-256color
  • Multiplexer: tmux 3.4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.