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): write the Architecture card plainly and with one number format
Bernhard Jackiewicz15557654cf32
diff --git a/graph-ui/src/browser-ai/BrowserChatDock.test.tsx b/graph-ui/src/browser-ai/BrowserChatDock.test.tsxindex d5d3faebd..0182b070a 100644--- a/graph-ui/src/browser-ai/BrowserChatDock.test.tsx+++ b/graph-ui/src/browser-ai/BrowserChatDock.test.tsx@@ -1515,13 +1515,13 @@ describe('grounded automatic explanations (K14, K7)', () => {await render({ ...props, proactive: true, selectionScope: 'django-demo:architecture', proactiveSelection: djangoAreaEvidence(), readSource }); await click('Download & load'); await settle();expect(readSource).not.toHaveBeenCalled();expect(runtime.chat).not.toHaveBeenCalled();- expect(card().textContent).toContain('Selected source area: django (2310 files · 15299 indexed nodes).');+ expect(card().textContent).toContain('Selected source area: django (2,310 files · 15,299 indexed nodes).');expect(card().textContent).toMatch(/Connections to \(root\): CALLS ×1,743/);expect(card().textContent).not.toMatch(/Finding a|Selected\.|members\[\d+\]|startLine/);// A question about the area gets the same readable facts.await type('What is in this area?'); await click('Send ↑');const prompt = runtime.chat.mock.calls[0][0].map(message => message.content).join('\n');- expect(prompt).toContain('Selected source area: `django` (2310 files · 15299 indexed nodes).');+ expect(prompt).toContain('Selected source area: `django` (2,310 files · 15,299 indexed nodes).');expect(prompt).not.toMatch(/Selected\.|members\[\d+\]|startLine/);});});diff --git a/graph-ui/src/browser-ai/BrowserChatDock.tsx b/graph-ui/src/browser-ai/BrowserChatDock.tsxindex 2c89d02e6..b5d77ad9e 100644--- a/graph-ui/src/browser-ai/BrowserChatDock.tsx+++ b/graph-ui/src/browser-ai/BrowserChatDock.tsx@@ -10,7 +10,7 @@ import { AUTO_INPUT_TOKENS, AUTO_OUTPUT_TOKENS, citedInterpretation, explanationimport { carriedSource, selectionSubject, SYMBOL_SOURCE_LINES, sourceTargetOf, symbolSource, type SymbolSourceReader } from './symbol-source';import { relationshipAnswer, relationshipSuggestion } from './relationship-answer';import { clampTokenLimits, tokenLimitBounds, tokenLimitsFor, useAgentPreferences, type TokenLimits } from './agent-preferences';-import { browserChatText, groundedText, relationshipWords, topicText } from './strings';+import { browserChatText, evidenceNote, groundedText, relationshipWords, topicText } from './strings';import { isGpuRuntimeFailure, BrowserRuntimeFatalError } from './runtime-fault';import ChatMarkdown from './ChatMarkdown';import AgentSettingsDialog from './AgentSettingsDialog';@@ -133,11 +133,11 @@ function AnswerNotes({ shortened, packet, model, historyOmitted, unsupported = [/** `codeOnly` where the listed facts already stand above it, in the explanation card. The* source does not push the first graph facts out: a listed answer shows both (K14). */-function PacketSource({ packet, citation, codeOnly = false }: { packet: PreparedExplanationContext; citation?: ReturnType<typeof citedInterpretation>; codeOnly?: boolean }): JSX.Element {+function PacketSource({ packet, citation, codeOnly = false, language = 'en' }: { packet: PreparedExplanationContext; citation?: ReturnType<typeof citedInterpretation>; codeOnly?: boolean; language?: 'en' | 'de' }): JSX.Element {const code = packet.evidence.filter(item => item.source === 'code').slice(0, 3);const facts = codeOnly ? [] : packet.evidence.filter(item => item.source !== 'code').slice(0, 3);return <>- {packet.limitations.map((limit, index) => <p className="cbm-chat-evidence-note" key={index}>{limit}</p>)}+ {packet.limitations.map((limit, index) => <p className="cbm-chat-evidence-note" key={index}>{evidenceNote(limit, language)}</p>)}{citation ? <pre>{citation.quote}</pre> : [...code, ...facts].map(item => <div key={item.id}>{item.location && <small>{item.location.path}:{item.location.startLine}-{item.location.endLine}</small>}<pre>{item.text}</pre></div>)}@@ -886,7 +886,7 @@ export default function BrowserChatDock({ proactiveSelection, selectionScope = "<div className="cbm-chat-question"><span className="cbm-chat-speaker">You</span><ChatMarkdown text={turn.prompt} /></div><div className="cbm-chat-answer"><SourceDisclosure>{turn.evidence || turn.attachment || turn.readerContext?.source || turn.context?.length ? <>- {turn.evidence ? <PacketSource packet={turn.evidence} /> : <>+ {turn.evidence ? <PacketSource packet={turn.evidence} language={turn.replyLanguage ?? questionLanguage(turn.prompt)} /> : <>{turn.attachment && <Attachment attachment={turn.attachment} />}{turn.readerContext?.source && <><Attachment attachment={turn.readerContext.source} label={turn.readerContext.source.kind === 'selection' ? 'Selection snapshot' : 'File snapshot'} />{turn.readerContext.source.partial && <p className="cbm-chat-evidence-note">{turn.readerContext.source.partial}</p>}</>}</>}diff --git a/graph-ui/src/browser-ai/BrowserChatDock.wording.test.tsx b/graph-ui/src/browser-ai/BrowserChatDock.wording.test.tsxindex b9204b1b9..f38c9dd9a 100644--- a/graph-ui/src/browser-ai/BrowserChatDock.wording.test.tsx+++ b/graph-ui/src/browser-ai/BrowserChatDock.wording.test.tsx@@ -177,3 +177,16 @@ describe('the topic divider in the language of its turn (W8)', () => {'New topic: tox.ini. Earlier messages are not sent with these questions.']);});});++describe('the Source block of an answer in its language (W10)', () => {+ it('says plainly where the relationships come from, in German under a German answer', async () => {+ const { props } = fixture();+ await render({ ...props, proactiveSelection: jsonbAggEvidence() }); await load();+ await ask('Wer ruft JSONBAgg auf?');+ const source = () => last().querySelector('.cbm-chat-source-content')?.textContent ?? '';+ expect(source()).toContain('Die Beziehungen hier wurden aus dem Code gelesen; sie zeigen nicht, was zur Laufzeit ausgeführt wird.');+ expect(source()).not.toContain('Static graph relationships');+ await ask('Who calls JSONBAgg?');+ expect(source()).toContain('The relationships here come from reading the code; they do not show what runs at runtime.');+ });+});diff --git a/graph-ui/src/browser-ai/architecture-evidence.ts b/graph-ui/src/browser-ai/architecture-evidence.tsindex 8bce2d240..f88575064 100644--- a/graph-ui/src/browser-ai/architecture-evidence.ts+++ b/graph-ui/src/browser-ai/architecture-evidence.ts@@ -24,6 +24,9 @@ function text(value: unknown, limit = 160): string | undefined {const count = (value: unknown): number | undefined => typeof value === 'number' && Number.isFinite(value) && value >= 0 ? value : undefined;const number = (value: number) => value.toLocaleString('en-US');const quote = (value: string) => `\`${value.replace(/`/g, "'")}\``;+/** Counts in a view's own detail ("2310 files · 15299 indexed nodes") written as the card writes them;+ * a line after a path ("query.py:1487") stays as it is (W10). */+const grouped = (detail: string | undefined) => detail?.replace(/(?<![\w:.,-])\d{4,}(?![\w.,:-])/g, digits => number(Number(digits)));const lines = (start: unknown, end: unknown) => {const first = count(start), last = count(end);return first ? `:${first}${last && last !== first ? `-${last}` : ''}` : '';@@ -47,9 +50,11 @@ function names(items: Row[], limit: number, total?: number): string {return `${listed.join(', ')}${more ? `; ${words.more(more)}` : ''}`;}-/** The measured lines and languages of an area or file. */+/** The measured lines and languages of an area or file; languages by files, largest first, Unknown last (W10). */function measuredFacts(measure: Row | undefined): string[] {- const languages = rows(measure?.languages).flatMap(item => { const name = text(item.name, 40), files = count(item.files); return name && files ? [`${name} ${number(files)}`] : []; });+ const languages = rows(measure?.languages).flatMap(item => { const name = text(item.name, 40), files = count(item.files); return name && files ? [{ name, files }] : []; })+ .sort((left, right) => Number(left.name === 'Unknown') - Number(right.name === 'Unknown') || right.files - left.files)+ .map(item => `${item.name} ${number(item.files)}`);return measure && count(measure.lines) !== undefined ? [words.measured(count(measure.lines)!, count(measure.measuredFiles) ?? 0, count(measure.files) ?? 0, languages)] : [];}@@ -120,7 +125,7 @@ function spatialFacts(selected: Row, relationships: Row | undefined, scope: Rowconst members = rows(selected.members);const total = count(selected.memberCount) ?? members.length;const symbol = kind === 'symbol' ? symbolOf(members[0]) : undefined;- facts.push(kind === 'symbol' && symbol ? words.selectedSymbol(located(symbol)) : words.selected(words.kinds[kind as keyof typeof words.kinds] ?? kind, quote(label), text(selected.detail, 160)));+ facts.push(kind === 'symbol' && symbol ? words.selectedSymbol(located(symbol)) : words.selected(words.kinds[kind as keyof typeof words.kinds] ?? kind, quote(label), grouped(text(selected.detail, 160))));facts.push(...measuredFacts(record(selected.measurement)));facts.push(...hotspotFacts(record(selected.hotspots)));if (kind !== 'symbol' && members.length) facts.push(words.members(names(members, 8, total)));diff --git a/graph-ui/src/browser-ai/chat-wording.test.ts b/graph-ui/src/browser-ai/chat-wording.test.tsindex 0242b8454..d67e8d535 100644--- a/graph-ui/src/browser-ai/chat-wording.test.ts+++ b/graph-ui/src/browser-ai/chat-wording.test.ts@@ -6,7 +6,8 @@ import { readGalaxyEvidence } from './galaxy-evidence';import { jsonbAggEvidence, jsonbAggRenderLimited, largeFolderScope } from './galaxy-evidence.fixture';import { generalQuestion, noQuestionAnswer } from './question-intent';import { relationshipAnswer, relationshipQuestion, relationshipSuggestion } from './relationship-answer';-import { browserChatText, groundedText, relationshipWords, topicText } from './strings';+import { browserChatText, evidenceNote, groundedText, relationshipWords, topicText } from './strings';+import { djangoAreaEvidence } from './architecture-evidence.fixture';import { sourceTargetOf, symbolSource } from './symbol-source';/* Wording of the chat texts after the third review of the hand test (2026-10-04, W1 to W10). */@@ -277,3 +278,37 @@ describe('German wording and examples that fit the selection (W9)', () => {expect(relationshipWords.en.definer('Interface', 1, 'X')).toBe('the interface that defines X');});});++describe('the Architecture card (W10)', () => {+ const area = (languages?: { name: string; files: number }[]) => {+ const context = djangoAreaEvidence();+ if (!languages) return context;+ const parsed = JSON.parse(context.text);+ parsed.evidence.selected.measurement.languages = languages.map(item => ({ ...item, lines: item.files * 10, color: '#999' }));+ return { ...context, text: JSON.stringify(parsed) };+ };++ it('writes every number of the card the same way', () => {+ const facts = selectionSummary(area());+ expect(facts[0]).toBe('Selected source area: `django` (2,310 files · 15,299 indexed nodes).');+ // Line numbers after a path ("query.py:1487") are places, not counts.+ expect(facts.join('\n')).not.toMatch(/(?<!:)\b\d{4,}\b/);+ });++ it('lists the files by language largest first, with Unknown last', () => {+ expect(selectionSummary(area())[1]).toBe('528,578 indexed lines in 2,163 measured files of 2,310; files by language: Python 883, HTML 162, Unknown 1,227.');+ expect(selectionSummary(area([{ name: 'Unknown', files: 1227 }, { name: 'Python', files: 883 }, { name: 'CSS', files: 14 }, { name: 'HTML', files: 162 },+ { name: 'JavaScript', files: 22 }]))[1]).toContain('files by language: Python 883, HTML 162, JavaScript 22, CSS 14, Unknown 1,227.');+ });++ it('says plainly that the relationships come from reading the code', () => {+ for (const context of [area(), jsonbAggEvidence()]) {+ const limits = prepareExplanationContext(undefined, context, 3200).limitations;+ expect(limits).toContain('The relationships here come from reading the code; they do not show what runs at runtime.');+ expect(limits.join('\n')).not.toContain('Static graph relationships');+ }+ expect(evidenceNote('The relationships here come from reading the code; they do not show what runs at runtime.', 'de'))+ .toBe('Die Beziehungen hier wurden aus dem Code gelesen; sie zeigen nicht, was zur Laufzeit ausgeführt wird.');+ expect(evidenceNote('Source unavailable.', 'de')).toBe('Source unavailable.');+ });+});diff --git a/graph-ui/src/browser-ai/explanation-context.test.ts b/graph-ui/src/browser-ai/explanation-context.test.tsindex 08c3dadc5..c6a678b7a 100644--- a/graph-ui/src/browser-ai/explanation-context.test.ts+++ b/graph-ui/src/browser-ai/explanation-context.test.ts@@ -93,7 +93,7 @@ describe('bounded explanation evidence', () => {expect(text).toContain('104');expect(text).toContain('76');expect(text).toMatch(/omitted/);- expect(text).toMatch(/static/i);+ expect(text).toContain('come from reading the code; they do not show what runs at runtime');expect(prepared.characterCount).toBeLessThanOrEqual(4000);expect(prepared.fallback.length).toBeLessThanOrEqual(400);});diff --git a/graph-ui/src/browser-ai/explanation-context.ts b/graph-ui/src/browser-ai/explanation-context.tsindex 1346055ae..98ad85cfe 100644--- a/graph-ui/src/browser-ai/explanation-context.ts+++ b/graph-ui/src/browser-ai/explanation-context.ts@@ -1,6 +1,6 @@import { snapshotReaderContext, type BrowserChatContext, type BrowserChatReaderContext, type BrowserChatSource } from './chat-model';import { fairShares, readGalaxyEvidence, relationshipLine, scopeSentence, selectionSentence, sideLoaded, type GalaxyEvidence } from './galaxy-evidence';-import { relationshipWords } from './strings';+import { relationshipWords, staticGraphNote } from './strings';import { architectureFacts } from './architecture-evidence';import { readerFacts } from './file-facts';@@ -215,7 +215,7 @@ function galaxyFacts(galaxy: GalaxyEvidence): GraphPreparation {return {facts: [fixedFact(selectionSentence(galaxy, words).join('\n')), fixedFact(scopeSentence(galaxy, words)),relationshipFact(galaxy, 'incoming'), relationshipFact(galaxy, 'outgoing'), ...further ? [fixedFact(further)] : []],- limitations: ['Static graph relationships do not establish runtime execution or repository purpose.'],+ limitations: [staticGraphNote],scope: { nodes: galaxy.nodes, edges: galaxy.edges },};}@@ -230,7 +230,7 @@ function graphEvidence(context: BrowserChatContext): GraphPreparation {try { parsed = record(JSON.parse(context.text)); } catch { /* Report unsupported data below. */ }const evidence = record(parsed?.evidence);if (evidence?.kind !== 'current-selection-evidence') return { facts: [], limitations: ['Unsupported graph snapshot; graph facts unavailable.'] };- const limits = ['Static graph relationships do not establish runtime execution or repository purpose.'];+ const limits = [staticGraphNote];if (typeof evidence.source !== 'string' || !evidence.source || typeof evidence.project !== 'string'|| !evidence.project || typeof evidence.generation !== 'string' || !evidence.generation || evidence.generation === 'unavailable') {limits.push('Graph provenance or index generation unavailable; freshness is not established.');diff --git a/graph-ui/src/browser-ai/grounded-explanation.test.ts b/graph-ui/src/browser-ai/grounded-explanation.test.tsindex 0ffc76102..142bce722 100644--- a/graph-ui/src/browser-ai/grounded-explanation.test.ts+++ b/graph-ui/src/browser-ai/grounded-explanation.test.ts@@ -10,8 +10,8 @@ describe('Architecture selections as readable facts (K7)', () => {it('describes a source area in sentences, without field paths a model would list as "Finding a line number"', () => {const prompt = formatExplanationEvidence(prepareExplanationContext(undefined, djangoAreaEvidence(), 3200));expect(prompt).not.toMatch(/Selected\.|members\[\d+\]|startLine|Snapshot\.|qualifiedName|snapshot items|graph fields omitted/);- expect(prompt).toContain('Selected source area: `django` (2310 files · 15299 indexed nodes).');- expect(prompt).toContain('528,578 indexed lines in 2,163 measured files of 2,310; files by language: Unknown 1,227, Python 883, HTML 162.');+ expect(prompt).toContain('Selected source area: `django` (2,310 files · 15,299 indexed nodes).');+ expect(prompt).toContain('528,578 indexed lines in 2,163 measured files of 2,310; files by language: Python 883, HTML 162, Unknown 1,227.');expect(prompt).toContain('3 hotspot findings: `create` (`django/apps/config.py:100`) fan-in 1,278, `filter` (`django/db/models/query.py:1487`) fan-in 1,224');expect(prompt).toMatch(/Connections to \(root\): CALLS ×1,743/);expect(prompt).toContain('Indexed members include `Member0` (Class)');@@ -111,7 +111,7 @@ describe('the selected symbol source in a Galaxy explanation (K14)', () => {'Outgoing: 2 relationships to 2 symbols (INHERITS 2).','Scope: 1 hop in both directions, all relationship types; 15 symbols and 25 relationships; fully loaded.',]);- expect(selectionSummary(djangoAreaEvidence())[0]).toBe('Selected source area: `django` (2310 files · 15299 indexed nodes).');+ expect(selectionSummary(djangoAreaEvidence())[0]).toBe('Selected source area: `django` (2,310 files · 15,299 indexed nodes).');});it('says that a scope stopped at the render limit is partial, in the card and in the prompt (C1)', () => {diff --git a/graph-ui/src/browser-ai/strings.ts b/graph-ui/src/browser-ai/strings.tsindex c4508abb9..005720caa 100644--- a/graph-ui/src/browser-ai/strings.ts+++ b/graph-ui/src/browser-ai/strings.ts@@ -339,6 +339,16 @@ export const browserChatContextText = {},};+/** The notes of an ⓘ Source block in plain words (W10). The prompt reads them in English; an+ * answer shows them in its language. */+const evidenceNotes = {+ staticGraph: { en: 'The relationships here come from reading the code; they do not show what runs at runtime.',+ de: 'Die Beziehungen hier wurden aus dem Code gelesen; sie zeigen nicht, was zur Laufzeit ausgeführt wird.' },+};+export const staticGraphNote = evidenceNotes.staticGraph.en;+/** A known note in the language of the answer; any other note as it is. */+export const evidenceNote = (note: string, language: 'en' | 'de'): string => Object.values(evidenceNotes).find(item => item.en === note)?.[language] ?? note;+const count = (value: number) => value.toLocaleString('en-US');const plural = (value: number, one: string, many: string) => `${count(value)} ${value === 1 ? one : many}`;/** Architecture selections as sentences: for the prompt and for the explanation card. */