fix: prevent DCS passthrough race in tdl causing nvim E349 on startup#5256
Open
peregrinus879 wants to merge 1 commit intobasecamp:devfrom
Open
fix: prevent DCS passthrough race in tdl causing nvim E349 on startup#5256peregrinus879 wants to merge 1 commit intobasecamp:devfrom
peregrinus879 wants to merge 1 commit intobasecamp:devfrom
Conversation
When tdl launches OpenCode (alias c) alongside nvim, OpenCode's TUI
framework sends DCS passthrough terminal capability queries during
initialization (wrapped as \ePtmux;\e...\eST). Because tdl creates the
AI pane last, that pane has focus when send-keys fires. The queries are
forwarded to the terminal emulator via allow-passthrough=on (tmux.conf).
The subsequent select-pane shifts focus to the editor pane before the
terminal's responses arrive. Tmux delivers incoming responses to the
now-focused editor pane, where nvim misinterprets the leaked bytes as
normal-mode commands, triggering E349 ("No identifier under cursor")
as a one-time flash on startup.
This does not occur with Claude Code (alias cx) because Claude Code
does not send DCS passthrough queries during TUI initialization. The
cx alias also includes a printf screen-clear before launching, which
produces only CSI sequences handled internally by tmux and generates
no passthrough traffic.
The fix temporarily disables allow-passthrough on AI panes at creation
time, blocking the DCS queries during the race window. After the focus
transition completes, a background subshell restores passthrough after
1 second, once the AI tool's TUI init is finished. This preserves full
passthrough capability for AI panes during normal use.
Reproduction:
1. tmux with allow-passthrough=on and focus-events=on (default)
2. tdl c (OpenCode in AI pane, nvim in editor pane)
3. E349 flashes in nvim on startup
Confirmed not affected: tdl cx, nvim alone, any tdl without OpenCode.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
peregrinus879
added a commit
to peregrinus879/dotfiles-arch
that referenced
this pull request
Apr 8, 2026
OpenCode's TUI sends DCS passthrough capability queries during init. When tdl switches focus to the editor pane before responses arrive, tmux misroutes them to nvim, triggering E349. Guard AI panes with per-pane allow-passthrough=off during init, restore after 1 second. Claude Code is not affected. Proposed upstream in basecamp/omarchy#5256. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a race condition where OpenCode's DCS passthrough terminal capability queries during TUI initialization are misrouted to the editor pane, causing nvim to display E349 ("No identifier under cursor") on startup.
Changes:
- Disable
allow-passthroughon AI panes immediately after creation to block DCS queries during the race window - Disable
allow-passthroughon secondary AI pane if present - Re-enable
allow-passthroughon AI panes after 1 second via background subshell, once OpenCode's TUI initialization completes
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
When
tdllaunches OpenCode (alias c) alongside nvim, OpenCode's TUI framework sends DCS passthrough terminal capability queries during initialization (wrapped as\ePtmux;\e...\eST). Becausetdlcreates the AI pane last, that pane has focus whensend-keysfires. The queries are forwarded to the terminal emulator viaallow-passthrough=onintmux.conf.The subsequent
select-paneshifts focus to the editor pane before the terminal's responses arrive. Tmux delivers the incoming responses to the now-focused editor pane, where nvim misinterprets the leaked bytes as normal-mode commands, triggering E349 ("No identifier under cursor") as a one-time flash on startup.Why this only affects OpenCode, not Claude Code
alias c/opencode): Its TUI framework sends DCS passthrough terminal capability queries (DECRQM, XTVERSION, Kitty graphics queries, pixel resolution queries, etc.) immediately during startup. These are the sequences that get misrouted.alias cx/claude): Does not send DCS passthrough queries during TUI initialization. Thecxalias also includes aprintfscreen-clear before launching, which produces only CSI sequences handled internally by tmux and generates no passthrough traffic.Fix
Temporarily disable
allow-passthroughon AI panes at creation time using per-panetmux set-option -p, blocking the DCS queries during the race window. After the focus transition completes, a background subshell restores passthrough after 1 second, once the AI tool's TUI init is finished. This preserves full passthrough capability for AI panes during normal use.Reproduction
allow-passthrough=onandfocus-events=on(Omarchy defaults)tdl c(OpenCode in AI pane, nvim in editor pane)Confirmed not affected
tdl cx(Claude Code)nvimalonetdlinvocation without OpenCodeTest plan
tdl crepeatedly; E349 should never appeartdl cx; confirm no regressiontdl c cx(dual AI); confirm no regression🤖 Generated with Claude Code