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
fix(ui): count the parts outside an opened area in its card (K7)
Bernhard Jackiewicz83c62200fc86
diff --git a/graph-ui/src/architecture/SpatialArchitecture.evidence.test.tsx b/graph-ui/src/architecture/SpatialArchitecture.evidence.test.tsxindex b5ccfadd0..c5d2dd088 100644--- a/graph-ui/src/architecture/SpatialArchitecture.evidence.test.tsx+++ b/graph-ui/src/architecture/SpatialArchitecture.evidence.test.tsx@@ -54,6 +54,7 @@ it('explains an opened area with nothing selected from its files, lines, languagconst text = facts.join('\n');expect(facts[0]).toBe('Opened source area: `django`.');expect(text).toContain('2,420 indexed lines in 3 measured files of 3; files by language: Python 3.');+ expect(evidence.scope.visibleNodes).toBe(3);expect(text).toContain('Parts shown (3, largest first): `db` (area, 1 file, 2,000 indexed lines), `contrib` (area, 1 file, 300 indexed lines), `shortcuts.py` (file, 120 indexed lines).');expect(text).toContain('1 hotspot finding: `filter` (`django/db/models/query.py:1487`) fan-in 1,224.');expect(text).not.toContain('`setup`');@@ -68,9 +69,13 @@ it('names the areas outside the opened area as outside in its connections', asynawait act(async () => root.render(<SpatialArchitecture project="sample" generation="g1" graph={outside} overview={overview} view="overview" filter="" activeonSelectionEvidence={onSelectionEvidence} onNavigate={vi.fn()} onView={vi.fn()} />));await click('django'); await click('Open area →');- const text = (architectureFacts(JSON.parse(onSelectionEvidence.mock.lastCall![0].text).evidence)?.facts ?? []).join('\n');+ const evidence = JSON.parse(onSelectionEvidence.mock.lastCall![0].text).evidence;+ const text = (architectureFacts(evidence)?.facts ?? []).join('\n');expect(text).toMatch(/`\(root\)` \(outside\) → `shortcuts\.py`: IMPORTS ×1/);- expect(text).not.toMatch(/Parts shown[^\n]*\(root\)/);+ // The card counts the parts the view counts: the ones inside the area and the ones outside it, each named as such.+ expect(evidence.scope.visibleNodes).toBe(4);+ expect(text).toContain('Parts shown (4): 3 inside the area, largest first: `db` (area, 1 file, 2,000 indexed lines), `contrib` (area, 1 file, 300 indexed lines), '+ + '`shortcuts.py` (file, 120 indexed lines); 1 outside it: `(root)`.');});it('names the hotspot findings of an opened hotspot area', async () => {diff --git a/graph-ui/src/architecture/SpatialArchitecture.tsx b/graph-ui/src/architecture/SpatialArchitecture.tsxindex 7d1c34e2c..ac2f0377e 100644--- a/graph-ui/src/architecture/SpatialArchitecture.tsx+++ b/graph-ui/src/architecture/SpatialArchitecture.tsx@@ -134,11 +134,12 @@ export default function SpatialArchitecture({ project, generation, graph, overvi.map(node => ({ node, measure: measureSourceNode(node, catalog) })).sort((a, b) => a.node.kind !== b.node.kind ? a.node.kind === 'area' ? -1 : 1 : (b.measure?.lines ?? -1) - (a.measure?.lines ?? -1) || (a.node.label < b.node.label ? -1 : 1));const links = [...model.edges].sort((a, b) => b.count - a.count);+ const outside = model.nodes.filter(node => node.external);return {selected: { areaPath, filePath, hotspotArea, measurement: openedScope?.measure,hotspots: hotspotArea ? hotspotCatalog.byArea.get(hotspotArea) : filePath ? hotspotsForNode(scopeNode('file', filePath), hotspotCatalog) : areaPath ? hotspotsForNode(scopeNode('area', areaPath), hotspotCatalog) : undefined,parts: hotspotArea ? [] : parts.slice(0, 24).map(({ node, measure }) => ({ kind: node.kind, label: node.label, files: measure?.files, lines: measure?.lines })),- partCount: hotspotArea ? 0 : parts.length, outside: hotspotArea ? [] : model.nodes.filter(node => node.external).slice(0, 24).map(node => node.label) },+ partCount: hotspotArea ? 0 : parts.length, outside: hotspotArea ? [] : outside.slice(0, 24).map(node => node.label), outsideCount: hotspotArea ? 0 : outside.length },relationships: hotspotArea ? undefined : { count: links.length, items: links.slice(0, 24).map(edge => ({ source: nodesById.get(edge.source)?.label ?? edge.source,target: nodesById.get(edge.target)?.label ?? edge.target, type: edge.type, count: edge.count })), omitted: Math.max(0, links.length - 24) },};diff --git a/graph-ui/src/browser-ai/architecture-evidence.ts b/graph-ui/src/browser-ai/architecture-evidence.tsindex b0f39dfc1..8bce2d240 100644--- a/graph-ui/src/browser-ai/architecture-evidence.ts+++ b/graph-ui/src/browser-ai/architecture-evidence.ts@@ -90,9 +90,12 @@ function openedFacts(selected: Row, relationships: Row | undefined): Architecturconst label = text(item.label, 160), kind = text(item.kind, 20);return label && (kind === 'area' || kind === 'file') ? [words.scopePart(quote(label), kind, kind === 'area' ? count(item.files) : undefined, count(item.lines))] : [];});- if (parts.length) facts.push(words.parts(parts, Math.max(count(selected.partCount) ?? 0, parts.length)));- facts.push(...hotspotFacts(record(selected.hotspots)));const outside = new Set((Array.isArray(selected.outside) ? selected.outside : []).flatMap(name => text(name, 120) ?? []));+ // The view counts the parts outside the opened scope with the ones inside it, so the card does too.+ const outsideTotal = Math.max(count(selected.outsideCount) ?? 0, outside.size);+ if (parts.length || outside.size) facts.push(words.parts(parts, Math.max(count(selected.partCount) ?? 0, parts.length), file ? 'file' : 'area',+ [...outside].map(quote), outsideTotal));+ facts.push(...hotspotFacts(record(selected.hotspots)));const described = connectionLines(rows(relationships?.items), undefined, outside);if (described.length) facts.push(words.partConnections(described, count(relationships?.omitted) ?? 0));return { facts };diff --git a/graph-ui/src/browser-ai/strings.ts b/graph-ui/src/browser-ai/strings.tsindex bd5337208..4923a5608 100644--- a/graph-ui/src/browser-ai/strings.ts+++ b/graph-ui/src/browser-ai/strings.ts@@ -201,7 +201,13 @@ export const architectureWords = {openedHotspots: (path: string) => `Opened hotspot area: ${path}.`,scopePart: (name: string, kind: string, files?: number, lines?: number) =>`${name} (${kind}${files !== undefined ? `, ${plural(files, 'file', 'files')}` : ''}${lines !== undefined ? `, ${plural(lines, 'indexed line', 'indexed lines')}` : ''})`,- parts: (items: readonly string[], total: number) => `Parts shown (${count(total)}, largest first): ${items.join(', ')}${total > items.length ? `; ${count(total - items.length)} more` : ''}.`,+ /** The parts a view shows of an opened area or file: the ones inside it, largest first, and the ones outside it. */+ parts: (items: readonly string[], total: number, scope: 'area' | 'file' = 'area', outside: readonly string[] = [], outsideTotal = outside.length) => {+ const more = (listed: readonly string[], all: number) => all > listed.length ? `, +${count(all - listed.length)} more` : '';+ if (!outsideTotal) return `Parts shown (${count(total)}, largest first): ${items.join(', ')}${total > items.length ? `; ${count(total - items.length)} more` : ''}.`;+ const inside = total ? `${count(total)} inside the ${scope}, largest first: ${items.join(', ')}${more(items, total)}; ` : '';+ return `Parts shown (${count(total + outsideTotal)}): ${inside}${count(outsideTotal)} outside it: ${outside.join(', ')}${more(outside, outsideTotal)}.`;+ },outside: (name: string) => `${name} (outside)`,partConnections: (described: readonly string[], omitted: number) => `Connections of its parts: ${described.join('; ')}${omitted ? `; ${plural(omitted, 'more connection', 'more connections')} not listed` : ''}.`,measured: (lines: number, measured: number, files: number, languages: readonly string[]) =>