Repository navigation
fix: render navigation options as links for Open in New Tab - #1524
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
✅ Review complete. This review was performed through OpenHands Cloud Automation. You can log in and view the conversation here. |
all-hands-bot
left a comment
There was a problem hiding this comment.
🟢 Good taste — minimal, well-targeted change that reuses the existing runItem activation path so keyboard, plain left-click, and (transitively) the test suite all keep working unchanged. Extracting assignRef + optionClassName + content collapses the previous <button>-only tree into one shared body with two thin wrappers, which is the right shape (the duplication was about to become a maintenance hazard).
The choice of a raw <a> over the existing NavigationLink is correct and well-reasoned in the PR body: NavigationLink calls navigate(to, { replace: false }) and doesn't close(), which would (a) change the navigate arg shape and break expect(navigate).toHaveBeenCalledWith(COMMAND_MENU_ROUTE.automations) and (b) split keyboard and mouse activation across two code paths. Keeping a single runItem activation is the right call.
The modifier-key gate (meta/ctrl/shift/alt) on onClick is the right size — don't preventDefault and let the browser's native new-tab behavior take over for middle/right-click and Cmd/Ctrl-click. Plain left-click still preventDefaults and reuses runItem. Behavior parity confirmed against runItem and the keyboard Enter branch.
Widening optionRefs to Map<string, HTMLElement> is correct — scrollIntoView exists on HTMLElement and the map is only used for that. One small follow-up below.
Evidence noted in PR description: npm run typecheck, ESLint/Prettier on the file, and 7/7 existing command-menu.test.tsx cases pass without modification. Mock-LLM E2E and Docker E2E both report 60/60 green at the head commit. No code changes that would invalidate them.
[RISK ASSESSMENT]
⚠️ Risk Assessment: 🟢 LOW
Single-file frontend change in a small, well-tested component. Plain left-click, keyboard Enter, and the existing navigate+close path are byte-identical to before (samerunItemcall). The only new behavior — letting the browser's native context menu offer "Open Link in New Tab" for<a href>— is exactly what the user asked for and falls through to the browser without any new code path. No data flow, persistence, security boundary, or API changes.
VERDICT: ✅ Worth merging.
KEY INSIGHT: Rendering navigation options as real <a href> and reusing runItem is the smallest change that solves the problem — no new context-menu UI, no new event handlers, no new navigate call shape.
✅ Mock-LLM E2E Tests60/60 passed Commit: Details
Posted by the Mock-LLM E2E workflow · results are deterministic (scripted LLM responses) |
✅ Mock-LLM Docker E2E Test Results60/60 passed Commit: Details
Posted by the Mock-LLM E2E workflow · results are deterministic (scripted LLM responses) |
|
🚀 Released in v1.2.0. |
HUMAN:
Command menu (Cmd/Ctrl+K) navigation options were rendered as elements that navigated programmatically, so right-clicking them never offered the browser's native "Open Link in New Tab" — that entry only appears for real anchors.
Render items with a
toroute as anchors while keeping the single action item (Toggle Sidebar) a . Plain left-click still preventDefaults and reuses the existing runItem() (close + navigate), so in-app navigation and the keyboard Enter path are unchanged. Modified clicks (cmd/ctrl/shift/alt) and right/middle-click fall through to the browser, opening the route in a new tab while the palette stays open.The option ref map is widened from HTMLButtonElement to HTMLElement to hold both anchors and the button (used only for scrollIntoView).
No test changes: navigate is still called as navigate(item.to) on click.
AGENT:
Why
When a user opens the command menu (
Cmd/Ctrl + K) and right-clicks an option, the browser's native context menu does not offer "Open Link in New Tab". As a result, users cannot open a navigation destination (New chat, Settings, Automations, MCP, etc.) in a separate tab — they can only navigate in place.Root cause: Navigation options are rendered as
<button>elements that navigate programmatically (navigate(item.to)). The browser only exposes "Open Link in New Tab" for real anchor (<a href>) elements, never for<button>s.Steps to Reproduce
npm run dev).Cmd + Kto open the command menu.Expected Behavior
Right-clicking a navigation option shows the native "Open Link in New Tab" entry; choosing it opens that route in a new tab.
Cmd/Ctrl/middle-clickon an option also opens it in a new tab. Action-only options without a destination (e.g. "Toggle Sidebar") correctly do not offer it.Acceptance Criteria
Cmd/Ctrl-click(and middle-click) on a navigation option opens it in a new tab; the palette stays open.Scope / Notes
src/components/features/command-menu/command-menu.tsx.Summary
Command menu (
Cmd/Ctrl + K) navigation options were rendered as<button>elements that navigated programmatically vianavigate(item.to). The browser's native right-click context menu only exposes "Open Link in New Tab" for real anchor (<a href>) elements — never for<button>s — so users had no way to open a command-menu destination in a new tab.This PR renders navigation options as real
<a href>anchors, so the native context menu offers "Open Link in New Tab" for free, andCmd/Ctrl/middle-clickopen the route in a new tab.What changed
src/components/features/command-menu/command-menu.tsx:Navigation options (items with a
toroute) now render as<a href={to} role="option">.Plain left-click:
preventDefault()+ reuse the existingrunItem(item)(which already doesclose()+navigate(item.to)). Behavior is byte-identical to before and consistent with the keyboard Enter path (alsorunItem).Modified click (
meta/ctrl/shift/alt) and right/middle-click: fall through to the browser → open the route in a new tab; the palette stays open.Action options with no destination (e.g. "Toggle Sidebar") stay as
<button>.Shared the inner markup (icon, title/description, GO/RUN hint) and class names between both branches so styling is unchanged.
Widened the option ref map from
Map<string, HTMLButtonElement>toMap<string, HTMLElement>(it holds both anchors and the button, and is only used forscrollIntoView).Design decisions / trade-offs
<a>over theNavigationLinkcomponent.NavigationLinkcallsnavigate(to, { replace: false })(2 args) and does not close the menu, which would split activation across two code paths (keyboard viarunItem, mouse viaNavigationLink) and change the navigate call shape. ReusingrunItemkeeps a single activation path and a test-safe, behavior-identical change.relomitted — first-party, same-origin app routes with notarget="_blank", so there is no opener/security concern.Testing
npm run typecheck— passesnpx eslint+prettier --checkon the changed file — passes__tests__/components/features/command-menu/command-menu.test.tsx— 7/7 pass, no test changesManual:
npm run dev, pressCmd + K, right-click a navigation option (e.g. "Automations") → native menu shows "Open Link in New Tab"; choosing it opens the route in a new tab, palette stays open.Cmd/Ctrl-clickan option → opens in a new tab.Out of scope
Issue Number
N/A.
How to Test
Clone the
agent-server-guirepository.Start the development server:
Video/Screenshots
app-2545.mov
Type
🐳 Docker images for this PR
• GHCR package: https://github.com/OpenHands/agent-canvas/pkgs/container/agent-canvas
ghcr.io/openhands/agent-canvasghcr.io/openhands/agent-server:1.29.3-pythonopenhands-automation==1.0.0a13dac6a61dee7de0dc13fa3392fe9e8141a13475a5Pull (multi-arch manifest)
# Multi-arch manifest — Docker automatically pulls the correct architecture docker pull ghcr.io/openhands/agent-canvas:sha-dac6a61Run
All tags pushed for this build
About Multi-Architecture Support
sha-dac6a61) is a multi-arch manifest supporting both amd64 and arm64sha-dac6a61-amd64) are also available if needed