The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): preserve star map context menu
Daniel Pengc54d21b90ec6
diff --git a/apps/desktop/src/app/context-menu/app-context-menu.tsx b/apps/desktop/src/app/context-menu/app-context-menu.tsxindex d2d813e938b..b4bac2f2b9b 100644--- a/apps/desktop/src/app/context-menu/app-context-menu.tsx+++ b/apps/desktop/src/app/context-menu/app-context-menu.tsx@@ -41,8 +41,8 @@ import {import { isWebUrl, resolveDomTarget } from './target'/** Marks a surface that owns PLAIN right-clicks itself (the user-message- * reaction bubble). Owned targets inside it — links, images, editables,- * selections — still get the app menu. */+ * reaction bubble and the Star Map canvas). Owned targets inside it — links,+ * images, editables, selections — still get the app menu. */export const CONTEXT_MENU_SKIP_ATTR = 'data-context-menu-skip'const LOOPBACK_HOST_RE = /^(localhost|127\.0\.0\.1|0\.0\.0\.0|\[?::1\]?)$/i@@ -647,8 +647,8 @@ export function AppContextMenu() {const target = resolveDomTarget(element)const owned = Boolean(target.linkUrl || target.onImage || target.editable || target.selectionText)- // The reaction bubble owns bare right-clicks; a link inside it still- // opens the link menu.+ // Skip-marked surfaces own bare right-clicks; owned DOM targets inside+ // them still open the corresponding app menu.if (!owned && element?.closest(`[${CONTEXT_MENU_SKIP_ATTR}]`)) {return}diff --git a/apps/desktop/src/app/starmap/star-map-context-menu.test.tsx b/apps/desktop/src/app/starmap/star-map-context-menu.test.tsxnew file mode 100644index 00000000000..daa70d57e66--- /dev/null+++ b/apps/desktop/src/app/starmap/star-map-context-menu.test.tsx@@ -0,0 +1,98 @@+import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'+import { MemoryRouter } from 'react-router'+import { afterEach, describe, expect, it, vi } from 'vitest'++import { AppContextMenu } from '@/app/context-menu/app-context-menu'+import { $contextMenu } from '@/app/context-menu/store'+import type { StarmapGraph } from '@/types/hermes'++import { StarMap } from './star-map'++class TestResizeObserver {+ constructor(private readonly callback: ResizeObserverCallback) {}++ disconnect() {}++ observe(target: Element) {+ Object.defineProperties(target, {+ clientHeight: { configurable: true, value: 300 },+ clientWidth: { configurable: true, value: 400 }+ })+ this.callback([{ target } as ResizeObserverEntry], this as unknown as ResizeObserver)+ }++ unobserve() {}+}++const graph: StarmapGraph = {+ clusters: [],+ edges: [],+ memory: [],+ nodes: [+ {+ category: 'coding',+ createdBy: null,+ id: 'skill-a',+ kind: 'skill',+ label: 'Skill A',+ pinned: false,+ state: 'active',+ useCount: 1+ }+ ],+ stats: {}+}++vi.mock('./simulation', () => ({+ buildSimulation: (input: StarmapGraph) => {+ const nodes = input.nodes.map(node => ({+ ...node,+ outerRingIndex: 0,+ rec: 1,+ tr: 0,+ vx: 0,+ vy: 0,+ x: 0,+ y: 0+ }))++ return {+ byId: new Map(nodes.map(node => [node.id, node])),+ links: [],+ nodes,+ rings: [{ label: null, r: 200, ratio: 1 }],+ sim: { stop: vi.fn() }+ }+ }+}))++afterEach(() => {+ $contextMenu.set(null)+ cleanup()+ vi.restoreAllMocks()+})++describe('StarMap context menu ownership', () => {+ it('keeps the canvas gesture so a node can open its Edit/Delete menu', async () => {+ vi.stubGlobal('ResizeObserver', TestResizeObserver)+ vi.spyOn(window, 'requestAnimationFrame').mockReturnValue(1)+ vi.spyOn(window, 'cancelAnimationFrame').mockImplementation(() => undefined)+ vi.spyOn(HTMLCanvasElement.prototype, 'getContext').mockReturnValue(null)++ const { container } = render(+ <MemoryRouter>+ <AppContextMenu />+ <StarMap graph={graph} />+ </MemoryRouter>+ )++ const canvas = container.querySelector('canvas')!++ await waitFor(() => expect(canvas.style.width).toBe('400px'))+ fireEvent.contextMenu(canvas, { clientX: 200, clientY: 165 })++ expect(await screen.findByText('Edit skill…')).toBeTruthy()+ expect(screen.getByText('Archive skill')).toBeTruthy()+ expect($contextMenu.get()).toBeNull()+ })+})diff --git a/apps/desktop/src/app/starmap/star-map.tsx b/apps/desktop/src/app/starmap/star-map.tsxindex 20998fce06a..4acbf62e440 100644--- a/apps/desktop/src/app/starmap/star-map.tsx+++ b/apps/desktop/src/app/starmap/star-map.tsx@@ -919,6 +919,7 @@ export function StarMap({<div className="relative min-h-0 flex-1 overflow-hidden" ref={wrapRef}><canvasclassName="block touch-none select-none text-foreground"+ data-context-menu-skip=""onContextMenu={onContextMenu}onDoubleClick={resetView}onMouseDown={onMouseDown}