Skip to content

Interface: ContextMenuContribution<S> ​

Defined in: packages/sdk/src/types.ts:524

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 ​

ts
surface: S;

Defined in: packages/sdk/src/types.ts:526

Which context menu to contribute to.


command ​

ts
command: string;

Defined in: packages/sdk/src/types.ts:528

The command to run; receives the surface's MenuContext[S] as its first arg.


label? ​

ts
optional label?: string;

Defined in: packages/sdk/src/types.ts:530

Menu label (falls back to the command's label).


icon? ​

ts
optional icon?: ReactNode;

Defined in: packages/sdk/src/types.ts:532

Leading glyph for the row (e.g. a Phosphor icon element), same as MenuItem.icon.


order? ​

ts
optional order?: number;

Defined in: packages/sdk/src/types.ts:534

Ordering within the menu; lower sorts first.


group? ​

ts
optional group?: string;

Defined in: packages/sdk/src/types.ts:540

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? ​

ts
optional when?: (ctx, target) => boolean;

Defined in: packages/sdk/src/types.ts:545

Enable/visibility predicate. Receives the same per-surface context as the command plus the current context keys. Returning false hides the item.

Parameters ​

ctx ​

ContextKeys

target ​

MenuContext[S]

Returns ​

boolean


checked? ​

ts
optional checked?: (ctx, target) => boolean;

Defined in: packages/sdk/src/types.ts:553

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 ​

ContextKeys

target ​

MenuContext[S]

Returns ​

boolean