Skip to content

feat: show plugin actions in pane, tab, and workspace menus - #1450

Open
joshka0 wants to merge 7 commits into
sheprd-labs:mainfrom
joshka0:feat/plugin-actions-in-menus
Open

joshka0 wants to merge 7 commits into
sheprd-labs:mainfrom
joshka0:feat/plugin-actions-in-menus

Conversation

@joshka0

@joshka0 joshka0 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Closes #534.

What it does

Herdr plugins declare where their actions apply (contexts = ["pane"], ["tab"], ["workspace"], ["selection"]). Sheprd now lists those actions in its right-click menus, under one heading per plugin, below the built-in rows:

  • Pane menu, and an agent row's menu, which is the same menu: pane actions. When the pane has highlighted text, selection actions too.
  • Tab menu: tab actions.
  • Workspace popover: workspace actions.

An action runs on the pane, tab or workspace the menu was opened on, not on the focused pane. Arrow keys and Enter walk across built-in and plugin rows. A long title ends with an ellipsis, and a tooltip shows the full title and the action's description.

How it reaches Herdr

  • Herdr 0.9.5 does not accept plugin.action.list or plugin.action.invoke on a client-shell connection (src/api/schema.rs:142-143).
  • The herdr plugin action invoke CLI fixes the context to cli, so it cannot target a pane.
  • So each request runs Herdr's own herdr remote-api-bridge on the endpoint's host, through the host scripts that pane moves already use. This works locally and over SSH.
  • The list is read again on a background worker each time a menu opens, and the menu shows the host's last list at once. A failed read never affects the built-in rows.
  • Disabled plugins, actions for another platform, and actions without contexts are left out.

When a caller leaves a context field out, Herdr fills it from its focused pane. So the context is built from session.snapshot just before the action runs: the target's ids, labels, worktree, cwd, agent and status. I asked Herdr to accept the two methods from clients, and to derive the context from the pane id the caller passes: herdrdev/herdr#5552 (comment). If Herdr makes both changes, the bridge can go.

Limits

  • Herdr 2 (herdr-core) has no plugin API, so its menus and kept workspaces show no plugin rows.
  • --socket and --dev windows, and Windows clients, show no plugin rows, because no host script reaches them.
  • When the target pane has no cwd or no agent, Herdr still fills that one field from its focused pane. Only a Herdr change can fix this.

QA checklist

  • cargo test --locked -p sheprd-gpui --lib -- plugin pane_menu tab_menu: 127 passed. This includes 35 new tests, written from a failure list by a separate author. They use a stand-in herdr behind the real host scripts.
  • Mutation check: 13 code mutations were tried, and the tests caught 11. The other 2 changed nothing, and that redundant code is removed in b989ee6d.
  • cargo fmt --all -- --check, cargo clippy --locked -p sheprd-gpui --all-targets -- -D warnings, scripts/check-file-size.sh, scripts/check-sorted.py, scripts/check-i18n.py: pass on macOS.
  • Native check on macOS, dev build against Herdr 0.9.5: right-clicking a pane that is not focused shows a plugin's pane actions under the plugin's name, and running one acts on that pane.
  • CI: all checks pass on 722c0edf, including Windows. The first push failed the Windows lints because a test-only stand-in was unused there, and 722c0edf fixes that.
  • Reviewer: right-click a tab and a workspace with a plugin that declares tab or workspace actions, and run one.
  • Reviewer: highlight text in the focused pane, right-click it, and run a selection action.
  • Reviewer: check the plugin section on an SSH host.

Screenshots

Not attached yet: the native check above was done by hand, and no capture was taken. I will add before and after images of the pane menu.

Herdr plugins declare actions with contexts (pane, tab, workspace,
selection). The pane menu (and an agent row's menu, which is the pane
menu), the tab menu, and the workspace popover now list the actions of
their context below their own rows, grouped under each plugin's name,
and run one on the pane, tab, or workspace the menu was opened on. A pane
with highlighted text also lists the actions that take a selection.

Herdr does not admit plugin.action.list or plugin.action.invoke on a GUI
client's connection, and the `herdr plugin action` CLI cannot carry an
invocation context. So each request runs Herdr's own
`herdr remote-api-bridge` on the endpoint's host, locally or over SSH,
through the host scripts pane moves already use, with the request on
stdin.

Herdr fills every context field a caller omits from its focused pane,
and a right-clicked pane is often not focused. So an action's context is
built from Herdr's session.snapshot taken just before it runs: the
target's ids, labels, worktree, cwd, agent, and status, and for a tab or
workspace the pane focused in it, as Herdr derives them itself.

Opening a menu shows the host's last list at once and reads it again on a
background worker; a failed read never affects the menu's own rows. The
list leaves out disabled plugins, actions for another platform, and
actions without contexts. Long titles end with an ellipsis; a tooltip
holds the whole title and the action's description. The pane and tab
menu rows are now the panel's own children, so a row the keyboard
selects below the window's edge scrolls into view.

Herdr 2 (herdr-core) has no plugins, so its menus and kept workspaces
show none. A window built without the host bridge, as headless tests
build theirs, reaches no host.

Refs sheprd-labs#534
Regression tests for the plugin action rows, written from the feature's
failure list by an author who did not write the feature.

A stand-in host (`plugin_actions::tests::fake`) replaces the bridge's
`fetch` and `invoke`, so the menus run against canned catalogs and record
each action they run. A stand-in `herdr` and `uname` in a private home
drive the real host scripts for the list and invoke paths.

