@@ -13,6 +13,25 @@ Tmux.name = "tmux"
1313---
1414--- `tmux` options for creating the pane.
1515--- @field options ? string
16+ ---
17+ --- Focus the opencode pane when created. Default: `false`
18+ --- @field focus ? boolean
19+ --
20+ --- Allow `allow-passthrough` on the opencode pane.
21+ -- When enabled, opencode.nvim will use your configured tmux `allow-passthrough` option on its pane.
22+ -- This allows opencode to use OSC escape sequences, but may leak escape codes to the buffer
23+ -- (e.g., "=31337;OK" appearing in your buffer).
24+ --
25+ -- Limitations of having allow-passthrough disabled in the opencode pane:
26+ -- - can't display images
27+ -- - can't use special (terminal specific; non-system) clipboards
28+ -- - may have issues setting window properties like the title from the pane
29+ --
30+ -- If you enable this, consider also enabling `focus` to auto-focus the pane on creation,
31+ -- which can help avoid OSC code leakage while opencode is sending escape sequences on startup.
32+ --
33+ -- Default: `false` (allow-passthrough is disabled to prevent OSC code leakage)
34+ --- @field allow_passthrough ? boolean
1635
1736--- @param opts ? opencode.provider.tmux.Opts
1837--- @return opencode.provider.Tmux
@@ -74,8 +93,14 @@ function Tmux:start()
7493 local pane_id = self :get_pane_id ()
7594 if not pane_id then
7695 -- Create new pane
77- self .pane_id =
78- vim .fn .system (string.format (" tmux split-window -d -P -F '#{pane_id}' %s '%s'" , self .opts .options , self .cmd ))
96+ local detach_flag = self .opts .focus and " " or " -d"
97+ self .pane_id = vim .fn .system (
98+ string.format (" tmux split-window %s -P -F '#{pane_id}' %s '%s'" , detach_flag , self .opts .options or " " , self .cmd )
99+ )
100+ local disable_passthrough = self .opts .allow_passthrough ~= true -- default true (disable passthrough)
101+ if disable_passthrough and self .pane_id and self .pane_id ~= " " then
102+ vim .fn .system (string.format (" tmux set-option -t %s -p allow-passthrough off" , vim .trim (self .pane_id )))
103+ end
79104 end
80105end
81106
0 commit comments