feat(tmux): focus tmux pane after sending text#298
Open
cyberksh wants to merge 1 commit intofolke:mainfrom
Open
feat(tmux): focus tmux pane after sending text#298cyberksh wants to merge 1 commit intofolke:mainfrom
cyberksh wants to merge 1 commit intofolke:mainfrom
Conversation
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.
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.
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"), sendingtext 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()instate.luaalready handles focus for Neovim terminal windows: it callsterminal:focus()whenopts.focus ~= false. However, when the tool runs in an external tmuxpane (no Neovim terminal),
state.terminalisniland this code path is never reached. Thetmux session backend also had no
focus()method at all —send()pastes text into the panevia
tmux paste-bufferbut never callstmux select-pane.Fix
Two changes:
lua/sidekick/cli/session/tmux.lua— adds afocus()method that runstmux select-pane -t <pane_id>to bring the pane to the foreground.lua/sidekick/cli/state.lua— adds anelseifbranch inM.attach()so that whenthere is no terminal window but the session backend implements
focus(), it is called.The
state.session.focusguard makes this safe for backends that don't implement it(e.g. zellij).