Skip to content

Target the invoking pane instead of --current - #8

Open
cunderw wants to merge 1 commit into
paulbkim-dev:mainfrom
cunderw:fix/target-invoking-pane
Open

Target the invoking pane instead of --current#8
cunderw wants to merge 1 commit into
paulbkim-dev:mainfrom
cunderw:fix/target-invoking-pane

Conversation

@cunderw

@cunderw cunderw commented Jul 30, 2026

Copy link
Copy Markdown

Fixes #7.

--current resolves to the herdr server's globally focused pane, not the pane the plugin action was invoked from. The script already knows its own pane via $HERDR_PANE_ID — it uses it for send-keys — so this just uses it for the other two calls as well.

Changes

site before after
navigate.sh:41 pane process-info --current pane process-info --pane "$pane"
navigate.sh:53 pane focus … --current pane focus … --pane "$pane"
editor/nvim.lua:26 "--current" "--pane", vim.env.HERDR_PANE_ID

--current is kept as a fallback in navigate.sh for invocation outside a pane, where $HERDR_PANE_ID is unset and --pane "" would be invalid. The nvim.lua change needs no guard because that branch only runs when HERDR_PANE_ID is non-empty.

Verification

Invoking the script from a pane that is not the focused one, before and after:

tp=$(herdr workspace create --cwd /tmp --label t --no-focus | jq -r '.result.root_pane.pane_id')
HERDR_PANE_ID="$tp" ./navigate.sh left
source_pane_id
before w7:p2 — the globally focused pane
after wA:p1 — the invoking pane

The detection change at line 41 is the more consequential of the two: a wrong answer there means keys get forwarded into a pane that isn't running Vim, or focus moves when the key should have been forwarded.

Running this patch locally on herdr 0.7.5 / Neovim 0.12.0-dev / macOS arm64; both navigation directions behave correctly.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QP5QBZ1kpDBmajU1u7cef7

`--current` resolves to the herdr server's globally focused pane, not the
pane the plugin action was invoked from. The script already knows its own
pane via $HERDR_PANE_ID and uses it for send-keys, so the information was
already available at both call sites.

Two consequences when focus and caller diverge:

- navigate.sh:41 tested whether the *focused* pane was running Vim and then
  acted on $HERDR_PANE_ID, so it could forward a key into a pane not running
  Vim, or move focus when it should have forwarded.
- navigate.sh:53 and editor/nvim.lua:26 moved focus relative to the wrong
  source pane.

--current is kept as a fallback in navigate.sh for invocation outside a pane,
where $HERDR_PANE_ID is unset and `--pane ""` would be invalid. The nvim.lua
change needs no guard because that branch only runs when HERDR_PANE_ID is
non-empty.

Refs paulbkim-dev#7

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QP5QBZ1kpDBmajU1u7cef7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--current resolves to the globally focused pane, not the invoking pane

1 participant