Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
feat(ui): group endpoints and hide test routes in Routes
Bernhard Jackiewiczb2d75ceb6abd
diff --git a/graph-ui/src/architecture/ArchitecturePanel.test.tsx b/graph-ui/src/architecture/ArchitecturePanel.test.tsxindex 4f5731bd3..da421f151 100644--- a/graph-ui/src/architecture/ArchitecturePanel.test.tsx+++ b/graph-ui/src/architecture/ArchitecturePanel.test.tsx@@ -7,7 +7,7 @@ import type { ArchitecturePanelProps } from './ArchitecturePanel';import type { ArchitectureOverviewDto } from '../core/intelligence-provider';import { architectureText as text } from './strings';vi.mock('./ArchitectureScene', () => ({ ArchitectureScene: () => <div data-testid="scene" /> }));-vi.mock('./ContainerMap', () => ({ default: () => <div data-testid="container-map" /> }));+vi.mock('./ContainerMap', () => ({ default: ({ filter }: { filter: string }) => <div data-testid="container-map" data-filter={filter} /> }));let container: HTMLDivElement;let root: Root;@@ -136,6 +136,24 @@ describe('architecture workspace', () => {expect(container.querySelectorAll('tbody tr')).toHaveLength(30);});+ it('offers the filter in Routes only and hands it to the service and endpoint views', async () => {+ await render({ graph: { nodes: [], edges: [], total_nodes: 0 } });+ expect(container.querySelector('input[type="search"]')).toBeNull();+ await click('[data-view="routes"]');+ await act(async () => { await vi.dynamicImportSettled(); });+ const search = container.querySelector<HTMLInputElement>('input[type="search"]')!;+ expect(search.getAttribute('aria-label')).toBe(text.filter);+ await act(async () => {+ Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')!.set!.call(search, '/users');+ search.dispatchEvent(new Event('input', { bubbles: true }));+ });+ expect(container.querySelector('[data-testid="container-map"]')?.getAttribute('data-filter')).toBe('/users');+ await click('[data-view="hotspots"]');+ expect(container.querySelector('input[type="search"]')).toBeNull();+ await click('[data-view="routes"]');+ expect(container.querySelector<HTMLInputElement>('input[type="search"]')?.value).toBe('/users');+ });+it('restores the view per project while discarding old hidden search filters', async () => {window.localStorage.setItem('atlas.architecture.v1:sample', JSON.stringify({ version: 1, view: 'routes', filter: 'unrecorded' }));await render();diff --git a/graph-ui/src/architecture/ArchitecturePanel.tsx b/graph-ui/src/architecture/ArchitecturePanel.tsxindex 5d9edaecc..d8e57a05a 100644--- a/graph-ui/src/architecture/ArchitecturePanel.tsx+++ b/graph-ui/src/architecture/ArchitecturePanel.tsx@@ -112,6 +112,7 @@ function Findings({ view, data, empty, onNavigate }: {function ArchitectureWorkspace({ projectName, overview, loading = false, error, onRefresh, onNavigate, graph, selectionPanel, onSelect, onClearSelection, onSelectionEvidence, graphNote, graphGeneration, active = true, coverage, systemArchitectureLoader }: ArchitecturePanelProps): JSX.Element {const storage = useMemo(browserStorage, []);+ // A filter is a search for this visit: one saved by an earlier session would silently hide routes.const [config, setConfig] = useState(() => ({ ...readArchitectureConfig(storage, projectName), filter: '' }));useEffect(() => { saveArchitectureConfig(storage, projectName, config); }, [config, projectName, storage]);// A cached summary from another project must never appear here.@@ -122,20 +123,26 @@ function ArchitectureWorkspace({ projectName, overview, loading = false, error,if (active && (!projectName || (!systemView && (!ready || !graph)))) onSelectionEvidence?.(undefined);}, [active, projectName, systemView, ready, graph, onSelectionEvidence]);const SpatialView = config.view === 'routes' ? RoutesArchitecture : SpatialArchitecture;+ // Only the Routes view offers the filter, so no other view may receive a stale one.+ const filter = config.view === 'routes' ? config.filter : '';+ const setFilter = (value: string) => setConfig(current => ({ ...current, filter: value }));return <section className="atlas-architecture" data-testid="atlas-architecture" data-system-view={systemView} aria-label={text.title} aria-busy={!systemView && loading}><nav className="atlas-arch-tabs" aria-label={text.navigation}>{ARCHITECTURE_VIEWS.map(view =><button className="atlas-arch-tab" key={view} aria-pressed={config.view === view || (view === 'overview' && ['dependencies', 'entryPoints'].includes(config.view))} data-view={view}onClick={() => { if (view !== config.view) onSelectionEvidence?.(undefined); setConfig(current => ({ ...current, view })); }}>{text.views[view]}</button>)}</nav>{systemView && projectName ? <Suspense fallback={<div role="status"><Empty>Preparing system analysis…</Empty></div>}><SystemArchitecture- project={projectName} generation={graphGeneration} view={systemView} filter={config.filter} active={active}+ project={projectName} generation={graphGeneration} view={systemView} filter={filter} active={active}graph={graph} onSelect={onSelect} onClearSelection={onClearSelection} onSelectionEvidence={onSelectionEvidence} onNavigate={onNavigate} loader={systemArchitectureLoader} /></Suspense> : null}{!systemView && (!projectName ? <Empty>{text.chooseProject}</Empty> : loading ? <div role="status"><Empty>{text.loading}</Empty></div>: error ? <div role="alert" className="atlas-arch-empty" data-error="true"><p>{text.loadFailed}</p><p className="atlas-arch-error-detail">{error}</p>{onRefresh && <button className="atlas-arch-action" onClick={onRefresh}>{text.retry}</button>}</div>: !data ? <Empty>{text.unavailable}</Empty> : null)}{systemView && !projectName && <Empty>{text.chooseProject}</Empty>}+ {!systemView && ready && data && graph && config.view === 'routes' && <div className="atlas-arch-toolbar"><label className="atlas-arch-filter">+ <svg width="16" height="16" viewBox="0 0 16 16" aria-hidden="true"><circle cx="6.5" cy="6.5" r="4.5" fill="none" stroke="currentColor" strokeWidth="1.4" /><path d="m10 10 4 4" stroke="currentColor" strokeWidth="1.4" /></svg>+ <input aria-label={text.filter} placeholder={text.filterPlaceholder} type="search" value={config.filter} onChange={event => setFilter(event.target.value)} /></label></div>}{!systemView && ready && data && graph && <SpatialView project={projectName} generation={graphGeneration} graph={graph} overview={data}- view={config.view === 'dependencies' || config.view === 'structure' || config.view === 'behavior' ? 'overview' : config.view} filter={config.filter} active={active}+ view={config.view === 'dependencies' || config.view === 'structure' || config.view === 'behavior' ? 'overview' : config.view} filter={filter} onFilter={setFilter} active={active}graphNote={graphNote} coverage={coverage} onSelect={onSelect} onClearSelection={onClearSelection} onSelectionEvidence={onSelectionEvidence} selectionPanel={selectionPanel} onNavigate={onNavigate} onView={view => { onSelectionEvidence?.(undefined); setConfig(current => ({ ...current, view: view === 'dependencies' ? 'overview' : view })); }} />}{!systemView && ready && data && !graph && <div className="atlas-arch-content" data-testid="atlas-architecture-content"><p className="atlas-arch-fallback-summary">{data.files.length.toLocaleString()} files · {data.groups.length.toLocaleString()} source areas · {data.boundaries.length.toLocaleString()} cross-area connections</p>diff --git a/graph-ui/src/architecture/SpatialArchitecture.test.tsx b/graph-ui/src/architecture/SpatialArchitecture.test.tsxindex 426eac5ba..cca3662f2 100644--- a/graph-ui/src/architecture/SpatialArchitecture.test.tsx+++ b/graph-ui/src/architecture/SpatialArchitecture.test.tsx@@ -93,6 +93,21 @@ it('cancels a route request on generation change and ignores its late result', aexpect(host.textContent).not.toContain('STALE RESPONSE');expect(loadRouteGraph).toHaveBeenCalledTimes(2);});+it('groups endpoints, hides test routes by default and narrows a group through the filter', async () => {+ const route = (id: number, name: string, file_path: string): GraphNode => ({ id, label: 'Route', name, qualified_name: `sample.route.${id}`, file_path, x: 0, y: 0, z: 0, size: 1, color: '' });+ const input: GraphData = { nodes: [node, route(2, '/accounts/login/', 'app/urls.py'), route(3, '/accounts/logout/', 'app/urls.py'), route(4, '/fixture/', 'tests/urls.py')], edges: [], total_nodes: 4 };+ const onFilter = vi.fn();+ await act(async () => root.render(<SpatialArchitecture project="sample" graph={input} overview={overview} view="routes" filter="" active onNavigate={vi.fn()} onView={vi.fn()} onFilter={onFilter} />));+ const scene = () => [...host.querySelectorAll('[data-testid="scene"] [data-node]')].map(item => item.textContent);+ expect(scene()).toEqual(['/accounts · 2']);+ const toggle = [...host.querySelectorAll('label')].find(label => label.textContent?.startsWith('Include test routes'))!;+ expect(toggle.textContent).toBe('Include test routes (1 hidden)');+ await click('/accounts · 2'); await click('Show these 2 routes →');+ expect(onFilter).toHaveBeenCalledExactlyOnceWith('/accounts');+ await act(async () => toggle.querySelector('input')!.click());+ expect(scene()).toEqual(['/accounts · 2', '/fixture/']);+ expect(toggle.textContent).toBe('Include test routes');+});it('does not load route evidence while the workspace is hidden', async () => {await act(async () => root.render(<SpatialArchitecture project="sample" graph={graph} overview={overview} view="routes" filter="" active={false} onNavigate={vi.fn()} onView={vi.fn()} />));expect(loadRouteGraph).not.toHaveBeenCalled();diff --git a/graph-ui/src/architecture/SpatialArchitecture.tsx b/graph-ui/src/architecture/SpatialArchitecture.tsxindex 1557f3d7c..9eb1694b4 100644--- a/graph-ui/src/architecture/SpatialArchitecture.tsx+++ b/graph-ui/src/architecture/SpatialArchitecture.tsx@@ -6,6 +6,7 @@ import { ArchitectureScene } from './ArchitectureScene';import { buildSemanticGraph, semanticEntryPoints, type SemanticNode, type SemanticView } from './semantic-graph';import { loadRouteGraph, type RouteGraphSnapshot } from './route-graph-source';import { areaLevels } from './repository-map';+import { architectureText as text } from './strings';import { collectSourceMetrics, measureSourceNode } from './source-metrics';import SourceMetricsDetails from './SourceMetricsDetails';import type { CoverageIndex } from '../app/tree-model';@@ -20,6 +21,8 @@ interface Props {onSelect?: (node: GraphNode) => void; onClearSelection?: () => void; selectionPanel?: ReactNode;onSelectionEvidence?: SelectionEvidenceListener;onView: (view: SemanticView) => void;+ /** Routes view: narrows the endpoints, for example to the routes of one group. */+ onFilter?: (filter: string) => void;onNavigate: (path: string, line?: number, name?: string) => void;coverage?: CoverageIndex;}@@ -41,7 +44,7 @@ const viewNotes: Record<SemanticView, string> = {};const relationKinds = ['CALLS', 'IMPORTS', 'USAGE', 'INHERITS', 'IMPLEMENTS', 'DATA_FLOWS'];-export default function SpatialArchitecture({ project, generation, graph, overview, view, filter, active, graphNote, onSelect, onClearSelection, onSelectionEvidence, selectionPanel, onNavigate, onView, coverage }: Props) {+export default function SpatialArchitecture({ project, generation, graph, overview, view, filter, active, graphNote, onSelect, onClearSelection, onSelectionEvidence, selectionPanel, onNavigate, onView, onFilter, coverage }: Props) {const [areaPath, setAreaPath] = useState<string>();const [filePath, setFilePath] = useState<string>();const [entryChoice, setEntryChoice] = useState<{ node: GraphNode; generation?: string }>();@@ -57,6 +60,7 @@ export default function SpatialArchitecture({ project, generation, graph, overviconst [routeReading, setRouteReading] = useState<{ key: string; snapshot?: RouteGraphSnapshot; error?: string }>();const [routeRevision, setRouteRevision] = useState(0);const [memberLimit, setMemberLimit] = useState(5);+ const [includeTestRoutes, setIncludeTestRoutes] = useState(false);useEffect(() => { setHotspotArea(undefined); }, [project, generation]);const routeKey = `${project}:${generation ?? ''}:${routeRevision}`;useEffect(() => {@@ -86,8 +90,8 @@ export default function SpatialArchitecture({ project, generation, graph, overviconst focusedHotspots = useMemo(() => hotspotArea ? collectHotspots(hotspotCatalog.byArea.get(hotspotArea)?.findings ?? [], graph) : hotspotCatalog, [hotspotArea, hotspotCatalog, graph]);const model = useMemo(() => view === 'hotspots' ? buildHotspotGraph(graph, focusedHotspots, filter) : buildSemanticGraph(graph, {view, areaPath, filePath, entryId: currentEntry?.id, entryQualifiedNames: overview.entryPoints.flatMap(entry => entry.qualifiedName ? [entry.qualifiedName] : []), depth, filter, relations,- routes: overview.routes, routeSnapshot, knownFiles: [...catalog.files.keys()], visibleFiles,- }), [graph, view, areaPath, filePath, currentEntry?.id, depth, filter, relations, overview.routes, overview.entryPoints, routeSnapshot, catalog, visibleFiles, focusedHotspots]);+ routes: overview.routes, routeSnapshot, knownFiles: [...catalog.files.keys()], visibleFiles, groupRoutes: true, hideTestRoutes: !includeTestRoutes,+ }), [graph, view, areaPath, filePath, currentEntry?.id, depth, filter, relations, overview.routes, overview.entryPoints, routeSnapshot, catalog, visibleFiles, focusedHotspots, includeTestRoutes]);const hasSourceBricks = model.nodes.some(node => node.kind === 'area' || node.kind === 'file');const scope = `${project}:${generation ?? ''}:${model.scopeKey}:${view}:${filter}:${hotspotArea ?? ''}`;const selectedNode = selection?.scope === scope ? model.nodes.find(node => node.id === selection.node) : undefined;@@ -147,6 +151,7 @@ export default function SpatialArchitecture({ project, generation, graph, overvi</select></label><label>Call depth <select aria-label="Call depth" value={depth} onChange={event => setDepth(Number(event.target.value))}>{[1, 2, 3, 4].map(value => <option key={value}>{value}</option>)}</select></label></>}{view === 'hotspots' && hotspotArea && <nav aria-label="Hotspot area"><button onClick={clearScope}>All hotspots</button><span>/ {hotspotArea}</span></nav>}{view === 'routes' && <button onClick={() => setRouteRevision(value => value + 1)}>Refresh connections</button>}+ {view === 'routes' && <label className="spatial-gravity-toggle"><input type="checkbox" checked={includeTestRoutes} onChange={event => { setIncludeTestRoutes(event.target.checked); setSelection(undefined); }} />{text.includeTestRoutes(model.hiddenRoutes ?? 0)}</label>}{filePath && (view === 'overview' || view === 'dependencies') && <button onClick={() => onNavigate(filePath, 1)}>Read this file</button>}{(view === 'overview' || view === 'dependencies') && <div className="spatial-relations" role="group" aria-label="Relationship types"><button aria-pressed={!relations.length} onClick={() => setRelations([])}>All</button>{relationKinds.map(type => <button key={type} aria-pressed={relations.includes(type)} onClick={() => setRelations(current => current.includes(type) ? current.filter(item => item !== type) : [...current, type])}>{type.replaceAll('_', ' ').toLowerCase()}</button>)}@@ -162,8 +167,8 @@ export default function SpatialArchitecture({ project, generation, graph, overvi<div className="spatial-map-layout"><div className="spatial-map"><SceneBoundary key={project}>{model.nodes.length ? <ArchitectureScene model={model} selectedId={selectedNode?.id} selectedEdgeId={selectedEdge?.id} onSelect={selectNode}- onSelectEdge={id => { setSelection({ scope, edge: id }); setMemberLimit(5); }} onOpen={id => { const node = nodesById.get(id); if (node && (node.kind === 'area' || node.kind === 'file')) openGroup(node); }} onClearSelection={clearScope} active={active} planar={planar} resetKey={resetKey} catalog={catalog} heightMetric={heightMetric} colorMetric={colorMetric} hotspots={hotspotCatalog} showHotspots={showHotspots}- adaptiveLabels={view === 'overview' || view === 'dependencies'} />+ onSelectEdge={id => { setSelection({ scope, edge: id }); setMemberLimit(5); }} onOpen={id => { const node = nodesById.get(id); if (node?.routePrefix) onFilter?.(node.routePrefix); else if (node && (node.kind === 'area' || node.kind === 'file')) openGroup(node); }} onClearSelection={clearScope} active={active} planar={planar} resetKey={resetKey} catalog={catalog} heightMetric={heightMetric} colorMetric={colorMetric} hotspots={hotspotCatalog} showHotspots={showHotspots}+ adaptiveLabels={view === 'overview' || view === 'dependencies' || view === 'routes'} />: <div className="spatial-unavailable">{filter ? 'No matching graph evidence. Try a broader filter.' : view === 'hotspots' ? 'No ranked hotspot measurements are available in this snapshot.' : view === 'entryPoints' ? 'No indexed entry points in this snapshot.' : view === 'routes' ? 'No endpoint evidence is available in this snapshot.' : filePath ? 'No indexed symbols in this file. Use “Read this file” to inspect its source.' : 'No source nodes are available in this repository snapshot.'}</div>}</SceneBoundary><div className="spatial-map-caption"><span title={model.positionMeaning}>{view === 'hotspots' ? 'Gravity: incoming references' : view === 'entryPoints' ? 'Static call paths' : 'Source folders and indexed relationships'}</span><span>Drag to orbit · scroll to zoom · select to inspect</span></div></div><aside className="spatial-inspector" aria-label="Architecture inspector">@@ -179,6 +184,7 @@ export default function SpatialArchitecture({ project, generation, graph, overvi{selectedMeasure && <details className="spatial-selection-details"><summary>{selectedMeasure.files.toLocaleString()} files · {selectedMeasure.lines?.toLocaleString() ?? "Unknown"} indexed lines</summary><SourceMetricsDetails measure={selectedMeasure} catalog={catalog} /></details>}{selectedHotspots && <details className="spatial-hotspot-details"><summary>{selectedHotspots.findings.length} hotspot findings · peak fan-in {selectedHotspots.maxFanIn ?? 'unknown'}</summary><p>Static incoming references, not runtime frequency.</p>{selectedHotspots.findings.slice(0, memberLimit).map(finding => <article key={hotspotIdentity(finding)}><button disabled={!finding.filePath} onClick={() => onNavigate(finding.filePath!, finding.line, finding.name)}>{finding.name}</button><div>{hotspotSignals(finding).map(signal => <span key={signal}>{signal}</span>)}</div></article>)}{selectedHotspots.findings.length > memberLimit && <button onClick={() => setMemberLimit(value => value + 16)}>More hotspot findings</button>}</details>}{(selectedNode.kind === 'area' || selectedNode.kind === 'file') && <button className="spatial-primary" onClick={() => openGroup(selectedNode)}>Open {selectedNode.kind === 'area' ? 'area' : 'file symbols'} →</button>}+ {selectedNode.routePrefix && onFilter && <button className="spatial-primary" onClick={() => onFilter(selectedNode.routePrefix!)}>{text.showRoutes(selectedNode.count)}</button>}{selectedNode.filePath && <button onClick={() => onNavigate(selectedNode.filePath!, selectedNode.line, selectedNode.label)}>Open source</button>}{!!selectedNode.members.length && <details className="spatial-selection-details"><summary>Source members · {selectedNode.members.length}</summary><div className="spatial-members">{selectedNode.members.slice(0, memberLimit).map(node => <button key={`${node.qualified_name}:${node.id}`} onClick={() => inspectMember(node)}>{node.name}<small>{node.file_path}{node.start_line ? `:${node.start_line}` : ''}</small></button>)}</div>{selectedNode.members.length > memberLimit && <button onClick={() => setMemberLimit(value => value + 16)}>More members</button>}</details>}diff --git a/graph-ui/src/architecture/semantic-graph.test.ts b/graph-ui/src/architecture/semantic-graph.test.tsindex d2e21f023..bca6c7f94 100644--- a/graph-ui/src/architecture/semantic-graph.test.ts+++ b/graph-ui/src/architecture/semantic-graph.test.ts@@ -315,6 +315,43 @@ describe('route identities and service evidence', () => {expect(model.edges).toHaveLength(0);expect(model.omittedNodes).toBe(1);});+ it('groups endpoints by their first path segment with counts and lists them again under a filter', () => {+ const routes = ['/accounts/login/', '/accounts/logout/', '/admin/', '/'].map((name, index) => ({ ...route, id: 300 + index, name, qualified_name: `fixture.route.${index}` }));+ const caller = node(1, 'services/gateway/client.ts', 'request');+ const graph: GraphData = { nodes: [caller, ...routes], edges: [], total_nodes: 5 };+ const routeSnapshot = { truncated: false, warnings: [], relationships: routes.map(target => ({ source: caller, target, type: 'HTTP_CALLS' as const })) };+ const model = buildSemanticGraph(graph, { view: 'routes', groupRoutes: true, routeSnapshot });+ expect(model.nodes.filter(item => item.kind === 'route').map(item => item.label).sort()).toEqual(['/', '/accounts · 2', '/admin/']);+ const group = model.nodes.find(item => item.routePrefix === '/accounts')!;+ expect(group).toMatchObject({ id: 'route-group:/accounts', count: 2, kindLabel: 'Route group' });+ expect(group.members.map(item => item.name)).toEqual(['/accounts/login/', '/accounts/logout/']);+ const calls = model.edges.find(edge => edge.target === group.id)!;+ expect(calls).toMatchObject({ source: 'caller-area:services/gateway', type: 'HTTP_CALLS', count: 2 });+ expect(calls.evidence.map(item => item.target)).toEqual([routes[0], routes[1]]);+ expect(buildSemanticGraph({ ...graph, nodes: [...graph.nodes].reverse() }, { view: 'routes', groupRoutes: true, routeSnapshot })).toEqual(model);+ const filtered = buildSemanticGraph(graph, { view: 'routes', groupRoutes: true, filter: '/accounts', routeSnapshot });+ expect(filtered.nodes.filter(item => item.kind === 'route').map(item => item.label)).toEqual(['/accounts/login/', '/accounts/logout/']);+ });+ it('hides routes whose evidence lies only in test code and keeps test callers of other routes', () => {+ const testCaller = node(2, 'tests/admin_views/tests.py', 'test_login');+ const handler = node(3, 'django/contrib/admin/actions.py', 'delete_selected');+ const testOnly = { ...route, id: 310, name: '/malformed_post/', qualified_name: 'fixture.route.test' };+ const shared = { ...route, id: 311, name: '/{pk}/delete_selected', qualified_name: 'fixture.route.admin' };+ const graph: GraphData = { nodes: [testCaller, handler, testOnly, shared], edges: [], total_nodes: 4 };+ const options = { view: 'routes' as const, routes: [{ method: 'GET', path: '/fixture/', filePath: 'tests/urls.py', line: 3, origin: 'source' as const },+ { method: 'GET', path: '/shop/', filePath: 'shop/urls.py', line: 4, origin: 'source' as const }],+ routeSnapshot: { truncated: false, warnings: [], relationships: [+ { source: testCaller, target: testOnly, type: 'HTTP_CALLS' as const }, { source: testCaller, target: shared, type: 'HTTP_CALLS' as const },+ { source: handler, target: shared, type: 'HANDLES' as const }] } };+ const all = buildSemanticGraph(graph, options);+ expect(all.nodes.filter(item => item.kind === 'route')).toHaveLength(4);+ expect(all.hiddenRoutes).toBe(0);+ const shown = buildSemanticGraph(graph, { ...options, hideTestRoutes: true });+ expect(shown.nodes.filter(item => item.kind === 'route').map(item => item.label).sort()).toEqual(['/{pk}/delete_selected', 'GET /shop/']);+ expect(shown.hiddenRoutes).toBe(2);+ expect(shown.edges.map(edge => [edge.source, edge.type])).toEqual([['caller-area:tests', 'HTTP_CALLS'], ['handler-area:django', 'HANDLES']]);+ expect(buildSemanticGraph(graph, { view: 'overview' }).hiddenRoutes).toBeUndefined();+ });it('packs large route lanes into compact deterministic bands without overlap', () => {const routes = Array.from({ length: 35 }, (_, id) => ({ ...route, id: 100 + id, name: `/api/${id}`, qualified_name: `fixture.route.${id}` }));const caller = node(1, 'services/gateway/client.ts', 'request');diff --git a/graph-ui/src/architecture/semantic-graph.ts b/graph-ui/src/architecture/semantic-graph.tsindex f576d4dfb..fb9223b38 100644--- a/graph-ui/src/architecture/semantic-graph.ts+++ b/graph-ui/src/architecture/semantic-graph.ts@@ -24,6 +24,8 @@ export interface SemanticNode {kindLabel?: string;/** An area outside the opened area or file; it keeps to its own lane. */external?: boolean;+ /** The first path segment shared by the routes of a route group. */+ routePrefix?: string;}export interface SemanticEvidence {source: GraphNode;@@ -68,6 +70,8 @@ export interface SemanticGraph {omittedNodes: number;omittedEdges: number;warnings: string[];+ /** Routes view only: routes left out because all of their evidence lies in test code. */+ hiddenRoutes?: number;}export interface SemanticGraphOptions {view: SemanticView;@@ -85,12 +89,18 @@ export interface SemanticGraphOptions {/** File inventory is independent of the dependency graph and its row cap. */knownFiles?: string[];visibleFiles?: ReadonlySet<string>;+ /** Routes view: fold routes sharing a first path segment into one counted group while no filter is set. */+ groupRoutes?: boolean;+ /** Routes view: leave out routes whose registration, handlers and callers all lie in test code. */+ hideTestRoutes?: boolean;}const compare = (a: string, b: string) => a < b ? -1 : a > b ? 1 : 0;const identity = (node: GraphNode) => `${node.label}:${node.qualified_name || `#${node.id}`}@${node.file_path ?? ''}`;const nodeOrder = (a: GraphNode, b: GraphNode) => compare(identity(a), identity(b));const symbolId = (node: GraphNode) => `symbol:${identity(node)}`;+/** Conventional test locations: a test directory, or a test_*, tests.*, *_test, *.test or *.spec file. */+const TEST_SOURCE = /(^|\/)(tests?|__tests__|specs?)\/|(^|\/)(test_[^/]*|tests?\.[^/.]+|[^/]+[._-](test|spec)\.[^/.]+)$/i;const sourceNode = (node: GraphNode) => Boolean(node.file_path && node.file_path !== '{}'&& !['Project', 'Folder', 'Package', 'Branch', 'Route'].includes(node.label));const symbolNode = (node: GraphNode): SemanticNode => ({ id: symbolId(node),@@ -292,6 +302,7 @@ export function buildSemanticGraph(graph: GraphData, options: SemanticGraphOptiolet positionMeaning = 'Nested platforms follow source folders; areas outside the opened one wait in their own lane. Boxes represent source grouping, not deployed services.';const depth = bounded(options.depth, 3, 8);let rootId: string | undefined;+ let hiddenRoutes = 0;if (options.view === 'entryPoints') {const entries = semanticEntryPoints(graph, options.entryQualifiedNames);@@ -325,11 +336,31 @@ export function buildSemanticGraph(graph: GraphData, options: SemanticGraphOptiopositionMeaning = 'Left to right: shortest static call distance from the entry point. This is possible reachability, not runtime execution order.';} else if (options.view === 'routes') {const currentByIdentity = new Map(graph.nodes.map(node => [identity(node), node]));- const routeEvidence = evidence.filter(edge => ['HTTP_CALLS', 'ASYNC_CALLS', 'HANDLES'].includes(edge.type));+ const recorded = evidence.filter(edge => ['HTTP_CALLS', 'ASYNC_CALLS', 'HANDLES'].includes(edge.type));for (const relationship of options.routeSnapshot?.relationships ?? []) {const remap = (node: GraphNode) => node.qualified_name ? currentByIdentity.get(identity(node)) ?? node : node;- routeEvidence.push({ ...relationship, source: remap(relationship.source), target: remap(relationship.target) });+ recorded.push({ ...relationship, source: remap(relationship.source), target: remap(relationship.target) });}+ // A route is test code only when every located piece of its evidence is:+ // its own registration, its handlers and its callers.+ const verdicts = new Map<string, boolean[]>();+ const record = (route: GraphNode, node: GraphNode) => {+ const file = node.file_path && !['{}', '-'].includes(node.file_path) ? node.file_path : undefined;+ if (!file && node.status !== 'test') return;+ const list = verdicts.get(identity(route)) ?? []; list.push(node.status === 'test' || TEST_SOURCE.test(file!)); verdicts.set(identity(route), list);+ };+ for (const node of graph.nodes) if (node.label === 'Route') record(node, node);+ for (const edge of recorded) {+ const route = edge.target.label === 'Route' ? edge.target : edge.source.label === 'Route' ? edge.source : undefined;+ if (route) { record(route, route); record(route, route === edge.target ? edge.source : edge.target); }+ }+ const hidden = new Set<string>();+ const shown = (route: GraphNode) => {+ const list = verdicts.get(identity(route));+ if (!options.hideTestRoutes || !list?.length || !list.every(Boolean)) return true;+ hidden.add(identity(route)); return false;+ };+ const routeEvidence = recorded.filter(edge => [edge.source, edge.target].every(node => node.label !== 'Route' || shown(node)));const routeNodes = new Map<string, SemanticNode>();const currentNodes = new Set(graph.nodes);const routeKey = (node: GraphNode, edge?: SemanticEvidence): string => {@@ -354,7 +385,7 @@ export function buildSemanticGraph(graph: GraphData, options: SemanticGraphOptioreturn id;};edges = aggregate(routeEvidence, (node, edge) => routeKey(node, edge));- for (const node of graph.nodes.filter(node => node.label === 'Route')) routeKey(node);+ for (const node of graph.nodes.filter(node => node.label === 'Route' && shown(node))) routeKey(node);for (const route of options.routes ?? []) {const alreadyRepresented = graph.nodes.some(node => node.label === 'Route'&& [route.path, `${route.method ?? ''} ${route.path}`.trim()].includes(node.name)@@ -363,10 +394,39 @@ export function buildSemanticGraph(graph: GraphData, options: SemanticGraphOptioif (alreadyRepresented) continue;// A textual registration is useful navigation, but cannot establish an edge or handler identity.const id = `registration:${route.method ?? ''}:${route.path}@${route.filePath ?? ''}:${route.line ?? ''}`;+ if (options.hideTestRoutes && route.filePath && TEST_SOURCE.test(route.filePath)) { hidden.add(id); continue; }routeNodes.set(id, { id, kind: 'route', label: `${route.method ? `${route.method} ` : ''}${route.path}`,detail: `${route.origin === 'source' ? 'Source' : 'Index'} registration · handler relationship not resolved`,position: [0, 0, 0], count: 1, filePath: route.filePath, line: route.line, members: [] });}+ hiddenRoutes = hidden.size;+ // Without a filter, routes sharing a first path segment become one counted+ // group; a filter lists the matching routes one by one again.+ const grouped = new Map<string, string>();+ if (options.groupRoutes && !options.filter?.trim()) {+ const prefixes = new Map<string, SemanticNode[]>();+ for (const node of routeNodes.values()) if (node.kind === 'route') {+ const prefix = `/${node.label.replace(/^[A-Z]+\s+/, '').split('/').filter(Boolean)[0] ?? ''}`;+ prefixes.set(prefix, [...prefixes.get(prefix) ?? [], node]);+ }+ for (const [prefix, routes] of prefixes) if (routes.length > 1) {+ const id = `route-group:${prefix}`;+ routeNodes.set(id, { id, kind: 'route', kindLabel: 'Route group', routePrefix: prefix, label: `${prefix} · ${routes.length}`,+ detail: `${routes.length} routes whose path starts with ${prefix}`, position: [0, 0, 0], count: routes.length,+ members: routes.flatMap(route => route.members) });+ for (const route of routes) { grouped.set(route.id, id); routeNodes.delete(route.id); }+ }+ }+ if (grouped.size) {+ const merged = new Map<string, SemanticEdge>();+ for (const edge of edges) {+ const source = grouped.get(edge.source) ?? edge.source, target = grouped.get(edge.target) ?? edge.target;+ const id = `${source}→${edge.type}→${target}`;+ const into = merged.get(id) ?? { ...edge, id, source, target, count: 0, evidence: [] };+ into.count += edge.count; into.evidence.push(...edge.evidence); merged.set(id, into);+ }+ edges = [...merged.values()].sort((a, b) => compare(a.id, b.id));+ }nodes = [...routeNodes.values()];for (const node of nodes) node.members.sort(nodeOrder);warnings.push(...options.routeSnapshot?.warnings ?? []);@@ -529,5 +589,5 @@ export function buildSemanticGraph(graph: GraphData, options: SemanticGraphOptioreturn { view: options.view, scopeKey: `${options.view}:${options.areaPath ?? ''}:${options.filePath ?? ''}:${rootId ?? ''}:${filter ?? ''}`,title, positionMeaning, nodes, ...(platforms ? { platforms: pruneHierarchyPlatforms(platforms, nodes) } : {}),edges, totalNodes, totalEdges, omittedNodes: totalNodes - nodes.length,- omittedEdges: totalEdges - edges.length, warnings: [...new Set(warnings)] };+ omittedEdges: totalEdges - edges.length, warnings: [...new Set(warnings)], ...(options.view === 'routes' ? { hiddenRoutes } : {}) };}diff --git a/graph-ui/src/architecture/strings.ts b/graph-ui/src/architecture/strings.tsindex b084f0405..dca30f920 100644--- a/graph-ui/src/architecture/strings.ts+++ b/graph-ui/src/architecture/strings.ts@@ -78,4 +78,6 @@ export const architectureText = {projectionLimited: 'The analysis returned no system structure for this project.',projectionEmpty: 'No component projection is available within this analysis budget.',behaviorLimited: 'The analysis returned no call evidence.',+ includeTestRoutes: (hidden: number) => hidden ? `Include test routes (${hidden.toLocaleString()} hidden)` : 'Include test routes',+ showRoutes: (count: number) => `Show these ${count.toLocaleString()} routes →`,};