Skip to content

Actions

Use hc.actions.register for lightweight commands discoverable from the Action menu (type #). Requires the ui permission. Actions do not need manifest.contributes.commands entries.

See UI for related contribution registrars.

hc.actions.register(namespace, handlers)

Available since v2.0.0

Signature:(namespace: string, handlers: Record<string, () => void | Promise<void>>) => Disposable

ParameterTypeDescription
namespacestringPrefix shown before each action label
handlersRecord<string, () => void | Promise<void>>Action labels mapped to handlers run on selection

Manifest: none. Requires the ui permission.

Registers plugin actions in HarborClient's Action menu. Users open the Action menu, type #, and see actions grouped as Namespace: Label.

Use this for lightweight commands that should be discoverable without adding a persistent menu item or toolbar button. Because actions are dynamic, they do not need manifest.contributes.commands entries, but the plugin must include the ui permission.

With that plugin installed, typing #curl in the Action menu shows:

  • cURL: View
  • cURL: Close
typescript
hc.actions.register('cURL', {
  View: () => {
    hc.ui.showToast('Viewing generated cURL command');
  },
  Close: () => {
    hc.ui.showToast('Closed cURL preview');
  }
});