Skip to content

Fix Ctrl+hjkl navigation for herdr 0.7.0#2

Open
vlcinsky wants to merge 4 commits into
devxplay:mainfrom
vlcinsky:fix/ctrl-hjkl-navigation-herdr-0.7.0
Open

Fix Ctrl+hjkl navigation for herdr 0.7.0#2
vlcinsky wants to merge 4 commits into
devxplay:mainfrom
vlcinsky:fix/ctrl-hjkl-navigation-herdr-0.7.0

Conversation

@vlcinsky

@vlcinsky vlcinsky commented Jun 21, 2026

Copy link
Copy Markdown

Summary

Fixes Ctrl+hjkl navigation for herdr 0.7.0, addressing the incompatibilities described in issue #1.

Problems Fixed

1. Pane ID format incompatibility

  • Problem: Code was generating IDs as {workspace_id}-{index+1} (e.g., w3-1), but herdr 0.7.0 uses {workspace_id}:p{number} format (e.g., w3:p3)
  • Solution: Use public_pane_numbers from session.json to generate correct public pane IDs in the new format

2. Focus API changed in 0.7.0

  • Problem: Agent-based focus shim (report_agentagent.focusrelease_agent) no longer moves focus in herdr 0.7.0
  • Solution: Use new pane.focus_direction RPC API added in herdr 0.7.0
  • Backward compatibility: Falls back to computed approach if the new API is unavailable (for older herdr versions)

3. Key forwarding method changed in 0.7.0

  • Problem: Using pane.send_text with raw control bytes caused keyboard protocol re-encoding issues
  • Solution: Switch to pane.send_keys with key-combo strings ("ctrl+h", etc.) introduced in herdr 0.7.0 PR #613
  • Benefit: Avoids keyboard protocol re-encoding issues and uses the proper API

4. Environment variable fallback

  • Problem: Plugin relies on HERDR_ACTIVE_PANE_ID environment variable which herdr doesn't inject automatically in all cases
  • Solution: Query herdr pane current API as fallback when environment variables are not set
  • Benefit: More robust pane detection

5. LazyVim/distro keybinding conflicts

  • Problem: LazyVim and similar distributions override Ctrl+{hjkl} keymaps after plugin setup
  • Solution: Document the issue and provide a working configuration in README
  • Benefit: Users can easily configure the plugin to work with LazyVim and similar distributions

Changes

Rust Binary (src/main.rs)

  • pane_public_mapping(): Now uses public_pane_numbers to build correct {workspace}:p{n} IDs
  • focus_pane_direction(): New function using pane.focus_direction API (herdr 0.7.0+)
  • focus_adjacent(): Tries new API first, falls back to computed approach for compatibility
  • send_ctrl_to_pane(): Switched from pane.send_text with raw bytes to pane.send_keys with key-combo strings

Lua Plugin (lua/herdr/navigator.lua)

  • pane_id(): Added fallback to query herdr pane current API when env vars are missing

Documentation (README.md)

  • Added LazyVim/distro compatibility section with working configuration
  • Documented the keybinding conflict and solution

Testing

Tested locally with herdr 0.7.0 on macOS:

Binary navigation:

  • herdr-navigator focus left/right/up/down - exit code 0
  • herdr-navigator dispatch - correctly detects Neovim panes and forwards keys

Full integration:

  • ✅ Ctrl+{hjkl} navigates within Neovim splits
  • ✅ Ctrl+{hjkl} jumps from Neovim to adjacent herdr panes when at edge
  • ✅ Ctrl+{hjkl} navigates between non-Neovim herdr panes
  • ✅ Works with LazyVim using documented configuration

Compatibility

  • ✅ Backward compatible with older herdr versions (falls back to old APIs)
  • ✅ Forward compatible with herdr 0.7.0+ (uses new APIs when available)
  • ✅ Works with LazyVim, NvChad, and other Neovim distributions (with documented config)

Closes #1

vlcinsky added 4 commits June 21, 2026 22:45
- Fix pane ID format: use public_pane_numbers to generate correct IDs (wB:p3 format)
  instead of deprecated wB-1 format
- Add focus_pane_direction() using new pane.focus_direction API (herdr 0.7.0+)
- Update focus_adjacent() to try new API first, fall back to computed approach
  for backward compatibility with older herdr versions

Fixes devxplay#1
When HERDR_ACTIVE_PANE_ID or HERDR_PANE_ID are not set in the
environment, query herdr's pane.current API to get the current pane ID
instead of returning nil. This ensures pane registration works even
when herdr doesn't inject the environment variables.
Herdr 0.7.0 (#613) added support for key-combo strings like 'ctrl+h'
in pane.send_keys. Switch from pane.send_text with raw control bytes
to pane.send_keys with key-combo strings for better compatibility and
to avoid keyboard protocol re-encoding issues.
Document the keybinding conflict with LazyVim and similar distributions
that set Ctrl+h/j/k/l after plugin setup. Provide a working configuration
that ensures herdr.nvim keymaps take precedence by setting them after
VimEnter with a delay.
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.

Ctrl+hjkl navigation broken on herdr 0.7.0 (pane-id format + focus API changes)

1 participant