DSH Web provides plugin capability, but native browser right-click menus are usually difficult to customize directly. When developers need custom actions (such as context actions for specific nodes) or integrate system tools (such as directly opening a workspace directory), they often have to implement complex interception logic themselves. The dsh-custom-context-menu plugin solves this problem. It globally takes over the browser’s contextmenu event, provides a zero-dependency extension framework, and includes a built-in feature for opening workspace folders in the file manager.
Plugin Overview¶
This is a custom right-click menu plugin for the DeepSeek Harness Web UI. It is maintained by developer sulfide2085 and licensed under the MIT License. The core value of the plugin is twofold: first, it provides an extensible Provider API, allowing developers to register custom menu items through code; second, it includes a built-in “Open Folder in Explorer” feature for the DSH workspace sidebar.
Core Features¶
- Global takeover and smart positioning: The plugin intercepts page-global right-click events (excluding input fields and the menu itself), automatically adjusts its position near screen edges, and ensures the menu remains visible.
- Extensible Provider API: Supports registering menu items through the
registerfunction. It supports regular items, separators, group titles, as well as disabled states, danger-action markers, and hint text. - No interference without a match: If no Provider matches the current right-click target, the plugin allows the browser’s native context menu to proceed, avoiding a “No menu items” placeholder.
- Workspace folder opening: Right-clicking a workspace row in the sidebar provides an “Open Folder” option. It supports Windows (
explorer.exe), macOS (open), and Linux (xdg-open), and reports an error when the path is invalid. - Keyboard navigation: Supports selecting menu items with arrow keys and triggering them with
EnterorSpace.
Installation and Enablement¶
Use the official CLI to install it.
dsh plugin --profile web add "https://github.com/sulfide2085/dsh-custom-context-menu.git"
After installation, restart the DSH Web process for it to take effect.
Typical Usage¶
After installation, you can access the window.dshContextMenu object from the browser console or extension code.
1. Register Menu Items¶
Use the register method to register a callback function. The function receives the target element and event object, and returns an array of menu items.
window.dshContextMenu.register((target, event) => {
// 检查是否为目标元素
const row = target.closest("[data-session-row]");
if (row === null) return null; // 不处理,交给下一个 provider
return [
{ type: "label", text: row.dataset.title },
{ label: "复制标题", onClick: () => navigator.clipboard.writeText(row.dataset.title) },
{ type: "separator" },
{ label: "删除会话", danger: true, onClick: () => { /* ... */ } }
];
});
2. Menu Item Types¶
Menu items support the following forms:
* String: A shorthand, where label is the string content.
* Object: Contains properties such as label, onClick, disabled, danger, and hint.
* Separator: { type: "separator" }.
* Group title: { type: "label", text: "Title" }.
3. Control the Menu¶
You can use the API to control the menu’s enabled state and display.
// 开启或关闭全局菜单
window.dshContextMenu.setEnabled(true);
// 命令式在指定坐标弹出菜单
window.dshContextMenu.open(x, y, items);
Applicable Scenarios and Notes¶
- Single-level menu: The current version does not support multi-level submenus; menu items have a flat structure.
- Workspace matching: The “Open Folder” feature depends on the official DSH Web workspace row structure and the
ctx.workspacesservice. Matching rules include thearia-labelof the ellipsis button at the end of the row and the first text span in the row matching the workspacetitleor the basename of the directorypath. - Native menu pass-through: Right-clicking on input fields, text areas, or editable elements, or when no matching item exists, causes the plugin to fully pass through the browser’s native context menu, preserving basic functions such as copy and paste.
Summary¶
This plugin solves the right-click menu customization needs in DSH Web environments through a simple API wrapper, making it suitable for developers who need to deeply integrate system tools or customize interactions.