Skip to content

feat(tmux): focus tmux pane after sending text#298

Open
cyberksh wants to merge 1 commit intofolke:mainfrom
cyberksh:feat/tmux-focus-pane-on-send
Open

feat(tmux): focus tmux pane after sending text#298
cyberksh wants to merge 1 commit intofolke:mainfrom
cyberksh:feat/tmux-focus-pane-on-send

Conversation

@cyberksh
Copy link
Copy Markdown

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.

Description

When using sidekick with a tmux mux backend (mux.create = "split" or "window"), sending
text to the tool pane does not switch focus to it. The pane receives the input correctly but
stays in the background — the user has to manually click or key-switch to it.

Root cause

State.attach() in state.lua already handles focus for Neovim terminal windows: it calls
terminal:focus() when opts.focus ~= false. However, when the tool runs in an external tmux
pane (no Neovim terminal), state.terminal is nil and this code path is never reached. The
tmux session backend also had no focus() method at all — send() pastes text into the pane
via tmux paste-buffer but never calls tmux select-pane.

Fix

Two changes:

  1. lua/sidekick/cli/session/tmux.lua — adds a focus() method that runs
    tmux select-pane -t <pane_id> to bring the pane to the foreground.

  2. lua/sidekick/cli/state.lua — adds an elseif branch in M.attach() so that when
    there is no terminal window but the session backend implements focus(), it is called.
    The state.session.focus guard makes this safe for backends that don't implement it
    (e.g. zellij).

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.
@github-actions github-actions Bot added the size/m Medium PR (<50 lines changed) label Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m Medium PR (<50 lines changed)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant