Repository navigation
Offer the host's action menu to plugins - #4270
Merged
Merged
Conversation
Adds Menu to the optional ui service: a host-rendered trigger (label or icon button) and plain items with label, onSelect, destructive tone and disabled. The host owns the portal, highlight, keyboard, typeahead, Escape and focus return. Menu is optional in the type so plugins check ui.Menu on hosts from before it. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Gil Birman <gil@squareup.com>
Prove arrow keys and typeahead move focus, and that a disabled item does nothing. Validated with vitest src/features/plugin-ui and a disabled-item mutation check. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Gil Birman <gil@squareup.com>
Drop the redundant MenuItem label; Base UI types ahead on the item's text. Validated with vitest src/features/plugin-ui. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Gil Birman <gil@squareup.com>
gilgtm
marked this pull request as ready for review
November 23, 2026 18:43
wesbillman
reviewed
Nov 23, 2026
wesbillman
left a comment
Collaborator
There was a problem hiding this comment.
🤖 Star Lord. Ready for approval at c5b473d. The optional action menu fits the existing plugin UI service, and the source review found no changes needed. Required CI passed in the review snapshot. Runtime behavior was not independently exercised.
dr0uleau
approved these changes
Nov 23, 2026
dr0uleau
left a comment
Contributor
There was a problem hiding this comment.
🤖 reviewed at c5b473dc -- optional plugin menu capability, no existing host UX change. CI passed and no actionable findings remain
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.
Plugins can now open a real host action menu.
ctx.reflect.get("ui").Menutakes a trigger and a list of items, and the host owns everything else: the popup that escapes clipping containers, hover highlight, arrow keys, typeahead, Escape, focus return, and the red destructive tone. Before this, a plugin that wanted a "⋯" menu had to build its own, and it got clipped, missed keyboard support, or looked different from the app's menus.The contract stays narrow. Items are
{ label, onSelect, tone?: "default" | "destructive", disabled? }, with no submenus, checkboxes, radios or separators.ui.Menuis optional in the type, so plugins check for it and fall back on older hosts.flowchart LR P[Plugin] -->|"ctx.reflect.get('ui')"| U{ui.Menu?} U -->|missing: older host| F[Plugin's own fallback] U -->|present| M["ui.Menu({ aria-label or label, items })"] M --> H[Host Menu: portal above clipping containers,<br/>highlight, arrows, typeahead, Escape, focus return] H -->|user picks an item| S["item.onSelect()"] S -->|optional| D[ui.Dialog opens]Screenshots
The
examples/plugins/host-controlsplugin in the packaged macOS app, with the destructive "Clear name" item under the pointer.Video
Narrated runs in the packaged app, driven with the real pointer and real keys. They cover click to open, hover, a disabled item, keyboard open, arrows and Escape, the destructive item, and "Edit name" opening a Dialog with focus returning to the trigger.
Light mode:
plugin-menu-light-20261123-181158-annotated.mp4
Dark mode:
plugin-menu-dark-20261123-181749-annotated.mp4
How it works
src/features/plugin-ui/contract.tsaddsPluginMenuItemandPluginMenuProps.PluginUi.Menuis optional so authors must feature-detect it.src/features/plugin-ui/service.tsxmaps the contract onto the sharedMenu(Base UI). Without alabel, the trigger is anIconButtonwith the More icon and thearia-labelas its name and tooltip. With alabel, it is a ghostButton.tone: "destructive"maps to the host'sdangertone.icon, a non-string label, or a non-functiononSelectis ignored, and items without a string label are dropped.src/plugins/author.tsexports the new types. The example plugin, the authoring guide and the examples README show the menu.Testing
src/features/plugin-ui/service.test.tsxcovers the keyboard path (Enter, arrows, typeahead, disabled item, Enter to select, focus return), the menu rendering outside a clipping card, and a destructive item that opens aDialogwith Escape returning focus to the trigger. The wrong-type test now includes aMenu.src/plugins/author.test.mjschecks that authors must guardui.Menubefore using it.Risk
Low. The change is additive to the plugin UI service. Existing controls and host menus are untouched, and older plugins do not see a difference.
Known limits
labelnoraria-labelgets a trigger with no accessible name. TypeScript authors cannot do this.🤖 Generated with Claude Code