From 1682b9da258856c5ab0b9c1d9968f6994c0eef91 Mon Sep 17 00:00:00 2001 From: Ethan Callanan Date: Sat, 24 Jan 2026 22:15:46 -0500 Subject: [PATCH 1/5] fix(tmux): add config options to prevent OSC response leak --- lua/opencode/config.lua | 2 ++ lua/opencode/provider/tmux.lua | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lua/opencode/config.lua b/lua/opencode/config.lua index 7f860e4d..66111ac8 100644 --- a/lua/opencode/config.lua +++ b/lua/opencode/config.lua @@ -158,6 +158,8 @@ local defaults = { }, tmux = { options = "-h", -- Open in a horizontal split + focus = false, -- Keep focus in Neovim + disable_passthrough = true, -- Prevent OSC response leak (e.g. "=31337;OK") }, }, } diff --git a/lua/opencode/provider/tmux.lua b/lua/opencode/provider/tmux.lua index 2895c8cf..773adce3 100644 --- a/lua/opencode/provider/tmux.lua +++ b/lua/opencode/provider/tmux.lua @@ -13,6 +13,14 @@ Tmux.name = "tmux" --- ---`tmux` options for creating the pane. ---@field options? string +--- +---Focus the opencode pane when created. Default: `false` +---@field focus? boolean +-- +---Disable `allow-passthrough` on the opencode pane. +-- Prevents leaking escape sequences when allow-passthrough is on in tmux. +---Default: `true` +---@field disable_passthrough? boolean ---@param opts? opencode.provider.tmux.Opts ---@return opencode.provider.Tmux @@ -74,8 +82,14 @@ function Tmux:start() local pane_id = self:get_pane_id() if not pane_id then -- Create new pane - self.pane_id = - vim.fn.system(string.format("tmux split-window -d -P -F '#{pane_id}' %s '%s'", self.opts.options, self.cmd)) + local detach_flag = self.opts.focus and "" or "-d" + self.pane_id = vim.fn.system( + string.format("tmux split-window %s -P -F '#{pane_id}' %s '%s'", detach_flag, self.opts.options or "", self.cmd) + ) + local disable_passthrough = self.opts.disable_passthrough ~= false -- default true + if disable_passthrough and self.pane_id and self.pane_id ~= "" then + vim.fn.system(string.format("tmux set-option -t %s -p allow-passthrough off", vim.trim(self.pane_id))) + end end end From b7de27bba2f216e05f2ffe6f7cbfc2ccb474c29e Mon Sep 17 00:00:00 2001 From: Ethan Callanan Date: Wed, 28 Jan 2026 10:10:22 -0500 Subject: [PATCH 2/5] disable_passthrough -> allow_passthrough & more documentation --- lua/opencode/config.lua | 4 +++- lua/opencode/provider/tmux.lua | 16 +++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lua/opencode/config.lua b/lua/opencode/config.lua index 66111ac8..240b3328 100644 --- a/lua/opencode/config.lua +++ b/lua/opencode/config.lua @@ -159,7 +159,9 @@ local defaults = { tmux = { options = "-h", -- Open in a horizontal split focus = false, -- Keep focus in Neovim - disable_passthrough = true, -- Prevent OSC response leak (e.g. "=31337;OK") + -- Disables allow-passthrough in the tmux split + -- preventing OSC escape sequences from leaking into the nvim buffer + allow_passthrough = false, }, }, } diff --git a/lua/opencode/provider/tmux.lua b/lua/opencode/provider/tmux.lua index 773adce3..fec1406f 100644 --- a/lua/opencode/provider/tmux.lua +++ b/lua/opencode/provider/tmux.lua @@ -17,10 +17,16 @@ Tmux.name = "tmux" ---Focus the opencode pane when created. Default: `false` ---@field focus? boolean -- ----Disable `allow-passthrough` on the opencode pane. --- Prevents leaking escape sequences when allow-passthrough is on in tmux. ----Default: `true` ----@field disable_passthrough? boolean +---Allow `allow-passthrough` on the opencode pane. +-- When enabled, opencode will NOT disable the tmux `allow-passthrough` option on its pane. +-- This allows opencode to use OSC escape sequences, but may leak escape codes to the terminal +-- (e.g., "=31337;OK" appearing in your terminal output). +-- +-- If you enable this, consider also enabling `focus` to auto-focus the pane on creation, +-- which can help avoid OSC code leakage while opencode is sending escape sequences on startup. +-- +-- Default: `false` (allow-passthrough is disabled to prevent OSC code leakage) +---@field allow_passthrough? boolean ---@param opts? opencode.provider.tmux.Opts ---@return opencode.provider.Tmux @@ -86,7 +92,7 @@ function Tmux:start() self.pane_id = vim.fn.system( string.format("tmux split-window %s -P -F '#{pane_id}' %s '%s'", detach_flag, self.opts.options or "", self.cmd) ) - local disable_passthrough = self.opts.disable_passthrough ~= false -- default true + local disable_passthrough = self.opts.allow_passthrough ~= true -- default true (disable passthrough) if disable_passthrough and self.pane_id and self.pane_id ~= "" then vim.fn.system(string.format("tmux set-option -t %s -p allow-passthrough off", vim.trim(self.pane_id))) end From d5fa2fffeab2458ca00d2aa9617455adf18c8e96 Mon Sep 17 00:00:00 2001 From: Ethan Callanan Date: Wed, 28 Jan 2026 10:13:44 -0500 Subject: [PATCH 3/5] Update documentation --- lua/opencode/provider/tmux.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lua/opencode/provider/tmux.lua b/lua/opencode/provider/tmux.lua index fec1406f..49534763 100644 --- a/lua/opencode/provider/tmux.lua +++ b/lua/opencode/provider/tmux.lua @@ -18,10 +18,15 @@ Tmux.name = "tmux" ---@field focus? boolean -- ---Allow `allow-passthrough` on the opencode pane. --- When enabled, opencode will NOT disable the tmux `allow-passthrough` option on its pane. +-- When enabled, opencode.nvim will use your configured tmux `allow-passthrough` option on its pane. -- This allows opencode to use OSC escape sequences, but may leak escape codes to the terminal -- (e.g., "=31337;OK" appearing in your terminal output). -- +-- Limitations of having allow-passthrough disabled in the opencode pane: +-- - can't display images +-- - can't use special (terminal specific; non-system) clipboards +-- - may have issues setting window properties like the title from the pane +-- -- If you enable this, consider also enabling `focus` to auto-focus the pane on creation, -- which can help avoid OSC code leakage while opencode is sending escape sequences on startup. -- From eae4bc0108d4c0171a5fab68a37fca761a000bec Mon Sep 17 00:00:00 2001 From: Ethan Callanan Date: Wed, 28 Jan 2026 10:14:53 -0500 Subject: [PATCH 4/5] Formatting --- lua/opencode/config.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/opencode/config.lua b/lua/opencode/config.lua index 240b3328..711eec0c 100644 --- a/lua/opencode/config.lua +++ b/lua/opencode/config.lua @@ -159,7 +159,7 @@ local defaults = { tmux = { options = "-h", -- Open in a horizontal split focus = false, -- Keep focus in Neovim - -- Disables allow-passthrough in the tmux split + -- Disables allow-passthrough in the tmux split -- preventing OSC escape sequences from leaking into the nvim buffer allow_passthrough = false, }, From 76f4a39297dfc4b8d43cb82ec00bbe7b997d2e72 Mon Sep 17 00:00:00 2001 From: Ethan Callanan Date: Wed, 28 Jan 2026 10:17:31 -0500 Subject: [PATCH 5/5] Fix wording --- lua/opencode/provider/tmux.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/opencode/provider/tmux.lua b/lua/opencode/provider/tmux.lua index 49534763..2f364fe9 100644 --- a/lua/opencode/provider/tmux.lua +++ b/lua/opencode/provider/tmux.lua @@ -19,8 +19,8 @@ Tmux.name = "tmux" -- ---Allow `allow-passthrough` on the opencode pane. -- When enabled, opencode.nvim will use your configured tmux `allow-passthrough` option on its pane. --- This allows opencode to use OSC escape sequences, but may leak escape codes to the terminal --- (e.g., "=31337;OK" appearing in your terminal output). +-- This allows opencode to use OSC escape sequences, but may leak escape codes to the buffer +-- (e.g., "=31337;OK" appearing in your buffer). -- -- Limitations of having allow-passthrough disabled in the opencode pane: -- - can't display images