diff --git a/src/renderer/src/components/dashboard-popout/AgentMap.tsx b/src/renderer/src/components/dashboard-popout/AgentMap.tsx index 6bce95eaeac..4d04af781a7 100644 --- a/src/renderer/src/components/dashboard-popout/AgentMap.tsx +++ b/src/renderer/src/components/dashboard-popout/AgentMap.tsx @@ -18,6 +18,7 @@ import { type AgentMapHostFilter } from './agent-map-filter' import { updateAgentMapLayout, type AgentMapLayoutCache } from './agent-map-layout' +import { selectAgentMapRecentFinishPaneKeys } from './agent-map-node-metadata' import './agent-map.css' type AgentMapProps = { @@ -120,6 +121,10 @@ export function AgentMap({ () => updateAgentMapLayout(layoutCacheRef.current, visibleCards, now, visibleWorkspaces), [visibleCards, visibleWorkspaces, now] ) + const recentFinishPaneKeys = useMemo( + () => selectAgentMapRecentFinishPaneKeys(visibleCards), + [visibleCards] + ) useEffect(() => { layoutCacheRef.current = layoutResult.cache }, [layoutResult.cache]) @@ -173,6 +178,7 @@ export function AgentMap({ selectedPaneKey={selectedPaneKey} allowAggregation showOrchestrationLinks={showOrchestrationLinks} + recentFinishPaneKeys={recentFinishPaneKeys} launchableAgentsByWorktreeId={launchableAgentsByWorktreeId} workspaceContextMenusEnabled={workspaceContextMenusEnabled} onWorkspaceContextMenuOpenChange={onWorkspaceContextMenuOpenChange} diff --git a/src/renderer/src/components/dashboard-popout/AgentMapCanvas.tsx b/src/renderer/src/components/dashboard-popout/AgentMapCanvas.tsx index 3b71f0f2006..acc4b539a2f 100644 --- a/src/renderer/src/components/dashboard-popout/AgentMapCanvas.tsx +++ b/src/renderer/src/components/dashboard-popout/AgentMapCanvas.tsx @@ -35,8 +35,6 @@ import { useAgentMapViewportTransition } from './useAgentMapViewportTransition' const AGENT_FOCUS_DURATION_MS = 240 -type Point = { x: number; y: number } - export type AgentMapCanvasHandle = { fit: () => void focusProject: (project: AgentMapProjectRing) => void @@ -48,6 +46,7 @@ type AgentMapCanvasProps = { selectedPaneKey: string | null allowAggregation: boolean showOrchestrationLinks: boolean + recentFinishPaneKeys: ReadonlySet launchableAgentsByWorktreeId?: Record workspaceContextMenusEnabled?: boolean onWorkspaceContextMenuOpenChange?: (open: boolean) => void @@ -64,6 +63,7 @@ export const AgentMapCanvas = forwardRef()) const dragRef = useRef<{ pointerId: number - point: Point - center: Point + point: AgentMapViewport['center'] + center: AgentMapViewport['center'] worldPerPixelX: number worldPerPixelY: number } | null>(null) @@ -387,6 +387,7 @@ export const AgentMapCanvas = forwardRef { selectedPaneKey={null} allowAggregation showOrchestrationLinks + recentFinishPaneKeys={new Set()} nodeRefs={{ current: new Map() }} onSelectAgent={vi.fn()} onAgentKeyDown={vi.fn()} diff --git a/src/renderer/src/components/dashboard-popout/AgentMapScene.tsx b/src/renderer/src/components/dashboard-popout/AgentMapScene.tsx index 4ca92550269..d0e7c2b61c9 100644 --- a/src/renderer/src/components/dashboard-popout/AgentMapScene.tsx +++ b/src/renderer/src/components/dashboard-popout/AgentMapScene.tsx @@ -11,7 +11,6 @@ import type { AgentMapWorktreeRing } from './agent-map-layout' import { AGENT_MAP_LINEAGE_RELATION, shouldAggregateAgentMapWorktree } from './agent-map-layout' -import { selectAgentMapRecentFinishPaneKeys } from './agent-map-node-metadata' import { selectVisibleAgentMapLabels } from './agent-map-label-declutter' import { agentMapDirectLineageChevronPath } from './agent-map-lineage-chevron-path' import { AgentMapWorktreeLabel } from './AgentMapWorktreeLabel' @@ -29,6 +28,7 @@ type AgentMapSceneProps = { selectedPaneKey: string | null allowAggregation: boolean showOrchestrationLinks: boolean + recentFinishPaneKeys: ReadonlySet launchableAgentsByWorktreeId?: Record nodeRefs: MutableRefObject> onSelectAgent: (card: DashboardCard) => void @@ -72,6 +72,7 @@ export const AgentMapScene = memo(function AgentMapScene({ selectedPaneKey, allowAggregation, showOrchestrationLinks, + recentFinishPaneKeys, launchableAgentsByWorktreeId, nodeRefs, onSelectAgent, @@ -125,15 +126,6 @@ export const AgentMapScene = memo(function AgentMapScene({ } return agents }, [allowAggregation, layout, selectedPaneKey, zoom]) - const recentFinishPaneKeys = useMemo( - () => - selectAgentMapRecentFinishPaneKeys( - layout.projects.flatMap((project) => - project.worktrees.flatMap((worktree) => worktree.agents.map((agent) => agent.card)) - ) - ), - [layout] - ) return ( <> {layout.projects.map((project) => { diff --git a/src/renderer/src/components/dashboard-popout/agent-map-glow.performance.test.ts b/src/renderer/src/components/dashboard-popout/agent-map-glow.performance.test.ts index 477cff4b0ad..c56c49dd11c 100644 --- a/src/renderer/src/components/dashboard-popout/agent-map-glow.performance.test.ts +++ b/src/renderer/src/components/dashboard-popout/agent-map-glow.performance.test.ts @@ -70,4 +70,12 @@ describe('Agent Map glow performance boundary', () => { expect(windowMs).toBeGreaterThan(0) expect(cssMs).toBe(windowMs) }) + + it('selects capped flares before rendering instead of flattening the scene', () => { + const map = source('AgentMap.tsx') + const scene = source('AgentMapScene.tsx') + + expect(map).toMatch(/selectAgentMapRecentFinishPaneKeys\(visibleCards\)/) + expect(scene).not.toContain('selectAgentMapRecentFinishPaneKeys') + }) })