feat: anchor launch decisions on the invocation context pane - #151
Open
diegopzz wants to merge 1 commit into
Open
feat: anchor launch decisions on the invocation context pane#151diegopzz wants to merge 1 commit into
diegopzz wants to merge 1 commit into
Conversation
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
force-pushed
the
context-target-pane
branch
from
August 16, 2026 17:21
ab869f9 to
a7d0ccd
Compare
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.
Makes the launchers honor the invocation context, so a programmatic invocation —
plugin.action.invokewith an explicitfocused_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'sremote-invokefillfocused_pane_iddeliberately, 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: invokingopen-file-viewerthrough 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 thepane list, that pane becomes the anchor for the whole decision (both variants). Absent, unparseable, or naming a dead pane → focused-pane behavior, unchanged.OPENcan 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; bareOPENstays the local default, so existing keybinding behavior is byte-identical.CLOSEd (a repeat programmatic invocation means toggle — there is no meaningful "focused" state to flip to remotely).HERDR_PLUGIN_CONTEXT_JSONitself (main.rs), keeping the scripts free of JSON parsing and the ids inside the tested/validated path, per the existing option-injection guard design."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, andcargo clippy --all-targets -- -D warningsall 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.