fix(cli): apply focus to tmux pane for external sessions#307
Draft
sei40kr wants to merge 1 commit intofolke:mainfrom
Draft
fix(cli): apply focus to tmux pane for external sessions#307sei40kr wants to merge 1 commit intofolke:mainfrom
sei40kr wants to merge 1 commit intofolke:mainfrom
Conversation
aff101b to
ef2ada6
Compare
Adds `Session:focus()` backend hook with a tmux implementation via `tmux select-pane`, and unifies the UI layer to dispatch through `state.session:focus()`. `Terminal` is already a `Session` backend so `state.terminal === state.session` for terminal-backed sessions — the same call covers both paths. Also fixes the default-focus asymmetry in `M.attach`: external focus now fires on `opts.show and opts.focus ~= false` to match terminal, so `send()` and `toggle()` (no args) focus external panes the same way they focus terminals. Closes folke#179. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Description
cli.toggle({ focus = true })andcli.focus()did not focus the tmux pane when using external mux sessions (cli.mux.enabled = truewithcreate = "split"/"window").Root cause
sidekick.cliwas built aroundstate.terminal(nvim's embedded terminal). When external mux sessions were added, the UI layer (M.toggle/M.focus) still keyed offstate.terminal, andSessionhad nofocus()method — so there was literally no path from the UI totmux select-pane. Terminal focus kept working only becausenvim_set_current_winis a synchronous API the UI callback could call directly via a capturedopts.focus, bypassing the missing propagation.Changes
Session:focus()hook on the backend base class (empty stub for backends that don't support it)focus()on the tmux backend viatmux select-window+tmux select-pane—select-windowfirst socreate = "window"actually switches the client to the pane's window (a no-op forcreate = "split"where the pane already lives in the current window)state.session:focus().Terminalis already registered as aSessionbackend (state.terminal === state.sessionfor terminal-backed sessions), so the same call works for both paths:Terminal:focus()(existing:show()+nvim_set_current_win)Tmux:focus()(new:tmux select-window+tmux select-pane)M.attachnow fires focus onopts.show and opts.focus ~= falsefor both backends, fixing the silent default-false asymmetry external previously had against terminalM.togglecallback handles both backends viastate.session:focus(), keeping the existingis_open()gate so toggling terminal visibility off doesn't immediately re-open itM.focuscallback routes tostate.terminal:blur()when terminal is focused (existing behavior), otherwisestate.session:focus()for both backendsBehavior matrix after the fix
toggle()toggle({ focus = true })toggle({ focus = false })send("x")send("x", { focus = false })focus()hide()close()Related Issue(s)
focusis not appplied with tmux pane #179Screenshots
N/A — behavioral fix with no UI change.
🤖 Generated with Claude Code