Interface: ContextMenuContribution<S>
Defined in: packages/sdk/src/types.ts:375
Adds a command to the right-click context menu of a built-in surface. Register via ExtensionContext.registerContextMenuItem.
When the surface is right-clicked, the host collects the registered contributions, evaluates each when against the current context keys and the freshly-built target object, and dispatches the chosen command with the target as its first argument.
Type Parameters
S
S extends MenuSurface = MenuSurface
Properties
surface
surface: S;Defined in: packages/sdk/src/types.ts:377
Which context menu to contribute to.
command
command: string;Defined in: packages/sdk/src/types.ts:379
The command to run; receives the surface's MenuContext[S] as its first arg.
label?
optional label?: string;Defined in: packages/sdk/src/types.ts:381
Menu label (falls back to the command's label).
icon?
optional icon?: ReactNode;Defined in: packages/sdk/src/types.ts:383
Leading glyph for the row (e.g. a Phosphor icon element), same as MenuItem.icon.
order?
optional order?: number;Defined in: packages/sdk/src/types.ts:385
Ordering within the menu; lower sorts first.
group?
optional group?: string;Defined in: packages/sdk/src/types.ts:391
Optional group id — items with the same group render together with a separator between groups. Group names sort lexically; defaults to "9_default", same as MenuItemContribution.group.
when?
optional when?: (ctx, target) => boolean;Defined in: packages/sdk/src/types.ts:396
Enable/visibility predicate. Receives the same per-surface context as the command plus the current context keys. Returning false hides the item.
Parameters
ctx
target
MenuContext[S]
Returns
boolean
checked?
optional checked?: (ctx, target) => boolean;Defined in: packages/sdk/src/types.ts:404
Toggle-row predicate. When provided, the item renders with a checkmark in the leading gutter whenever this returns true — the same rendering MenuItem.checked gives ctx.ui.showMenu rows. Lets a single command represent an on/off state (e.g. "enabled for this workspace") instead of registering two mutually-exclusive commands gated by when.
Parameters
ctx
target
MenuContext[S]
Returns
boolean