Skip to content

feat: anchor launch decisions on the invocation context pane - #151

Open
diegopzz wants to merge 1 commit into
smarzban:mainfrom
diegopzz:context-target-pane
Open

feat: anchor launch decisions on the invocation context pane#151
diegopzz wants to merge 1 commit into
smarzban:mainfrom
diegopzz:context-target-pane

Conversation

@diegopzz

Copy link
Copy Markdown

Makes the launchers honor the invocation context, so a programmatic invocation — plugin.action.invoke with an explicit focused_pane_id, e.g. a mirroring tool driving this host's viewer from another machine — opens the viewer beside the pane the caller named, instead of wherever the host's UI focus happens to sit.

The problem

Both launch decisions anchor on the focused pane. That's right for a keybinding — the user is where the focus is. But when the action arrives with a context (herdr hands it to the action as HERDR_PLUGIN_CONTEXT_JSON, and callers like herdr-mirror's remote-invoke fill focused_pane_id deliberately, translated to this host's ids), the UI focus is unrelated: on a headless or remotely-driven host the viewer pops up in some arbitrary workspace, invisible to the caller. Concretely: invoking open-file-viewer through a mirror opened the viewer in whatever tab the host last had focused; with this change it opens beside the mirrored pane the caller invoked from — which then streams back to the mirroring side, making remote file browsing work end to end.

What changes

  • context_pane(): if the invocation context names a pane that exists in the pane list, that pane becomes the anchor for the whole decision (both variants). Absent, unparseable, or naming a dead pane → focused-pane behavior, unchanged.
  • OPEN can now carry a target: OPEN <pane_id> (split variant → --target-pane), OPEN <workspace_id> (tab variant → --workspace). Only emitted under a context anchor, only after the same flag-safety validation as every other emitted id; bare OPEN stays the local default, so existing keybinding behavior is byte-identical.
  • Under a context anchor, a Files pane already in the anchor's tab is CLOSEd (a repeat programmatic invocation means toggle — there is no meaningful "focused" state to flip to remotely).
  • The binary reads HERDR_PLUGIN_CONTEXT_JSON itself (main.rs), keeping the scripts free of JSON parsing and the ids inside the tested/validated path, per the existing option-injection guard design.
  • Scripts: one new "OPEN "* case each, passing the validated target through.

Tests

Six new cases in launch.rs (context anchors OPEN with a target, repeat-toggle, dead-pane fallback, tab-variant workspace targeting, SWITCHTAB within the context workspace, garbage context changes nothing). cargo test (522), cargo fmt --check, and cargo clippy --all-targets -- -D warnings all green.

Verified live against herdr 0.8.0: a context naming a non-focused workspace's pane opens the viewer beside that pane; the same invocation again toggles it closed; and invoked on a mirrored host, the viewer pane streams back to the mirroring side and is fully drivable from there.

@diegopzz
diegopzz requested a review from smarzban as a code owner August 16, 2026 17:20
A programmatic invocation (plugin.action.invoke with an explicit
focused_pane_id — e.g. a mirroring tool driving this host's viewer
from another machine) should open the viewer beside the pane the
caller named, not wherever the host's UI focus happens to sit. When
the context names a live pane it now anchors the whole decision, OPEN
carries the validated target (--target-pane / --workspace), and a
repeat invocation toggles the viewer closed. No context, dead pane, or
garbage JSON leaves the focused-pane behavior byte-identical.
@diegopzz
diegopzz force-pushed the context-target-pane branch from ab869f9 to a7d0ccd Compare August 16, 2026 17:21
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.

1 participant