From 12ae5b846987dadd15a71c14e92f48832d2ccc6a Mon Sep 17 00:00:00 2001 From: cyberksh <125770189+cyberksh@users.noreply.github.com> Date: Mon, 13 Apr 2026 17:08:30 +0530 Subject: [PATCH] feat(tmux): focus tmux pane after sending text When using tmux mux mode with create = "split" or "window", sending text to the tool pane now switches focus to it via `tmux select-pane`. Adds M:focus() to the tmux session backend and calls it from State.attach() for external sessions that implement it. --- lua/sidekick/cli/session/tmux.lua | 8 ++++++++ lua/sidekick/cli/state.lua | 2 ++ 2 files changed, 10 insertions(+) diff --git a/lua/sidekick/cli/session/tmux.lua b/lua/sidekick/cli/session/tmux.lua index 942ed7d1..b1c02a4e 100644 --- a/lua/sidekick/cli/session/tmux.lua +++ b/lua/sidekick/cli/session/tmux.lua @@ -186,6 +186,14 @@ function M:submit() Util.exec({ "tmux", "send-keys", "-t", self.tmux_pane_id, "Enter" }) end +---Focus the tmux pane (select it as the active pane) +function M:focus() + local pane_id = self:pane_id() + if pane_id then + Util.exec({ "tmux", "select-pane", "-t", pane_id }) + end +end + function M:dump() local pane_id = self:pane_id() if not pane_id then diff --git a/lua/sidekick/cli/state.lua b/lua/sidekick/cli/state.lua index 01f1f3e3..a11aa02a 100644 --- a/lua/sidekick/cli/state.lua +++ b/lua/sidekick/cli/state.lua @@ -194,6 +194,8 @@ function M.attach(state, opts) terminal:focus() end end + elseif state.session and state.session.focus and opts.focus ~= false then + state.session:focus() elseif attached then Util.info("Attached to `" .. state.tool.name .. "`") end