Context Menu
Extensions can add custom items to the entry context menu in the powhttp interface. Items can target a single entry or multiple selected entries. When a user clicks a registered item, powhttp invokes the corresponding handler callback on the extension.
ContextMenuNode
Context menu registrations use a tree structure called ContextMenuNode. A node is either an item with a unique ID and label or a submenu containing child nodes.
type ContextMenuNode =
| { type: "item"; id: string; label: string }
| { type: "submenu"; label: string; children: Array<ContextMenuNode> };Submenus create nested groups in the context menu. Items represent clickable actions with unique IDs that are referenced in handler callbacks.
context_menu/extend_single
Registers context menu items for single-entry actions. Accepts a ContextMenuNode tree to define items and submenus.
Parameters: ContextMenuNode
Result: null
Example:
{
"type": "submenu",
"label": "My Extension",
"children": [
{ "type": "item", "id": "analyze", "label": "Analyze Request" },
{ "type": "item", "id": "export", "label": "Export as cURL" }
]
}context_menu/remove_item_single
Removes a previously registered single-entry context menu item by its ID. If the removal causes a submenu to become empty, the submenu is also removed.
Parameters:
{
itemId: string;
}Result: null
context_menu/extend_multi
Registers context menu items that appear when multiple entries are selected. Works the same as context_menu/extend_single but handlers receive an array of entry IDs.
Parameters: ContextMenuNode
Result: null
context_menu/remove_item_multi
Removes a previously registered multi-entry context menu item by its ID.
Parameters:
{
itemId: string;
}Result: null
Handler Callbacks
These methods are called by powhttp on the extension when a user clicks a registered context menu item. The extension must implement these handlers to respond to user actions.
context_menu/call_item_handler_single
Called when a user clicks a single-entry context menu item.
Parameters:
{
itemId: string;
sessionId: string;
entryId: string;
}Result: null
context_menu/call_item_handler_multi
Called when a user clicks a multi-entry context menu item.
Parameters:
{
itemId: string;
sessionId: string;
entryIds: Array<string>;
}Result: null