- Catalog: contexts per menu, unknown contexts and platforms, disabled and
  removed plugins, platform filter by `uname`, grouping and headings,
  one-line titles, blank descriptions.
- Context: pane, tab, and workspace targets take every field from the
  target, never Herdr's focused pane; absent values are left out; a gone or
  inconsistent target is refused.
- Bridge: list order and failures, the output bound, data only on stdin,
  `--session` binding, no invoke for a gone target.
- Menus: rows run on the right-clicked pane, tab, or workspace; cached rows
  show at once and survive failed reads; one read at a time; keys and hover
  across built-in and plugin rows; late answers; stale targets; failure
  flashes; selection only for the highlighted pane, fenced at run time;
  scrolling past headings; long titles.
- Errors: every variant localizes, also through the app's root error.

The only non-test change is the `#[cfg(test)]` module declaration in
`plugin_actions.rs`.
serde already reads a JSON null into None for the worktree and agent
status, and Catalog::rows never lists an action without contexts.
@joshka0
joshka0 requested a review from penso as a code owner November 19, 2026 16:51
@netlify

netlify Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

👷 Deploy request for sheprd-labs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 057446e

@greptile-apps

greptile-apps Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The latest test-only changes appear safe to merge; the two earlier menu issues remain non-blocking.

Findings

  1. P2 Menus retain another session’s actions. ▶
  2. P2 Keyboard selection leaves view. ▶

Summary

Adds plugin actions below the built-in pane, tab, and workspace menu rows.

  • Plugin actions run with context from the menu's chosen target.
  • Pane menus show plugin actions for the pane and its highlighted text.
  • Tab menus show plugin actions for the tab they were opened on.
  • Workspace popovers show plugin actions for the chosen workspace.

No new issues were found in the changes since the previous review.

Reviews (2) · Last reviewed commit: "test: build the plugin menus' stand-in h..." · Reviewed by Greptile

Comment on lines +102 to +108
let id = endpoint.id.clone();
let entry = self
.plugin_actions
.by_endpoint
.entry(id.clone())
.or_default();
if entry.fetching {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Menus retain another session’s actions. The cache uses only the endpoint ID, but choosing another local or device session keeps that ID. A menu can therefore show the previous session’s actions. An old request that finishes after the switch can also replace the new session’s list and prevent its opening from starting a fresh read. Actions missing from the current session then fail when clicked.

Key both cached lists and pending reads by the host’s identity, including its session, and ignore answers from an earlier target.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 1e17be5: the cache is now keyed by the host identity (route, session, installation), so each session keeps its own actions. A late answer for the session left no longer touches the open menu, and a read in flight for one session no longer blocks another. Tests in plugin_actions/tests/sessions.rs.

Comment on lines +538 to +540
self.render_plugin_rows(
&target.plugins,
selected,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Keyboard selection leaves view. Workspace plugin rows can make the popover taller than the window. Arrow keys update workspace_selected, but never scroll the selected row into view. Users can move onto an unseen action and press Enter without seeing what will run. The new pane and tab rows already scroll their selection into view; add the same behavior for workspace rows and cover a long list in a short window.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 057446e: the popover now draws its sections as the menu panel's own children with a tracked scroll handle, so arrow keys scroll the selected action, plugin row, or pull request card into view. menu/workspace_tests/plugins_scroll.rs covers a long list in a 320px window, both directions, across plugin headings.

Windows lints failed on the unused stand-in host: every menu test that
uses it needs host scripts, so it is gated the same way. The catalog
helper the pure tests share moves out of it.
@penso

penso commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator

@greptileai review

…n-menus

# Conflicts:
#	crates/sheprd-gpui/src/menu/workspace.rs
#	crates/sheprd-gpui/src/menu/workspace/popover.rs
#	crates/sheprd-gpui/src/pane_menu.rs
#	crates/sheprd-gpui/src/tab_menu/tests.rs
An endpoint keeps its id when the user picks another session behind it,
so a cache of plugin actions keyed by endpoint id showed one session's
actions in another session's menus, let a late answer for the session
left replace the new one's, and let a read in flight for one session stop
the other's. Key the cache by the host's identity (route, session,
installation) instead, and update an open menu only when the answer is
for the session it is on.

Tests: a menu lists its session's actions and keeps each session's cache;
a late answer for the session left does not change the open menu; a read
in flight for another session does not stop this one's; a row runs on the
host of the menu's session. The pane menu's key-walk test clears agents,
as the Favorite row that main added to agent panes evened out the row
counts it compares.
With plugin actions the workspace popover can be taller than the window,
and arrow keys could select an action below its edge. The popover now
draws its sections as the menu panel's own children, with a tracked scroll
handle, so the selected action, plugin row, or pull request card scrolls
into view, as in the pane and tab menus.

The pages that draw into the panel itself (group, move pane, move tab,
pane, tab) go through one lookup in menu/chrome/panel_pages.rs, which
keeps menu/chrome.rs within the 1,000-line limit after the merge of main.

Tests: in a short window, arrow keys keep every selected action inside
the panel, both ways, with and without the pull request card, across
plugin headings; the popover keeps its order of header, tiles, rows,
delete, plugin rows, and pull request.

This branch has not been deployed

No deployments
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.

[Feature]: Show pane-context plugin actions in the pane menu (e.g. hand a Claude Code session to/from Remote Control)

2 participants