Repository navigation
feat(hub): let dock entries add items to the context menu - #501
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
👁️🗨️ Review this pull request with grouped, summarized diffs at: raw result💭 analyzed by {
"headSha": "75ae12362455e7bb773af07b48957c6adc853817",
"result": {
"overallSummary": "Lets a dock entry declare `contextMenu` items that run a command (server or client), so a devframe can add its own right-click actions to its dock button alongside the built-in Pin/Hide/Refresh/Edge/Popup items. Adds the type, a pure resolver that applies `when`/fallback/separator rules, the hub-ui rendering (including checkbox items), a demo in `examples/hub-vite`, and guide docs.",
"groups": [
{
"key": "types",
"label": "Dock contextMenu types",
"summary": "Adds the `contextMenu` field to `DevframeDockEntryBase` along with the new serializable `DevframeDockContextMenuItem` (command/separator) types; snapshot files are the generated type-API diffs for this change.",
"category": "api",
"filePaths": [
"packages/hub/src/types/docks.ts",
"tests/__snapshots__/tsnapi/@devframes/hub/index.snapshot.d.ts",
"tests/__snapshots__/tsnapi/@devframes/hub/types.snapshot.d.ts"
],
"fileNotes": [
{
"path": "packages/hub/src/types/docks.ts",
"text": "`args` is restricted to `string | number | boolean | null` so items stay serializable across the wire for out-of-process viewers."
}
]
},
{
"key": "ui",
"label": "Render entry menu items",
"summary": "Implements the dock context menu UI: a pure resolver turns an entry's `contextMenu` into renderable items (applying `when`, fallbacks, separator cleanup), and `DockContextMenu.ts` renders them above the built-in items with checkbox support.",
"category": "ui",
"filePaths": [
"packages/hub-ui/src/client/components/dock/DockContextMenu.ts",
"packages/hub-ui/src/client/state/dock-context-menu.ts"
],
"critical": true,
"fileNotes": [
{
"path": "packages/hub-ui/src/client/state/dock-context-menu.ts",
"text": "Pure resolver: drops items whose own or command `when` is false, unknown command ids, and client commands with no `action`; also collapses leading/trailing/duplicate separators."
}
]
},
{
"key": "ui-tests",
"label": "Resolver tests",
"summary": "Unit tests for `resolveDockContextMenu` covering fallbacks, locales, `when` filtering, unknown/action-less commands, and separator cleanup.",
"category": "tests",
"filePaths": [
"packages/hub-ui/src/client/state/dock-context-menu.test.ts"
]
},
{
"key": "example",
"label": "Demo in hub-vite example",
"summary": "Adds a \"Ping\" command item and a checkable \"Compact Mode\" item to the JSON Render dock to demonstrate and manually verify the new feature.",
"category": "examples",
"filePaths": [
"examples/hub-vite/vite.config.ts"
]
},
{
"key": "docs",
"label": "Document dock context menu",
"summary": "Adds a \"Dock context menu\" guide section explaining the item fields and resolution rules, plus a pointer for custom hub UI authors.",
"category": "docs",
"filePaths": [
"docs/content/1.guide/16.hub.md",
"docs/content/1.guide/22.build-your-own-hub-ui.md"
]
}
],
"schemaVersion": 1,
"source": "llm",
"generatedAt": "2026-11-19T01:35:31.059Z",
"model": "vercel-ai-gateway/anthropic/claude-sonnet-5",
"locale": "en"
}
} |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A devframe can now add its own items to the right-click menu of its dock button. Before this change, the menu had only the built-in items (Pin, Hide, Refresh, Edge mode, Popup).
The request came from the Svelte inspector use case. A left-click toggles the inspector, and a right-click shows its settings, so the settings do not need a second dock entry.
A dock entry declares
contextMenu. Each item points to a command id, so one handler serves the menu, the palette and keybindings. This is the same pattern thatlauncher.commanduses. The items are serializable, so a node-side devframe can declare them and an out-of-process viewer can show them.Change map
@devframes/hubtypesDevframeDockEntryBase.contextMenu: command items (command,args,title,titleLocales,icon,when,checked) and{ type: 'separator' }@devframes/hub-uiDockContextMenu.tsrole="menuitemcheckbox"witharia-checked@devframes/hub-uistate/dock-context-menu.tswhenor commandwhenis false, unknown command ids, and client commands with noaction. Title and icon default to the command's. Removes separators at the start and end and merges repeated onesexamples/hub-viteDesign notes:
argstakes onlystring | number | boolean | null. Shared state wraps entries inImmutable<T>. Withunknown[], the storybook typecheck failed, and a recursive JSON type hit "excessively deep". Object args can come later if a tool needs them.checkedis a plain boolean that the author patches withdocks.update(). The when-context has no custom keys today, so a when-expression could not reflect a tool's own setting.@devframes/hub-uirenders the items.custom-hub-viteandcustom-hub-nexthave no dock context menu today, so they stay unchanged and still match each other.Visual changes
Right-click on the JSON Render dock in
examples/hub-vite, after "Compact Mode" was clicked once. The triangle icons are the fallback because the sandbox blocks the Iconify CDN. No "before" capture: onmain, the same menu shows only Pin and Hide.Verification
pnpm lint,pnpm knip,pnpm build,pnpm typecheck: pass (after the rebase oneaa9f7b5).pnpm test: 1896 passed, 2 failed. The 2 failures aredev.test.tsandinitiate.test.ts, which fetch[::1], and the sandbox HTTP proxy blocks that. With the proxy variables unset, both files pass (51 of 51).vitest run packages/hub-ui: 170 of 170, including 5 new tests for the resolver (fallbacks, locales,when, unknown and action-less commands, separator cleanup).examples/hub-vite: the right-click menu shows Ping, a separator, Compact Mode, a separator, Pin, Hide. Clicking Compact Mode ran the server command, and the next open showedchecked=true. Label x-offsets are 92px for all four items.contextmenufor it. The existing focus and arrow-key code now also selectsmenuitemcheckbox.User prompts
Claude Opus 5.5 in Claude Code (inside Paseo). The user forwarded a community request for devtools to add their own right-click items to the dock icon (Svelte inspector: left-click toggles, right-click opens settings). They asked to implement it as "devframe registers the right-click menu and binds a command to it", using an interview to settle the design: item fields, placement,
whenbehavior, separators, scope, demo and docs. Then they asked for a PR.This PR was written with an AI agent. The user gave the task and made each design decision in the interview. They have not reviewed the diff yet.