mirror of
https://github.com/stablyai/orca.git
synced 2026-10-23 08:03:39 +00:00
perf(agent-map): avoid fleet flare allocation
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -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<string>
|
||||
launchableAgentsByWorktreeId?: Record<string, TuiAgent[]>
|
||||
workspaceContextMenusEnabled?: boolean
|
||||
onWorkspaceContextMenuOpenChange?: (open: boolean) => void
|
||||
@@ -64,6 +63,7 @@ export const AgentMapCanvas = forwardRef<AgentMapCanvasHandle, AgentMapCanvasPro
|
||||
selectedPaneKey,
|
||||
allowAggregation,
|
||||
showOrchestrationLinks,
|
||||
recentFinishPaneKeys,
|
||||
launchableAgentsByWorktreeId,
|
||||
workspaceContextMenusEnabled = false,
|
||||
onWorkspaceContextMenuOpenChange,
|
||||
@@ -78,8 +78,8 @@ export const AgentMapCanvas = forwardRef<AgentMapCanvasHandle, AgentMapCanvasPro
|
||||
const nodeRefs = useRef(new Map<string, SVGGElement>())
|
||||
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<AgentMapCanvasHandle, AgentMapCanvasPro
|
||||
selectedPaneKey={selectedPaneKey}
|
||||
allowAggregation={allowAggregation}
|
||||
showOrchestrationLinks={showOrchestrationLinks}
|
||||
recentFinishPaneKeys={recentFinishPaneKeys}
|
||||
launchableAgentsByWorktreeId={launchableAgentsByWorktreeId}
|
||||
nodeRefs={nodeRefs}
|
||||
onSelectAgent={onSelectAgent}
|
||||
|
||||
@@ -44,6 +44,7 @@ describe('AgentMapScene project labels', () => {
|
||||
selectedPaneKey={null}
|
||||
allowAggregation
|
||||
showOrchestrationLinks
|
||||
recentFinishPaneKeys={new Set()}
|
||||
nodeRefs={{ current: new Map() }}
|
||||
onSelectAgent={vi.fn()}
|
||||
onAgentKeyDown={vi.fn()}
|
||||
|
||||
@@ -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<string>
|
||||
launchableAgentsByWorktreeId?: Record<string, TuiAgent[]>
|
||||
nodeRefs: MutableRefObject<Map<string, SVGGElement>>
|
||||
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) => {
|
||||
|
||||
@@ -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')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user