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): name Branch nodes for what they are and keep the ring note beside Explore
Bernhard Jackiewicz7ad29a1757f7
diff --git a/graph-ui/src/architecture/RepositoryMap.tsx b/graph-ui/src/architecture/RepositoryMap.tsxindex 8fd7d4f47..e0b973691 100644--- a/graph-ui/src/architecture/RepositoryMap.tsx+++ b/graph-ui/src/architecture/RepositoryMap.tsx@@ -1,5 +1,6 @@import { useEffect, useMemo, useRef, useState, type ReactNode } from 'react';import type { ArchitectureOverviewDto } from '../core/intelligence-provider';+import { graphNodeName } from '../galaxy/node-names';import type { GraphData, GraphNode } from '../galaxy/types';import { areaConnections, areaOf, repositoryMap, type MapEvidence } from './repository-map';import { entryCandidates, entryRole, entryRoutes, sourceCandidates, type SourceReader, type SourceQuote } from './repository-guide';@@ -21,7 +22,8 @@ function Nodes({ nodes, onSelect, onNavigate }: Pick<RepositoryMapProps, 'onSeleconst [limit, setLimit] = useState(24);return <><ul className="repo-map-nodes">{nodes.slice(0, limit).map(node => <li key={node.id}><button onClick={() => onSelect ? onSelect(node) : onNavigate(node.file_path!, node.start_line, node.name)}>- <strong>{node.name}</strong><span>{node.label} · {node.file_path}{node.start_line ? `:${node.start_line}` : ''}</span>+ {/* Round 4 (N1): a Branch node reads "django-demo · detached HEAD", not "DETACHED". */}+ <strong>{graphNodeName(node)}</strong><span>{node.label} · {node.file_path}{node.start_line ? `:${node.start_line}` : ''}</span></button></li>)}</ul>{nodes.length > limit && <button className="atlas-arch-action" onClick={() => setLimit(limit + 24)}>More symbols ({limit} of {nodes.length})</button>}</>;}diff --git a/graph-ui/src/browser-ai/chat-context.ts b/graph-ui/src/browser-ai/chat-context.tsindex 332a54ef7..c14bc9b53 100644--- a/graph-ui/src/browser-ai/chat-context.ts+++ b/graph-ui/src/browser-ai/chat-context.ts@@ -1,6 +1,6 @@import type { BrowserChatAttachment, BrowserChatContext, BrowserChatReaderContext, BrowserChatTurn } from './chat-model';-import { readGalaxyEvidence } from './galaxy-evidence';-import { browserChatContextText } from './strings';+import { readGalaxyEvidence, selectionName } from './galaxy-evidence';+import { browserChatContextText, relationshipWords } from './strings';/** What a question is about: the open file, the selected graph item, attached code or* attached context, within one project and view. Turns about another one are another@@ -14,7 +14,8 @@ export function chatTopic(scope: string, sources: { reader?: BrowserChatReaderCoif (graph) {// The selected item itself; depth, direction and edge types only redraw its scope.const galaxy = readGalaxyEvidence(graph.text);- return { kind: 'graph', label: galaxy?.label ?? graph.label, key: JSON.stringify([scope, 'graph', galaxy ? galaxy.identity : graph.label]) };+ // Named as the Galaxy names it, a Branch node "django-demo · detached HEAD" (round 4, N1); the key stays the identity.+ return { kind: 'graph', label: galaxy ? selectionName(galaxy, relationshipWords.en) : graph.label, key: JSON.stringify([scope, 'graph', galaxy ? galaxy.identity : graph.label]) };}if (attachment) return { kind: 'attachment', label: attachment.path, key: JSON.stringify([scope, 'attachment', attachment.path]) };if (context.length) return { kind: 'context', label: context.map(item => item.label).join(', '), key: JSON.stringify([scope, 'context', ...context.map(item => item.id)]) };diff --git a/graph-ui/src/browser-ai/galaxy-evidence.branch.test.ts b/graph-ui/src/browser-ai/galaxy-evidence.branch.test.tsnew file mode 100644index 000000000..d6acdcee8--- /dev/null+++ b/graph-ui/src/browser-ai/galaxy-evidence.branch.test.ts@@ -0,0 +1,59 @@+import { expect, it } from 'vitest';+import { galaxyScopeEvidence, selectionEvidenceContext } from '../galaxy/selection-evidence';+import type { GraphScope } from '../galaxy/graph-scope';+import type { GraphEdge, GraphNode } from '../galaxy/types';+import { chatTopic } from './chat-context';+import { readGalaxyEvidence, relationshipLine, selectionSentence } from './galaxy-evidence';+import { relationshipAnswer } from './relationship-answer';+import { relationshipWords } from './strings';++/*+ * Hand test 2026-10-04, round 4 (N1): the chat took the name of the Branch+ * node from the index, "DETACHED", and listed it beside .github as if it were+ * a folder. Its evidence and listed answers name it for what it is, in the+ * language of the answer. The snapshot keeps the names of the index, so the+ * chat still matches a typed "DETACHED" as before.+ */+const node = (id: number, extra: Partial<GraphNode>): GraphNode => ({ id, x: 0, y: 0, z: 0, size: 1, color: '#999', label: 'Folder', name: `n${id}`, ...extra });+const project = node(1, { label: 'Project', name: 'django-demo', qualified_name: 'django-demo' });+const branch = node(2, { label: 'Branch', name: 'DETACHED', qualified_name: 'django-demo.__branch__.detached' });+const github = node(4, { name: '.github', qualified_name: 'django-demo..github', file_path: '.github' });+const security = node(5, { label: 'File', name: 'SECURITY.md', qualified_name: 'django-demo..github.SECURITY.md.__file__', file_path: '.github/SECURITY.md' });+const edges: GraphEdge[] = [{ source: 1, target: 2, type: 'HAS_BRANCH' }, { source: 2, target: 4, type: 'CONTAINS_FOLDER' }, { source: 4, target: 5, type: 'CONTAINS_FILE' }];+const context = (root: GraphNode, identity: GraphScope) => selectionEvidenceContext(galaxyScopeEvidence({ project: 'django-demo', identity,+ nodes: [project, branch, github, security], edges, roots: new Set([root.id]), depth: 1, direction: 'both', edgeTypes: 'all', state: 'complete-indexed-scope', exhausted: false }));+const githubContext = () => context(github, { kind: 'node', id: 4, name: '.github', qualifiedName: 'django-demo..github' });+const branchContext = () => context(branch, { kind: 'node', id: 2, name: 'DETACHED', qualifiedName: 'django-demo.__branch__.detached' });++it('N1: the related Branch node of .github is listed by its shown name, in English and in German', () => {+ const evidence = readGalaxyEvidence(githubContext().text)!;+ const [group] = evidence.relationships.incoming;+ expect(relationshipLine(group!, 'incoming', Infinity, relationshipWords.en, true).text).toBe('- **CONTAINS_FOLDER (1):** `django-demo · detached HEAD` (Branch)');+ expect(relationshipLine(group!, 'incoming', Infinity, relationshipWords.de, true).text).toBe('- **CONTAINS_FOLDER (1):** `django-demo · losgelöster HEAD` (Branch-Knoten)');+});++it('N1: a selected Branch node is named for what it is in the evidence, the topic and the listed answer', () => {+ const graph = branchContext();+ expect(graph.label).toBe('django-demo · detached HEAD');+ const evidence = readGalaxyEvidence(graph.text)!;+ // The identity and the names the chat matches stay those of the index.+ expect(evidence.label).toBe('DETACHED');+ expect(evidence.roots[0]).toMatchObject({ name: 'DETACHED', kind: 'Branch', qualifiedName: 'django-demo.__branch__.detached' });+ expect(selectionSentence(evidence, relationshipWords.en)).toEqual(['Selected: django-demo · detached HEAD (Branch).']);+ expect(selectionSentence(evidence, relationshipWords.de)).toEqual(['Ausgewählt: django-demo · losgelöster HEAD (Branch-Knoten).']);+ expect(chatTopic('django-demo:galaxy', { graph })?.label).toBe('django-demo · detached HEAD');+ // A typed "DETACHED" still names the selection; the answer names it as the Galaxy does.+ const english = relationshipAnswer('Who calls DETACHED?', [graph])!;+ expect(english.markdown).toContain('No CALLS edge reaches `django-demo · detached HEAD` in this scope.');+ expect(english.markdown).not.toContain('`DETACHED`');+ const german = relationshipAnswer('Wer ruft DETACHED auf?', [graph])!;+ expect(german.markdown).toContain('`django-demo · losgelöster HEAD`');+ expect(german.markdown).not.toContain('`DETACHED`');+});++it('N1: the working tree of cbm and a named branch read the same way', () => {+ const words = relationshipWords.de.nodeNames;+ expect(words.workingTree).toBe('Arbeitsverzeichnis');+ expect(words.branch('main')).toBe('Branch main');+ expect(relationshipWords.en.nodeNames.workingTree).toBe('working tree');+});diff --git a/graph-ui/src/browser-ai/galaxy-evidence.ts b/graph-ui/src/browser-ai/galaxy-evidence.tsindex e252eae18..c8bc0ec0e 100644--- a/graph-ui/src/browser-ai/galaxy-evidence.ts+++ b/graph-ui/src/browser-ai/galaxy-evidence.ts@@ -1,3 +1,4 @@+import { nodeDisplayName } from '../galaxy/node-names';import type { RelationshipGroup, ScopeRelationships } from '../galaxy/selection-evidence';import type { RelationshipWords } from './strings';@@ -39,12 +40,16 @@ function text(value: unknown, limit: number): string | undefined {return clean.length <= limit ? clean : `${clean.slice(0, limit - 1)}…`;}-function groups(value: unknown): RelationshipGroup[] {+/* A related Branch node carries the project of the snapshot, so a listed answer can name it "django-demo · detached HEAD" (round 4, N1). */+function groups(value: unknown, project: string | undefined): RelationshipGroup[] {return records(value).flatMap(group => {const type = text(group.type, 60);if (!type) return [];const files = records(group.files).map(file => ({ path: text(file.path, 240) ?? '', symbols: records(file.symbols)- .flatMap(symbol => { const name = text(symbol.name, 120); return name ? [{ name, kind: text(symbol.kind, 40) }] : []; }) }))+ .flatMap(symbol => {+ const name = text(symbol.name, 120), kind = text(symbol.kind, 40);+ return name ? [{ name, kind, ...kind === 'Branch' && project ? { project } : {} }] : [];+ }) })).filter(file => file.symbols.length);const listed = files.reduce((sum, file) => sum + file.symbols.length, 0);return [{ type, count: Math.max(count(group.count), listed), files }];@@ -78,14 +83,15 @@ export function readGalaxyEvidence(snapshot: string): GalaxyEvidence | undefinedreturn name ? [{ name, kind: text(root.kind, 40), qualifiedName: text(root.qualifiedName, 400), filePath: text(root.filePath, 240), startLine: line(root.startLine),endLine: line(root.endLine), documentation: text(root.documentation, 300) }] : [];});+ const project = text(evidence.project, 120);return {- project: text(evidence.project, 120) ?? '', label: text(identity.name, 120) ?? roots[0]?.name ?? 'selection',+ project: project ?? '', label: text(identity.name, 120) ?? roots[0]?.name ?? 'selection',identity, selectionKind: text(identity.kind, 20) ?? 'node',roots, rootCount: Math.max(count(selected?.rootCount), roots.length),depth: count(scope.depth), direction, edgeTypes, nodes: count(scope.nodes), edges: count(scope.edges),state, ...state === 'limited' ? { renderLimit } : {}, error: text(limits?.error, 200), exhausted: limits?.exhausted === true,- relationships: { incoming: groups(relationships?.incoming), incomingSymbols: total(relationships?.incomingSymbols),- outgoing: groups(relationships?.outgoing), outgoingSymbols: total(relationships?.outgoingSymbols),+ relationships: { incoming: groups(relationships?.incoming, project), incomingSymbols: total(relationships?.incomingSymbols),+ outgoing: groups(relationships?.outgoing, project), outgoingSymbols: total(relationships?.outgoingSymbols),internal: totals(relationships?.internal), beyond: totals(relationships?.beyond) },truncated,};@@ -121,7 +127,7 @@ export function relationshipLine(group: RelationshipGroup, _side: 'incoming' | 'const suffix = where ? ` (${where})` : '';let chunk = '';for (const symbol of file.symbols) {- const next = `${chunk ? `${chunk}, ` : body ? '; ' : ''}${quote(symbol.name)}`;+ const next = `${chunk ? `${chunk}, ` : body ? '; ' : ''}${quote(nodeDisplayName(symbol, words.nodeNames))}`;const shown = listed + 1;const after = group.count > shown ? `; ${words.more(group.count - shown)}` : '';if (head.length + body.length + next.length + suffix.length + after.length > budget) {@@ -151,6 +157,21 @@ export function sideLoaded(evidence: GalaxyEvidence, side: 'incoming' | 'outgoinreturn evidence.depth > 0 && evidence.direction !== (side === 'incoming' ? 'outbound' : 'inbound');}+/** A root as the answer names it: a Branch node "django-demo · detached HEAD", every other by its name (round 4, N1). */+const rootName = (root: GalaxyEvidence['roots'][number], words: RelationshipWords) => nodeDisplayName(root, words.nodeNames);++/**+ * The selection as the answer names it. The label stays the name of the+ * index, because the chat matches typed names against it; what is written+ * names a Branch node for what it is, in the language of the answer.+ */+export function selectionName(evidence: GalaxyEvidence, words: RelationshipWords): string {+ const [first] = evidence.roots;+ if (evidence.rootCount <= 1 && first && first.name === evidence.label) return rootName(first, words);+ const identity = record(evidence.identity);+ return nodeDisplayName({ name: evidence.label, qualifiedName: typeof identity?.qualifiedName === 'string' ? identity.qualifiedName : undefined }, words.nodeNames);+}+/** What is selected, in the words of the prompt (English) or of a question (C5). */export function selectionSentence(evidence: GalaxyEvidence, words: RelationshipWords): string[] {const [first] = evidence.roots;@@ -159,10 +180,10 @@ export function selectionSentence(evidence: GalaxyEvidence, words: RelationshipW// Kinds in the words of the answer: "(Klasse)" in a German one (W8).const kind = (root: GalaxyEvidence['roots'][number]) => root.kind ? ` (${words.kindName(root.kind)})` : '';if (evidence.rootCount <= 1 && first) {- return [words.selected(`${first.name}${kind(first)}${range(first)}`),+ return [words.selected(`${rootName(first, words)}${kind(first)}${range(first)}`),...first.documentation ? [words.documentation(first.documentation)] : []];}- if (!first) return [words.notInScope(evidence.label, words.kindName(evidence.selectionKind))];- const listed = evidence.roots.map(root => `${root.name}${kind(root)}`).join(', ');- return [words.selectedGroup(words.kindName(evidence.selectionKind), evidence.label, evidence.rootCount, listed, evidence.rootCount - evidence.roots.length)];+ if (!first) return [words.notInScope(selectionName(evidence, words), words.kindName(evidence.selectionKind))];+ const listed = evidence.roots.map(root => `${rootName(root, words)}${kind(root)}`).join(', ');+ return [words.selectedGroup(words.kindName(evidence.selectionKind), selectionName(evidence, words), evidence.rootCount, listed, evidence.rootCount - evidence.roots.length)];}diff --git a/graph-ui/src/browser-ai/relationship-answer.ts b/graph-ui/src/browser-ai/relationship-answer.tsindex b8d15a142..a7c231c17 100644--- a/graph-ui/src/browser-ai/relationship-answer.ts+++ b/graph-ui/src/browser-ai/relationship-answer.ts@@ -1,7 +1,7 @@import { identifierNamesIn, mentionsIn, quotedNamesIn } from '../compiler/question-classifier';import type { BrowserChatContext } from './chat-model';import type { RelationshipGroup } from '../galaxy/selection-evidence';-import { readGalaxyEvidence, relationshipLine, scopeSentence, sideLoaded, type GalaxyEvidence } from './galaxy-evidence';+import { readGalaxyEvidence, relationshipLine, scopeSentence, selectionName, sideLoaded, type GalaxyEvidence } from './galaxy-evidence';import { relationshipWords, type RelationshipWords } from './strings';type Side = 'incoming' | 'outgoing';@@ -179,7 +179,8 @@ function listedLine(group: RelationshipGroup, side: Side, words: RelationshipWor* reads as a caller (C2). */function listed(question: RelationshipQuestion, evidence: GalaxyEvidence): string {const words = relationshipWords[question.language];- const name = quote(evidence.label);+ // The selection as the Galaxy names it: a Branch node is "django-demo · detached HEAD" (round 4, N1).+ const name = quote(selectionName(evidence, words));const sections: string[] = [];for (const side of question.sides) {const unlisted = words.unlisted(side, name);diff --git a/graph-ui/src/browser-ai/strings.ts b/graph-ui/src/browser-ai/strings.tsindex 6c4b0b9c4..6ec25efd5 100644--- a/graph-ui/src/browser-ai/strings.ts+++ b/graph-ui/src/browser-ai/strings.ts@@ -1,4 +1,5 @@import type { DroppedReason } from './explanation-response';+import { galaxyNodeNameText, type BranchNameWords } from '../galaxy/galaxy-strings';export const browserAiText = {title: 'Browser AI',@@ -47,6 +48,15 @@ const GERMAN_KINDS: Readonly<Record<string, readonly [string, string, 'f' | 'm'struct: ['Struktur', 'Strukturen', 'f'], trait: ['Trait', 'Traits', 'm'], macro: ['Makro', 'Makros', 'n'], constant: ['Konstante', 'Konstanten', 'f'],namespace: ['Namensraum', 'Namensräume', 'm'], property: ['Eigenschaft', 'Eigenschaften', 'f'], decorator: ['Dekorator', 'Dekoratoren', 'm'],test: ['Test', 'Tests', 'm'], channel: ['Kanal', 'Kanäle', 'm'], node: ['Knoten', 'Knoten', 'm'], symbol: ['Symbol', 'Symbole', 'n'],+ branch: ['Branch-Knoten', 'Branch-Knoten', 'm'],+};+/** The Branch node in the words of the answer: "django-demo · detached HEAD", "django-demo · losgelöster HEAD" (round 4, N1). */+const englishNodeNames: BranchNameWords = galaxyNodeNameText;+const germanNodeNames: BranchNameWords = {+ detached: 'losgelöster HEAD',+ workingTree: 'Arbeitsverzeichnis',+ branch: (name: string) => `Branch ${name}`,+ inProject: (project: string, what: string) => `${project} · ${what}`,};const englishRelationshipWords = {more: (count: number) => `+${en(count)} more`,@@ -68,6 +78,8 @@ const englishRelationshipWords = {exhausted: 'nothing further beyond this depth',/** A node kind as the answer's language writes it: "Class", "Klasse" (W8). */kindName: (kind: string) => kind,+ /** How a Branch node is named (round 4, N1). */+ nodeNames: englishNodeNames,scope: (shape: string, size: string, state: string) => `Scope: ${shape}; ${size}; ${state}.`,/** Each number with its unit: "Incoming: 23 relationships from 12 symbols", never "23 from 12", which reads like a score (W2). */incoming: (total: number, symbols?: number) => `Incoming: ${en(total)} ${total === 1 ? 'relationship' : 'relationships'}`@@ -148,6 +160,7 @@ export const relationshipWords: { en: RelationshipWords; de: RelationshipWords }},exhausted: 'dahinter folgt nichts mehr',kindName: (kind: string) => GERMAN_KINDS[kind.toLowerCase()]?.[0] ?? kind,+ nodeNames: germanNodeNames,scope: (shape: string, size: string, state: string) => `Ausschnitt: ${shape}; ${size}; ${state}.`,incoming: (total: number, symbols?: number) => `Eingehend: ${de(total)} ${total === 1 ? 'Beziehung' : 'Beziehungen'}`+ `${symbols === undefined ? '' : ` von ${de(symbols)} ${symbols === 1 ? 'Symbol' : 'Symbolen'}`}.`,diff --git a/graph-ui/src/galaxy/GalaxyNavigator.tsx b/graph-ui/src/galaxy/GalaxyNavigator.tsxindex d08f2adcc..8cf4e30f1 100644--- a/graph-ui/src/galaxy/GalaxyNavigator.tsx+++ b/graph-ui/src/galaxy/GalaxyNavigator.tsx@@ -2,19 +2,25 @@ import { useEffect, useMemo, useRef, useState } from 'react';import { RpcIntelligenceClient } from '../provider/rpc-client';import type { SearchGraphHit } from '../provider/rpc-schemas';import type { GraphScope } from './graph-scope';+import { galaxyNodeNameText } from './galaxy-strings';+import { graphNodeName, graphNodeTitle, nodeDisplayName, nodeFilePath } from './node-names';import type { GraphNode } from './types';export const FOCUS_GALAXY_SEARCH = 'cbm:focus-galaxy-search';-interface Choice { key: string; name: string; detail: string; kind: string; scope: GraphScope; node?: GraphNode }+/** `name` is the shown name (a Branch node reads "django-demo · detached HEAD", round 4, N1); `title` keeps the one of the index. */+interface Choice { key: string; name: string; title?: string; detail: string; kind: string; scope: GraphScope; node?: GraphNode }/** Server hits also expose selectable file/folder clusters outside the layout. */export function choicesFromSearchHits(hits: readonly SearchGraphHit[]): Choice[] {const choices = new Map<string, Choice>();for (const hit of hits) {- if (hit.qualified_name) choices.set(hit.qualified_name, { key: hit.qualified_name, name: hit.name,- detail: hit.file_path ?? hit.qualified_name, kind: hit.label ?? 'Symbol',+ const file = nodeFilePath({ ...hit });+ const shown = nodeDisplayName({ name: hit.name, label: hit.label, qualifiedName: hit.qualified_name });+ if (hit.qualified_name) choices.set(hit.qualified_name, { key: hit.qualified_name, name: shown,+ ...shown !== hit.name ? { title: galaxyNodeNameText.branchTitle(shown, hit.name, hit.qualified_name) } : {},+ detail: file ?? hit.qualified_name, kind: hit.label ?? 'Symbol',scope: { kind: 'symbol', qualifiedName: hit.qualified_name, name: hit.name } });- if (!hit.file_path) continue;- const path = hit.file_path.replace(/\\/g, '/');+ if (!file) continue;+ const path = file.replace(/\\/g, '/');choices.set(path, { key: path, name: path, kind: 'File', detail: 'Indexed file', scope: { kind: 'file', path, name: path } });const parts = path.split('/');for (let i = 1; i < parts.length; i++) {@@ -70,16 +76,19 @@ export default function GalaxyNavigator({ nodes, onSelect, onSelectScope, projecconst needle = query.trim().toLocaleLowerCase();const choices: Choice[] = [], paths = new Map<string, number>();for (const node of nodes) {- if (node.file_path) {- paths.set(node.file_path, (paths.get(node.file_path) ?? 0) + 1);- const parts = node.file_path.split('/');+ const file = nodeFilePath(node);+ if (file) {+ paths.set(file, (paths.get(file) ?? 0) + 1);+ const parts = file.split('/');for (let i = 1; i < parts.length; i++) {const directory = parts.slice(0, i).join('/') + '/'; paths.set(directory, (paths.get(directory) ?? 0) + 1);}}- if (!needle || [node.name, node.qualified_name, node.file_path].some(value => value?.toLocaleLowerCase().includes(needle))) {- choices.push({ key: node.qualified_name ?? `node:${node.id}`, name: node.name,- detail: node.file_path ?? node.qualified_name ?? node.label, kind: node.label,+ const shown = graphNodeName(node);+ if (!needle || [shown, node.name, node.qualified_name, file].some(value => value?.toLocaleLowerCase().includes(needle))) {+ choices.push({ key: node.qualified_name ?? `node:${node.id}`, name: shown,+ ...shown !== node.name ? { title: graphNodeTitle(node) } : {},+ detail: file ?? node.qualified_name ?? node.label, kind: node.label,scope: { kind: 'node', id: node.id, name: node.name, qualifiedName: node.qualified_name }, node });}}@@ -97,7 +106,7 @@ export default function GalaxyNavigator({ nodes, onSelect, onSelectScope, projecconst results = <>{status && <small role="status">{status}</small>}<ul>{matches.map(choice => <li key={choice.key}>- <button type="button" onClick={() => {+ <button type="button" title={choice.title} onClick={() => {if (choice.node) onSelect(choice.node); else onSelectScope?.(choice.scope);if (details.current) details.current.open = false;setPickerOpen(false);diff --git a/graph-ui/src/galaxy/GalaxyPanel.branch-names.test.tsx b/graph-ui/src/galaxy/GalaxyPanel.branch-names.test.tsxnew file mode 100644index 000000000..34e5a3bbd--- /dev/null+++ b/graph-ui/src/galaxy/GalaxyPanel.branch-names.test.tsx@@ -0,0 +1,154 @@+// @vitest-environment jsdom+/*+ * Hand test 2026-10-04, round 4. N1: in the hierarchy of .github the node+ * the index puts above the top level folders stood as a bare "DETACHED".+ * Its name now says what it is in the toolbar, the history, Path to and the+ * chat label, and the hierarchy leaves room for that name. N2: the note+ * "nothing of this walk is in focus: the ring follows the symbol in front of+ * the reader" stood under that hierarchy, where the root stands marked in+ * the middle and Explore is not even open. It now stands only beside+ * Explore's reader, in plain words.+ */+import { act } from 'react';+import { createRoot, type Root } from 'react-dom/client';+import { afterEach, beforeEach, expect, it, vi } from 'vitest';+import GalaxyPanel from './GalaxyPanel';+import { galaxyHierarchyNoteText } from './galaxy-strings';+import { hierarchyLabelWidth, SCOPED_HIERARCHY_LEVEL_GAP } from './graph-scope';+import { HIERARCHY_LABEL_PAD_X } from './hierarchy-layout';+import { scopeFetch, scopeNode } from './test-scope-fetch';+import type { BrowserChatContext } from '../browser-ai/chat-model';+import type { ClosureResult } from '../provider/closure';+import { toEditorRange } from '../core/positions';++vi.mock('./GraphScene', async importOriginal => ({ ...await importOriginal<typeof import('./GraphScene')>(), GraphScene: () => <output data-testid="scene" /> }));++let host: HTMLDivElement, root: Root;+beforeEach(() => {+ (globalThis as unknown as Record<string, unknown>).IS_REACT_ACT_ENVIRONMENT = true;+ host = document.createElement('div'); document.body.append(host); root = createRoot(host);+});+afterEach(async () => { await act(async () => root.unmount()); host.remove(); globalThis.__atlasGalaxy = undefined; });++const seam = () => globalThis.__atlasGalaxy!;+const settle = (check: () => void) => vi.waitFor(async () => {+ await act(async () => { await new Promise(resolve => setTimeout(resolve, 0)); });+ check();+});+const count = () => host.querySelector('.atlas-graph-scope-count')?.textContent;+const note = () => host.querySelector('[data-testid="atlas-galaxy-note"]')?.textContent ?? '';+const rootName = () => host.querySelector('.atlas-graph-scope-name');++const branch = scopeNode(2, { label: 'Branch', name: 'DETACHED', qualified_name: 'django-demo.__branch__.detached', file_path: '{}', start_line: undefined, end_line: undefined });+const github = scopeNode(4, { label: 'Folder', name: '.github', qualified_name: 'django-demo..github', file_path: '.github', start_line: undefined, end_line: undefined });+const security = scopeNode(5, { label: 'File', name: 'SECURITY.md', qualified_name: 'django-demo..github.SECURITY.md.__file__', file_path: '.github/SECURITY.md' });+const workflows = scopeNode(6, { label: 'Folder', name: 'workflows', qualified_name: 'django-demo..github.workflows', file_path: '.github/workflows', start_line: undefined, end_line: undefined });+const edges = [{ id: 1, source: 2, target: 4, type: 'CONTAINS_FOLDER' }, { id: 2, source: 4, target: 5, type: 'CONTAINS_FILE' }, { id: 3, source: 4, target: 6, type: 'CONTAINS_FOLDER' }];++async function githubHierarchy(onSelectionEvidence = vi.fn()) {+ await act(async () => root.render(<GalaxyPanel project="django-demo" visible workspaceExpanded onOpenNode={vi.fn()} onSelectionEvidence={onSelectionEvidence}+ fetch={scopeFetch({ nodes: [branch, github, security, workflows], edges }).fetch} />));+ await settle(() => expect(seam().nodes).toBe(4));+ await act(async () => { seam().clickNode('django-demo..github'); });+ await settle(() => expect(count()).toBe('4 nodes · 3 edges'));+ await act(async () => host.querySelector<HTMLButtonElement>('[data-testid="atlas-graph-mode-chip"][data-mode="hierarchy"]')!.click());+ expect(seam().mode).toBe('hierarchy');+ return onSelectionEvidence;+}++it('N1: the hierarchy of .github leaves room for the shown name of the Branch node on its left', async () => {+ await githubHierarchy();+ const placed = Object.fromEntries(seam().hierarchy!.placements.map(placement => [placement.name, placement]));+ // The column gap follows the width of the name that is drawn, "django-demo · detached HEAD", not of "DETACHED".+ const gap = Math.max(SCOPED_HIERARCHY_LEVEL_GAP, (hierarchyLabelWidth('.github') + hierarchyLabelWidth('django-demo · detached HEAD')) / 2 + 40);+ expect(placed.DETACHED!.x).toBeCloseTo(-gap, 5);+ expect(placed.DETACHED!.x).toBeLessThan(-SCOPED_HIERARCHY_LEVEL_GAP);+ // The camera frames the whole name, which stands centred over its node (seen cut off at the left edge in the browser).+ const right = Math.max(...seam().hierarchy!.placements.map(placement => placement.x));+ expect(seam().lastFit!.width).toBeGreaterThanOrEqual(right + HIERARCHY_LABEL_PAD_X - placed.DETACHED!.x + hierarchyLabelWidth('django-demo · detached HEAD') / 2);+});++it('N2: the scoped hierarchy in the Galaxy tab carries no note about a ring that follows Explore', async () => {+ await githubHierarchy();+ expect(seam().pulsedQn).toBe('');+ expect(note()).toBe('');+ expect(host.textContent).not.toContain('nothing of this walk');+ expect(host.textContent).not.toContain(galaxyHierarchyNoteText.noFocus);+});++it('N1: with the Branch node as root, the toolbar, the history and the chat label name it, and the real name stays in the tooltip', async () => {+ const evidence = await githubHierarchy();+ await act(async () => host.querySelector<HTMLButtonElement>('[data-testid="atlas-graph-mode-chip"][data-mode="galaxy"]')!.click());+ await act(async () => { seam().clickNode('django-demo.__branch__.detached'); });+ await settle(() => expect(count()).toBe('2 nodes · 1 edge'));+ expect(rootName()?.textContent).toBe('django-demo · detached HEAD');+ // The "{}" the index stores as its file is no source to open: the name is no button.+ expect(rootName()?.tagName).toBe('STRONG');+ expect(rootName()?.getAttribute('title')).toContain('Name in the index: DETACHED (django-demo.__branch__.detached)');+ expect(seam().history.recent).toContain('django-demo · detached HEAD · 1 layer');+ const recent = [...host.querySelectorAll('.atlas-graph-recent-menu strong')].map(name => name.textContent);+ expect(recent).toEqual(expect.arrayContaining(['django-demo · detached HEAD', '.github']));+ // The chat names the selection as the Galaxy does; the snapshot keeps the identity of the index.+ const context = evidence.mock.lastCall![0] as BrowserChatContext;+ expect(context.label).toBe('django-demo · detached HEAD');+ const snapshot = JSON.parse(context.text).evidence;+ expect(snapshot.selected.scope).toMatchObject({ kind: 'node', name: 'DETACHED', qualifiedName: 'django-demo.__branch__.detached' });+ expect(snapshot.selected.roots[0]).toMatchObject({ name: 'DETACHED', kind: 'Branch' });+ expect(snapshot.selected.roots[0].filePath).toBeUndefined();+});++it('N1: a file scope with a single root keeps its path as the name of the root', async () => {+ await act(async () => root.render(<GalaxyPanel project="django-demo" visible workspaceExpanded onOpenNode={vi.fn()}+ fetch={scopeFetch({ nodes: [branch, github, security, workflows], edges }).fetch} />));+ await settle(() => expect(seam().nodes).toBe(4));+ const input = host.querySelector<HTMLInputElement>('input[aria-label="Find a graph node"]')!;+ await act(async () => {+ input.focus();+ Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')!.set!.call(input, 'SECURITY');+ input.dispatchEvent(new Event('input', { bubbles: true }));+ });+ const file = [...host.querySelectorAll<HTMLButtonElement>('.atlas-galaxy-search-results li button')]+ .find(button => button.querySelector('.atlas-graph-result-kind')?.textContent === 'File' && button.querySelector('strong')?.textContent === '.github/SECURITY.md')!;+ await act(async () => file.click());+ await settle(() => expect(count()).toMatch(/^1 node · /));+ expect(rootName()?.textContent).toBe('.github/SECURITY.md');+});++it('N1: Path to names the Branch node in its heading', async () => {+ await githubHierarchy();+ host.querySelector<HTMLDetailsElement>('.atlas-graph-path-picker')!.open = true;+ const target = [...host.querySelectorAll<HTMLButtonElement>('.atlas-graph-path-menu li button')]+ .find(entry => entry.querySelector('strong')?.textContent === 'django-demo · detached HEAD')!;+ await act(async () => target.click());+ expect(host.querySelector('[data-testid="atlas-galaxy-path-panel"] strong')?.textContent).toBe('Path to django-demo · detached HEAD · 1 hop');+ expect(seam().history.entries.at(-1)).toContain('path to django-demo · detached HEAD');+});++/* A walk in the Explore panel: the place where the ring follows the symbol open in the reader. */+const qn = { start: 'atlas.src.app.start', helper: 'atlas.src.app.helper' };+const symbol = (name: keyof typeof qn, line: number) => ({ name, qualifiedName: qn[name], kind: 'function' as const, uri: 'file:///workspace/src/app.ts',+ range: toEditorRange(line, line + 3), selectionRange: toEditorRange(line, line) });+const walk: ClosureResult = { root: symbol('start', 1), nodes: [{ symbol: symbol('start', 1), hop: 0 }, { symbol: symbol('helper', 9), hop: 1, via: qn.start }],+ edges: [{ from: qn.start, to: qn.helper, line: 2 }], truncated: false, visited: 2, depth: 2, cap: 15 };+const layout = () => vi.fn(async () => new Response(JSON.stringify({ nodes: [], edges: [], total_nodes: 0 })));++it('N2: beside Explore the note says plainly that no node of the walk is open there, and goes once one is', async () => {+ const fetch = layout();+ await act(async () => root.render(<GalaxyPanel project="atlas" visible onOpenNode={vi.fn()} fetch={fetch} walk={walk} focusQualifiedName="atlas.src.other.elsewhere" />));+ await settle(() => expect(seam().mode).toBe('hierarchy'));+ expect(note()).toBe('None of these nodes is open in Explore; the ring marks the symbol open there.');+ expect(galaxyHierarchyNoteText.noFocus).toBe(note());+ await act(async () => root.render(<GalaxyPanel project="atlas" visible onOpenNode={vi.fn()} fetch={fetch} walk={walk} focusQualifiedName={qn.helper} />));+ expect(seam().pulsedQn).toBe(qn.helper);+ expect(note()).toBe('');+});++it('N2: the hierarchy chip says in plain words what it needs before it can show anything', async () => {+ await act(async () => root.render(<GalaxyPanel project="atlas" visible onOpenNode={vi.fn()} fetch={layout()} />));+ const chip = host.querySelector('[data-testid="atlas-graph-mode-chip"][data-mode="hierarchy"]')!.closest('[data-hint]');+ expect(chip?.getAttribute('data-hint')).toBe(galaxyHierarchyNoteText.unavailable);+ expect(galaxyHierarchyNoteText.unavailable).not.toMatch(/way in/);+ await act(async () => root.render(<GalaxyPanel project="atlas" visible workspaceExpanded onOpenNode={vi.fn()} fetch={layout()} />));+ const workspaceChip = host.querySelector('[data-testid="atlas-graph-mode-chip"][data-mode="hierarchy"]')!.closest('[data-hint]');+ expect(workspaceChip?.getAttribute('data-hint')).toBe(galaxyHierarchyNoteText.unavailableWorkspace);+});diff --git a/graph-ui/src/galaxy/GalaxyPanel.test.tsx b/graph-ui/src/galaxy/GalaxyPanel.test.tsxindex 9d395a4a0..25be9e97d 100644--- a/graph-ui/src/galaxy/GalaxyPanel.test.tsx+++ b/graph-ui/src/galaxy/GalaxyPanel.test.tsx@@ -656,7 +656,8 @@ describe('GalaxyPanel und die Hierarchie', () => {it('sagt es, wenn nichts von diesem Walk im Fokus steht', async () => {await render(props({ walk: walkOf() }));expect(seam().pulsedQn).toBe('');- expect(noteText()).toContain('nothing of this walk is in focus');+ // Runde 4 (N2): in einfachen Worten, und nur neben dem Reader von Explore.+ expect(noteText()).toBe('None of these nodes is open in Explore; the ring marks the symbol open there.');});it('oeffnet einen angeklickten Knoten der Projektion ueber denselben Weg', async () => {diff --git a/graph-ui/src/galaxy/GalaxyPanel.tsx b/graph-ui/src/galaxy/GalaxyPanel.tsxindex 9395595a9..29cc907a9 100644--- a/graph-ui/src/galaxy/GalaxyPanel.tsx+++ b/graph-ui/src/galaxy/GalaxyPanel.tsx@@ -140,7 +140,8 @@ import GalaxyNavigator from './GalaxyNavigator';import { TraceEdgeFilter } from './TraceEdgeFilter';import { PathPicker, PathSteps } from './ScopePathControls';import { callOrder, pathNodes, shortestScopePath, type ScopePathStep } from './scope-path';-import { galaxyHierarchyText, galaxyHistoryText, galaxyLayerText, galaxyPathText, galaxyToolbarText } from './galaxy-strings';+import { galaxyHierarchyNoteText, galaxyHierarchyText, galaxyHistoryText, galaxyLayerText, galaxyPathText, galaxyToolbarText } from './galaxy-strings';+import { graphNodeName, nodeFilePath, scopeDisplayName, scopeTitle } from './node-names';import { HierarchyBandLabel, HierarchyEdgeLabels } from './HierarchyEdgeLabels';import { FitLabel, useToolbarFit } from './toolbar-fit';import { emptyNavigationHistory, moveNavigation, peekNavigation, pushNavigation } from '../graph/navigation-history';@@ -149,7 +150,7 @@ import { galaxyHistoryOptions, historyEntryDetail, historyEntryLabel, scopeIdentimport { useOrganicLayout } from './use-organic-layout';import RenderProgress from './RenderProgress';import { useGraphScope } from './use-graph-scope';-import { SCOPED_HIERARCHY_LABEL_BUDGET, SCOPED_HIERARCHY_LABEL_MAX_TEXT_WIDTH, expandPastLimit, limitGraphRender, nextLayerEstimate, scenePictureFor, scopedHierarchy, type ExpandOutlook } from './graph-scope';+import { SCOPED_HIERARCHY_LABEL_BUDGET, SCOPED_HIERARCHY_LABEL_MAX_TEXT_WIDTH, expandPastLimit, hierarchyLabelWidth, limitGraphRender, nextLayerEstimate, scenePictureFor, scopedHierarchy, type ExpandOutlook } from './graph-scope';import './graph-exploration.css';import { layoutNodeForSelection } from './selected-node';import { galaxyScopeEvidence, useSelectionEvidence, type SelectionEvidenceListener } from './selection-evidence';@@ -238,20 +239,14 @@ export type GraphMode = 'galaxy' | 'hierarchy';/** Die beiden Chips, in der Reihenfolge, in der sie im Kopf stehen. */export const GRAPH_MODES: readonly GraphMode[] = ['galaxy', 'hierarchy'];-/**- * Was der `hierarchy`-Chip sagt, solange es weder Walk noch Fokus gibt.- *- * Seit W10b nennt er BEIDE Wege, weil es seitdem beide gibt (AC3): ein Symbol- * im Fokus genuegt, ein Einstiegs-Spaziergang ist der andere Weg. Ein Knopf, der- * nur den umstaendlicheren nennt, schickt den Leser auf den Umweg, den dieser- * Zyklus gerade abgeschafft hat.+/*+ * Was der `hierarchy`-Chip sagt, solange es weder Walk noch Fokus gibt, und+ * was das Panel sagt, wenn kein Knoten des Walks im Reader offen ist, stehen+ * seit Runde 4 (N2) in galaxy-strings.ts (`galaxyHierarchyNoteText`). Seit+ * W10b nennt der Chip BEIDE Wege (AC3): ein offenes Symbol genuegt, ein+ * gewaehlter Start ist der andere Weg; im Galaxy-Tab ist es ein gewaehlter+ * Knoten.*/-export const HIERARCHY_UNAVAILABLE_TITLE =- 'hierarchy: open a symbol or pick a way in first, then this shows what it reaches';--/** Was das Panel in der Hierarchie sagt, wenn der Leser ausserhalb des Walks steht. */-export const HIERARCHY_NO_FOCUS_NOTE =- 'nothing of this walk is in focus: the ring follows the symbol in front of the reader';/*** Wie die Szene im hierarchy-Modus eingestellt ist.@@ -1271,7 +1266,7 @@ export default function GalaxyPanel(props: GalaxyPanelProps): JSX.Element {const trailView = useMemo(() => {// Handtest K5: Pfad und Aufrufreihe auch in der Hierarchie eines Ausschnitts.if (!props.workspaceExpanded || (mode !== 'galaxy' && !scopedProjection) || trail?.key !== organicKey || !data || !scope.result) return undefined;- const names = new Map(data.nodes.map(node => [node.id, node.name]));+ const names = new Map(data.nodes.map(node => [node.id, graphNodeName(node)]));const nameOf = (id: number) => names.get(id) ?? `#${id}`;if (trail.kind === 'calls') {return { nameOf, lines: true, labels: 'active' as const, steps: rootCalls,@@ -1626,7 +1621,11 @@ export default function GalaxyPanel(props: GalaxyPanelProps): JSX.Element {return;}if (mode === 'hierarchy' && projection !== undefined) {- const box = hierarchyFrame(projection);+ // In der Hierarchie eines Ausschnitts rahmt die Kamera die Namen in ihrer Breite (Runde 4, N1); ohne Namen zaehlt der Punkt.+ const box = hierarchyFrame(projection, projection === scopedProjection ? (placement) => {+ const node = projection.data.nodes[placement.id];+ return node === undefined || (scopedNamedIds !== undefined && !scopedNamedIds.has(placement.id)) ? 0 : hierarchyLabelWidth(graphNodeName(node));+ } : undefined);const target = computeFrameTarget(box, aspect);// Erst eine Einpassung, die wirklich lief, verbraucht die Anfrage:// ein Scope, dessen Bild noch angeordnet wird, passt danach ein.@@ -1688,7 +1687,7 @@ export default function GalaxyPanel(props: GalaxyPanelProps): JSX.Element {};// `scope.result` folgt dem Bild und loest selbst keine Einpassung aus.// eslint-disable-next-line react-hooks/exhaustive-deps- }, [visible, mode, projection, picture, aspect, requestedFit, ownFit, coverageShadow, fitRequest, props.workspaceExpanded, fitScope]);+ }, [visible, mode, projection, picture, aspect, requestedFit, ownFit, coverageShadow, fitRequest, props.workspaceExpanded, fitScope, scopedProjection, scopedNamedIds]);const [backgroundCleared, setBackgroundCleared] = useState(false);useEffect(() => {@@ -1856,6 +1855,18 @@ export default function GalaxyPanel(props: GalaxyPanelProps): JSX.Element {return undefined;}, [backgroundCleared, mode, readerHierarchyActive, focusQualifiedName, stepQualifiedName, index]);+ /*+ * Ob die Notiz zum Ring gilt (Runde 4, N2). Der Ring folgt dem Symbol, das+ * im Reader von Explore offen ist; die Notiz sagt, dass keiner der Knoten+ * dieses ist. Das gilt nur neben dem Reader: im Galaxy-Tab steht die+ * Wurzel eines Ausschnitts markiert in der Mitte, und Explore ist dort+ * nicht zu sehen. Ein Klick ins Leere blendet den Ring aus, macht die+ * Notiz aber nicht wahr; darum zaehlt hier das Bild und nicht der Ring.+ */+ const hierarchyNoFocusNote = useMemo(() => !props.workspaceExpanded+ && ![focusQualifiedName, stepQualifiedName].some((candidate) => candidate !== undefined && candidate.length > 0 && index.has(candidate))+ ? galaxyHierarchyNoteText.noFocus : '', [props.workspaceExpanded, focusQualifiedName, stepQualifiedName, index]);+/** In der Hierarchie bleibt alles hell.*@@ -1872,8 +1883,8 @@ export default function GalaxyPanel(props: GalaxyPanelProps): JSX.Element {return;}setHighlighted(new Set(projection.data.nodes.map((node) => node.id)));- setNote(readerProjection ? readerProjection.message : pulsedNode === undefined ? HIERARCHY_NO_FOCUS_NOTE : '');- }, [mode, projection, pulsedNode, readerProjection]);+ setNote(readerProjection ? readerProjection.message : hierarchyNoFocusNote);+ }, [mode, projection, pulsedNode, readerProjection, hierarchyNoFocusNote]);// Rueck-Richtung: ein Klick in die Szene oeffnet die Datei.const handleNodeClick = useCallback(@@ -1896,7 +1907,8 @@ export default function GalaxyPanel(props: GalaxyPanelProps): JSX.Element {setNote('');return;}- if (node.file_path === undefined || node.file_path.length === 0) {+ const file = nodeFilePath(node);+ if (file === undefined || file.length === 0) {setNote(unopenableNodeNote(node));return;}@@ -1914,10 +1926,10 @@ export default function GalaxyPanel(props: GalaxyPanelProps): JSX.Element {scope.reset();changeTraceTypes(undefined);setHighlighted(null);- setNote(props.workspaceExpanded ? '' : mode === 'hierarchy' ? readerProjection?.message ?? HIERARCHY_NO_FOCUS_NOTE : GALAXY_NO_FOCUS_NOTE);+ setNote(props.workspaceExpanded ? '' : mode === 'hierarchy' ? readerProjection?.message ?? hierarchyNoFocusNote : GALAXY_NO_FOCUS_NOTE);refitNow();props.onClearSelection?.();- }, [mode, refitNow, props.onClearSelection, readerProjection, scope.reset, props.workspaceExpanded, changeTraceTypes, clearTrail]);+ }, [mode, refitNow, props.onClearSelection, readerProjection, scope.reset, props.workspaceExpanded, changeTraceTypes, clearTrail, hierarchyNoFocusNote]);/** Ein Klick ins Leere hebt im Ausschnitt nur die Markierung auf (Handtest* K9). Bis dahin verliess er den Ausschnitt samt Ebenen und Pfad, ohne@@ -2055,7 +2067,7 @@ export default function GalaxyPanel(props: GalaxyPanelProps): JSX.Element {<button type="button" disabled={current} aria-current={current ? 'true' : undefined} onClick={() => {recentMenu.close();jumpToRecent(entry);- }}><strong>{entry.scope?.name}</strong><span>{historyEntryDetail(entry)}</span></button>+ }}><strong>{entry.scope && scopeDisplayName(entry.scope)}</strong><span>{historyEntryDetail(entry)}</span></button></li>;})}</ul></details>}@@ -2073,8 +2085,13 @@ export default function GalaxyPanel(props: GalaxyPanelProps): JSX.Element {useToolbarFit(explorationBar, Boolean(props.workspaceExpanded && scope.scope));/* Was die Leiste sonst noch braucht (K3): Quelle der Wurzel, Gruppen und was ausserhalb der Limits liegt. */- const openRoot = props.workspaceExpanded && scopedRoot?.file_path+ const openRoot = props.workspaceExpanded && scopedRoot && nodeFilePath(scopedRoot)? () => props.onOpenNode(layoutNodeForSelection(layout, scopedRoot) ?? scopedRoot) : undefined;+ /* Runde 4 (N1): die Wurzel heisst, wie die Galaxie sie zeigt; ein Branch-Knoten "django-demo · detached HEAD". */+ // Ordner und Dateien behalten ihren Pfad; ein Knoten nimmt seine Art von der geladenen Wurzel, wo es sie gibt.+ const rootShown = !scope.scope ? ''+ : (scope.scope.kind === 'node' || scope.scope.kind === 'symbol') && scopedRoot && scopedRoot.qualified_name === scope.scope.qualifiedName+ ? graphNodeName(scopedRoot) : scopeDisplayName(scope.scope);const groupCount = mode === 'galaxy' && organic ? organic.groups.length : 0;const groupsText = groupCount > 1 ? galaxyToolbarText.groupsTitle(groupCount) : undefined;const outsideLimits = props.workspaceExpanded && data && shown && (shown.nodes.length < data.nodes.length || shown.edges.length < data.edges.length)@@ -2493,7 +2510,7 @@ export default function GalaxyPanel(props: GalaxyPanelProps): JSX.Element {name={`graph-mode-${candidate}`}text={candidate === 'hierarchy' && projection === undefined- ? HIERARCHY_UNAVAILABLE_TITLE+ ? props.workspaceExpanded ? galaxyHierarchyNoteText.unavailableWorkspace : galaxyHierarchyNoteText.unavailable: !visible? graphModeCollapsedTitle(candidate): mode === candidate && candidate === 'galaxy' && !props.workspaceExpanded@@ -2626,9 +2643,9 @@ export default function GalaxyPanel(props: GalaxyPanelProps): JSX.Element {* die Tastatur weiter im Menue "⋯".*/}{props.workspaceExpanded && openRoot- ? <button type="button" className="atlas-graph-scope-name" data-fit-whole="" onClick={openRoot} aria-label={galaxyToolbarText.openRootLabel(scope.scope.name)}- title={galaxyToolbarText.openRootTitle(scope.scope.name, scopedRoot?.file_path ?? '', scopedRoot?.start_line)}>{scope.scope.name}</button>- : <strong className="atlas-graph-scope-name" data-fit-whole="" title={scope.scope.name}>{scope.scope.name}</strong>}+ ? <button type="button" className="atlas-graph-scope-name" data-fit-whole="" onClick={openRoot} aria-label={galaxyToolbarText.openRootLabel(rootShown)}+ title={galaxyToolbarText.openRootTitle(rootShown, scopedRoot?.file_path ?? '', scopedRoot?.start_line)}>{rootShown}</button>+ : <strong className="atlas-graph-scope-name" data-fit-whole="" title={scopeTitle(scope.scope)}>{rootShown}</strong>}{props.workspaceExpanded && <select aria-label="Trace direction" title={galaxyToolbarText.traceTitle} value={scope.direction}onChange={event => scope.setDirection(event.target.value as 'both' | 'inbound' | 'outbound')}><option value="both">Both directions</option><option value="inbound">Incoming</option><option value="outbound">Outgoing</option>@@ -2660,7 +2677,7 @@ export default function GalaxyPanel(props: GalaxyPanelProps): JSX.Element {<FitLabel wide={galaxyToolbarText.expand} narrow={galaxyToolbarText.expandNarrow} /></button></Hint>{props.workspaceExpanded && (mode === 'galaxy' || scopedProjection) && <>- <PathPicker nodes={pathCandidates} onPick={node => { setTrail({ key: organicKey, kind: 'path', target: node.id, name: node.name }); setTrailStep(0); }} />+ <PathPicker nodes={pathCandidates} onPick={node => { setTrail({ key: organicKey, kind: 'path', target: node.id, name: graphNodeName(node) }); setTrailStep(0); }} /><button type="button" disabled={rootCalls.length === 0} aria-pressed={trail?.key === organicKey && trail.kind === 'calls'}title={rootCalls.length ? galaxyPathText.callOrderTitle : galaxyPathText.callOrderUnavailable}onClick={() => { if (trail?.key === organicKey && trail.kind === 'calls') clearTrail(); else { setTrail({ key: organicKey, kind: 'calls' }); setTrailStep(0); } }}>diff --git a/graph-ui/src/galaxy/GraphScene.tsx b/graph-ui/src/galaxy/GraphScene.tsxindex 5a189aa72..c7c23c364 100644--- a/graph-ui/src/galaxy/GraphScene.tsx+++ b/graph-ui/src/galaxy/GraphScene.tsx@@ -132,6 +132,7 @@ import { ScreenNodeSeparation } from './ScreenNodeSeparation';import { PathLayer, pathNodeIds, type ScenePath } from './PathLayer';import { pathFrame } from './path-frame';import { markerNameRect, placeMarkerNames, type MarkerName } from './marker-names';+import { graphNodeName } from './node-names';import type { LabelBox } from './NodeLabels';import { FRAME_MIN_DISTANCE, containShift, fitCamera, flatBounds, frameDistance, orthographicZoom } from './camera-frame';import type { CameraFit, FrameBox } from './camera-frame';@@ -483,8 +484,9 @@ export function RootMarkers({ nodes }: { nodes: readonly GraphNode[] }): JSX.Elefor (const node of nodes) {const name = markers.current.get(node.id)?.querySelector('b');if (!name) continue;- let size = sizes.current.get(node.name);- if (!size && name.offsetWidth > 0) { size = { width: name.offsetWidth, height: name.offsetHeight }; sizes.current.set(node.name, size); }+ const shown = graphNodeName(node);+ let size = sizes.current.get(shown);+ if (!size && name.offsetWidth > 0) { size = { width: name.offsetWidth, height: name.offsetHeight }; sizes.current.set(shown, size); }if (!size) continue;point.set(node.x, node.y, node.z).project(camera);if (!(point.z >= -1 && point.z <= 1)) continue;@@ -514,7 +516,7 @@ export function RootMarkers({ nodes }: { nodes: readonly GraphNode[] }): JSX.Ele<span className="atlas-galaxy-root-marker" data-testid="atlas-galaxy-root-marker" data-qn={node.qualified_name ?? node.name}ref={(element) => { if (element) markers.current.set(node.id, element); else markers.current.delete(node.id); }}><i aria-hidden="true" />- <b>{node.name}</b>+ <b>{graphNodeName(node)}</b></span></Html>))}diff --git a/graph-ui/src/galaxy/NodeLabels.tsx b/graph-ui/src/galaxy/NodeLabels.tsxindex 267a580e5..89689d372 100644--- a/graph-ui/src/galaxy/NodeLabels.tsx+++ b/graph-ui/src/galaxy/NodeLabels.tsx@@ -39,6 +39,7 @@import { useCallback, useEffect, useMemo, useRef } from 'react';import { useFrame } from '@react-three/fiber';import * as THREE from 'three';+import { graphNodeName } from './node-names';import type { GraphNode } from './types';/** Ein gezeichneter Namenskasten in Weltkoordinaten. */@@ -179,9 +180,11 @@ function NodeLabelSprite({/** Der gezeichnete Sprite, damit die Entfernungspruefung ihn erreicht. */spriteRef?: ((sprite: THREE.Sprite | null) => void) | undefined;}) {+ // The shown name: a Branch node reads "django-demo · detached HEAD", not "DETACHED" (round 4, N1).+ const text = graphNodeName(node);const label = useMemo(- () => createLabelTexture(node.name, node.color, maxTextWidth),- [node.name, node.color, maxTextWidth],+ () => createLabelTexture(text, node.color, maxTextWidth),+ [text, node.color, maxTextWidth],);useEffect(() => {diff --git a/graph-ui/src/galaxy/NodeTooltipCard.tsx b/graph-ui/src/galaxy/NodeTooltipCard.tsxindex 26a6936b2..2494b1a34 100644--- a/graph-ui/src/galaxy/NodeTooltipCard.tsx+++ b/graph-ui/src/galaxy/NodeTooltipCard.tsx@@ -16,7 +16,9 @@*/import type { JSX } from 'react';+import { galaxyCardText } from './galaxy-strings';import { HoverCardHtml } from './hover-layer';+import { graphNodeIndexName, graphNodeName, nodeFilePath } from './node-names';import type { GraphNode } from './types';/** Der Zeilenbereich, wenn das Layout einen fuehrt. */@@ -39,8 +41,10 @@ export function tooltipRows(node: GraphNode): [string, string][] {if (node.out_calls !== undefined) {rows.push(['fan-out', String(node.out_calls)]);}+ // Zeile 0 ist keine Zeile: so antwortet query_graph fuer einen Knoten ohne Quelle (Runde 4, N1).if (node.start_line !== undefined &&+ node.start_line > 0 &&node.end_line !== undefined &&node.end_line >= node.start_line) {@@ -51,26 +55,29 @@ export function tooltipRows(node: GraphNode): [string, string][] {/** Was ein Klick auf diesen Knoten tun wird, als Satz. */export function tooltipAction(node: GraphNode): string {- return node.file_path === undefined || node.file_path.length === 0- ? 'no file in the index: nothing to open'- : 'click to open the file and follow the twin';+ const file = nodeFilePath(node);+ return file === undefined || file.length === 0 ? galaxyCardText.nothingToOpen : galaxyCardText.openFile;}export function NodeTooltipCard({ node }: { node: GraphNode }): JSX.Element {const rows = tooltipRows(node);const lines = lineRangeOf(node);+ // Round 4 (N1): a Branch node shows what it is, its name in the index stands where a file would, and "{}" is no file.+ const file = nodeFilePath(node);+ const indexName = graphNodeIndexName(node);return (/* Review zu K29: in der Ebene der Hover-Karten, ueber den Flaechen der Galaxie (hover-layer.tsx). */<HoverCardHtml position={[node.x, node.y + node.size * 0.7, node.z]}><div className="atlas-galaxy-card" data-testid="atlas-galaxy-card"><div className="atlas-galaxy-card-head"><span className="atlas-galaxy-card-dot" style={{ backgroundColor: node.color }} />- <span className="atlas-galaxy-card-name">{node.name}</span>+ <span className="atlas-galaxy-card-name">{graphNodeName(node)}</span><span className="atlas-galaxy-card-label">{node.label}</span></div>- {node.file_path !== undefined && node.file_path.length > 0 && (+ {indexName !== undefined && <p className="atlas-galaxy-card-path">{indexName}</p>}+ {file !== undefined && file.length > 0 && (<p className="atlas-galaxy-card-path">- {node.file_path}+ {file}{lines.length > 0 && <span className="atlas-galaxy-card-lines"> {lines}</span>}</p>)}diff --git a/graph-ui/src/galaxy/PathLayer.tsx b/graph-ui/src/galaxy/PathLayer.tsxindex ce8eeca64..d9c1294fd 100644--- a/graph-ui/src/galaxy/PathLayer.tsx+++ b/graph-ui/src/galaxy/PathLayer.tsx@@ -21,6 +21,7 @@ import { useFrame, useThree } from '@react-three/fiber';import { Html } from '@react-three/drei';import * as THREE from 'three';import { edgeColor } from '../graph/edge-style';+import { graphNodeName } from './node-names';import { placeAlongSegment, type ScreenRect } from './path-frame';import type { ScopePathStep } from './scope-path';import type { GraphNode } from './types';@@ -180,7 +181,7 @@ export function PathLayer({ nodes, path, namedRoots }: {<span className="atlas-galaxy-path-node" data-active={active} data-node={node.id}{...(active ? { 'data-testid': 'atlas-galaxy-path-step' } : {})}><i aria-hidden="true" />- <b>{node.name}</b>+ <b>{graphNodeName(node)}</b></span></Html>);diff --git a/graph-ui/src/galaxy/ScopePathControls.tsx b/graph-ui/src/galaxy/ScopePathControls.tsxindex d902267eb..22be82cae 100644--- a/graph-ui/src/galaxy/ScopePathControls.tsx+++ b/graph-ui/src/galaxy/ScopePathControls.tsx@@ -1,6 +1,7 @@import { useMemo, useRef, useState } from 'react';import type { KeyboardEvent } from 'react';import { galaxyPathText as text } from './galaxy-strings';+import { graphNodeName, graphNodeTitle, nodeFilePath } from './node-names';import type { ScopePathStep } from './scope-path';import type { GraphNode } from './types';import { FitLabel } from './toolbar-fit';@@ -20,13 +21,14 @@ export function PathPicker({ nodes, onPick }: { nodes: readonly GraphNode[]; onPconst matches = useMemo(() => {const needle = query.trim().toLocaleLowerCase();// Name matches first, as in the node search: exact, prefix, anywhere, then path or qualified name.- const rank = (node: GraphNode) => {- const name = node.name.toLocaleLowerCase();+ // A Branch node is found by its shown name and by its name in the index (round 4, N1).+ const rank = (node: GraphNode) => Math.min(...[graphNodeName(node), node.name].map(value => {+ const name = value.toLocaleLowerCase();return name === needle ? 0 : name.startsWith(needle) ? 1 : name.includes(needle) ? 2 : 3;- };- return nodes.filter(node => !needle || [node.name, node.qualified_name, node.file_path]+ }));+ return nodes.filter(node => !needle || [graphNodeName(node), node.name, node.qualified_name, nodeFilePath(node)].some(value => value?.toLocaleLowerCase().includes(needle)))- .sort((a, b) => rank(a) - rank(b) || a.name.localeCompare(b.name) || a.id - b.id);+ .sort((a, b) => rank(a) - rank(b) || graphNodeName(a).localeCompare(graphNodeName(b)) || a.id - b.id);}, [nodes, query]);return <details ref={details} className="atlas-graph-path-picker" onKeyDown={closeOnEscape}><summary title={text.pathToTitle}><FitLabel wide={text.pathTo} narrow={text.pathToNarrow} /></summary>@@ -37,7 +39,7 @@ export function PathPicker({ nodes, onPick }: { nodes: readonly GraphNode[]; onP<button type="button" onClick={() => {onPick(node);if (details.current) details.current.open = false;- }}><strong>{node.name}</strong><span>{node.file_path ?? node.qualified_name ?? node.label}</span></button>+ }} title={graphNodeTitle(node)}><strong>{graphNodeName(node)}</strong><span>{nodeFilePath(node) ?? node.qualified_name ?? node.label}</span></button></li>)}</ul>{matches.length === 0 && <small>{text.pathNoMatch}</small>}{matches.length > PICKER_LIMIT && <small>{text.pathMore(matches.length - PICKER_LIMIT)}</small>}diff --git a/graph-ui/src/galaxy/branch-names.scene.test.tsx b/graph-ui/src/galaxy/branch-names.scene.test.tsxnew file mode 100644index 000000000..87523a1f4--- /dev/null+++ b/graph-ui/src/galaxy/branch-names.scene.test.tsx@@ -0,0 +1,113 @@+// @vitest-environment jsdom+/*+ * Hand test 2026-10-04, round 4 (N1): wherever the Galaxy shows a node by+ * name, a Branch node carries what it is ("django-demo · detached HEAD"),+ * not the bare "DETACHED" that reads like a folder. The real name stays in+ * the tooltip and the detail line.+ */+import { act, type ReactNode } from 'react';+import { createRoot, type Root } from 'react-dom/client';+import { afterEach, beforeEach, expect, it, vi } from 'vitest';+import { PerspectiveCamera } from 'three';+import type { GraphNode } from './types';++const fiber = vi.hoisted(() => ({ frames: [] as ((state: unknown, delta: number) => void)[] }));+let scene: { camera: PerspectiveCamera; gl: { domElement: HTMLCanvasElement }; size: { width: number; height: number } };+vi.mock('@react-three/fiber', async importOriginal => ({+ ...await importOriginal<typeof import('@react-three/fiber')>(),+ useFrame: (callback: (state: unknown, delta: number) => void) => { fiber.frames.push(callback); },+ useThree: (select?: (state: unknown) => unknown) => (select ? select(scene) : scene),+}));+vi.mock('@react-three/drei', async importOriginal => ({+ ...await importOriginal<typeof import('@react-three/drei')>(),+ Html: ({ children }: { children: ReactNode }) => <div data-testid="html">{children}</div>,+}));++const { RootMarkers } = await import('./GraphScene');+const { NodeTooltipCard } = await import('./NodeTooltipCard');+const { NodeLabels } = await import('./NodeLabels');+const { PathPicker } = await import('./ScopePathControls');+const { default: GalaxyNavigator, choicesFromSearchHits } = await import('./GalaxyNavigator');++let host: HTMLDivElement, root: Root;+beforeEach(() => {+ (globalThis as unknown as Record<string, unknown>).IS_REACT_ACT_ENVIRONMENT = true;+ const canvas = document.createElement('canvas');+ canvas.getBoundingClientRect = () => ({ left: 0, top: 0, right: 800, bottom: 600, width: 800, height: 600, x: 0, y: 0, toJSON: () => ({}) });+ scene = { camera: new PerspectiveCamera(50, 800 / 600, 0.1, 100000), gl: { domElement: canvas }, size: { width: 800, height: 600 } };+ fiber.frames = [];+ host = document.createElement('div'); document.body.append(host); root = createRoot(host);+});+afterEach(() => { act(() => root.unmount()); host.remove(); vi.restoreAllMocks(); });++const detached: GraphNode = { id: 2, x: 0, y: 0, z: 0, size: 5.8, color: '#ffc070', label: 'Branch', name: 'DETACHED',+ qualified_name: 'django-demo.__branch__.detached', file_path: '{}', status: 'structural', in_calls: 0, out_calls: 0 };+const workingTree: GraphNode = { ...detached, id: 3, name: 'working-tree', qualified_name: 'cbm.__branch__.working-tree' };+const github: GraphNode = { ...detached, id: 4, label: 'Folder', name: '.github', qualified_name: 'django-demo..github', file_path: '.github' };++it('N1: the root marker names the Branch node for what it is', () => {+ act(() => root.render(<RootMarkers nodes={[detached, github]} />));+ expect([...host.querySelectorAll('[data-testid="atlas-galaxy-root-marker"] b')].map(name => name.textContent))+ .toEqual(['django-demo · detached HEAD', '.github']);+});++it('N1: the hover card shows the name, keeps the real one in its detail line, and offers no file to open', () => {+ // query_graph answers a Branch node with the lines 0 to 0; that is no line range ("lines 1" in the browser).+ act(() => root.render(<NodeTooltipCard node={{ ...workingTree, start_line: 0, end_line: 0 }} />));+ expect([...host.querySelectorAll('.atlas-galaxy-card-row dt')].map(term => term.textContent)).toEqual(['fan-in', 'fan-out']);+ const card = host.querySelector('[data-testid="atlas-galaxy-card"]')!;+ expect(card.querySelector('.atlas-galaxy-card-name')?.textContent).toBe('cbm · working tree');+ expect(card.querySelector('.atlas-galaxy-card-label')?.textContent).toBe('Branch');+ expect(card.querySelector('.atlas-galaxy-card-path')?.textContent).toBe('Name in the index: working-tree (cbm.__branch__.working-tree)');+ expect(card.querySelector('.atlas-galaxy-card-action')?.textContent).toBe('no file in the index: nothing to open');+ expect(card.textContent).not.toContain('{}');+});++it('N1: the name drawn into the label texture of the scene is the shown name', () => {+ const drawn: string[] = [];+ const context = { font: '', textAlign: '', textBaseline: '', lineJoin: '', lineWidth: 0, strokeStyle: '', fillStyle: '',+ measureText: (text: string) => ({ width: text.length * 30 }), scale: () => {}, strokeText: () => {}, fillText: (text: string) => { drawn.push(text); } };+ vi.spyOn(HTMLCanvasElement.prototype, 'getContext').mockImplementation((() => context) as unknown as HTMLCanvasElement['getContext']);+ vi.spyOn(console, 'error').mockImplementation(() => {});+ act(() => root.render(<NodeLabels nodes={[detached, github]} highlightedIds={null} maxTextWidth={4000} />));+ expect(drawn.sort()).toEqual(['.github', 'django-demo · detached HEAD']);+});++it('N1: Path to lists the Branch node by its shown name and finds it by either name', async () => {+ const pick = vi.fn();+ await act(async () => root.render(<PathPicker nodes={[github, detached]} onPick={pick} />));+ const names = () => [...host.querySelectorAll('.atlas-graph-path-menu li button strong')].map(name => name.textContent);+ expect(names()).toEqual(['.github', 'django-demo · detached HEAD']);+ const input = host.querySelector<HTMLInputElement>('.atlas-graph-path-menu input')!;+ const type = async (value: string) => act(async () => {+ Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')!.set!.call(input, value);+ input.dispatchEvent(new Event('input', { bubbles: true }));+ });+ await type('detached head');+ expect(names()).toEqual(['django-demo · detached HEAD']);+ await type('DETACHED');+ expect(names()).toEqual(['django-demo · detached HEAD']);+ // The detail line shows the qualified name, never the "{}" the index stores as its file.+ expect(host.querySelector('.atlas-graph-path-menu li button span')?.textContent).toBe('django-demo.__branch__.detached');+});++it('N1: the search lists the Branch node by its shown name, keeps the real one in the tooltip, and makes no file of "{}"', async () => {+ const choices = choicesFromSearchHits([{ name: 'DETACHED', qualified_name: 'django-demo.__branch__.detached', label: 'Branch', file_path: '{}' }]);+ expect(choices.map(choice => [choice.kind, choice.name, choice.detail])).toEqual([['Branch', 'django-demo · detached HEAD', 'django-demo.__branch__.detached']]);+ // The scope keeps the name of the index: it is the identity the chat and the history read.+ expect(choices[0]!.scope).toEqual({ kind: 'symbol', qualifiedName: 'django-demo.__branch__.detached', name: 'DETACHED' });++ const select = vi.fn();+ await act(async () => root.render(<GalaxyNavigator embedded nodes={[detached, github]} onSelect={select} />));+ const input = host.querySelector<HTMLInputElement>('input[aria-label="Find a graph node"]')!;+ await act(async () => {+ input.focus();+ Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')!.set!.call(input, 'detached');+ input.dispatchEvent(new Event('input', { bubbles: true }));+ });+ const results = [...host.querySelectorAll<HTMLButtonElement>('.atlas-galaxy-search-results li button')];+ expect(results.map(button => button.querySelector('strong')?.textContent)).toEqual(['django-demo · detached HEAD']);+ expect(results[0]!.title).toContain('Name in the index: DETACHED (django-demo.__branch__.detached)');+ await act(async () => results[0]!.click());+ expect(select).toHaveBeenCalledWith(detached);+});diff --git a/graph-ui/src/galaxy/galaxy-model.ts b/graph-ui/src/galaxy/galaxy-model.tsindex 12f66c6f9..5a51d173d 100644--- a/graph-ui/src/galaxy/galaxy-model.ts+++ b/graph-ui/src/galaxy/galaxy-model.ts@@ -27,6 +27,7 @@import { symbolKindOf } from '../provider/cbm-rpc-provider';import { twinTargetOf } from '../twin/twin-target';import type { SymbolRef } from '../core/focus-protocol';+import { graphNodeName } from './node-names';import type { GraphData, GraphEdge, GraphNode } from './types';/**@@ -132,7 +133,7 @@ export function missingNodeNote(name: string, budget: number = LAYOUT_NODE_BUDGE/** Was das Panel sagt, wenn ein angeklickter Knoten keine Datei hat. */export function unopenableNodeNote(node: GraphNode): string {- return `${node.name} is a ${node.label} node and carries no file in the index, so there is nothing to open`;+ return `${graphNodeName(node)} is a ${node.label} node and carries no file in the index, so there is nothing to open`;}/** Was das Panel sagt, solange kein Symbol im Fokus steht. */diff --git a/graph-ui/src/galaxy/galaxy-strings.ts b/graph-ui/src/galaxy/galaxy-strings.tsindex ec6bf5e1a..f250b30df 100644--- a/graph-ui/src/galaxy/galaxy-strings.ts+++ b/graph-ui/src/galaxy/galaxy-strings.ts@@ -193,3 +193,55 @@ export const galaxyToolbarText = {expandNarrow: '+1',outsideLimits: (nodes: number, edges: number) => `${nodes.toLocaleString()} nodes · ${edges.toLocaleString()} edges outside render limits`,};++/**+ * The names of Branch nodes (hand test 2026-10-04, round 4, N1). The index+ * puts one Branch node above the top level folders and files: the checkout it+ * read. Its own name is the branch, "DETACHED" for a detached HEAD or+ * "working-tree" where no branch is known, and on its own that read like a+ * folder of that name. The shown name says what it is; the real one stays in+ * the tooltip and the detail line (node-names.ts).+ */+export interface BranchNameWords {+ detached: string;+ workingTree: string;+ branch: (name: string) => string;+ /** The project in front: "django-demo · detached HEAD". */+ inProject: (project: string, what: string) => string;+}++export const galaxyNodeNameText: BranchNameWords & {+ indexName: (name: string, qualifiedName?: string) => string;+ branchTitle: (shown: string, name: string, qualifiedName?: string) => string;+} = {+ detached: 'detached HEAD',+ workingTree: 'working tree',+ branch: (name: string) => `branch ${name}`,+ inProject: (project: string, what: string) => `${project} · ${what}`,+ /** The detail line of the hover card. */+ indexName: (name: string, qualifiedName?: string) => `Name in the index: ${name}${qualifiedName ? ` (${qualifiedName})` : ''}`,+ /** The tooltip wherever the shown name stands. */+ branchTitle: (shown: string, name: string, qualifiedName?: string) =>+ `${shown}: the checkout the index read, above its top level folders and files. Name in the index: ${name}${qualifiedName ? ` (${qualifiedName})` : ''}.`,+};++/** What a click on a node in the hover card will do. */+export const galaxyCardText = {+ nothingToOpen: 'no file in the index: nothing to open',+ openFile: 'click to open the file and follow the twin',+};++/**+ * The hierarchy without anything to show, and its ring (hand test+ * 2026-10-04, round 4, N2). The ring follows the symbol open in Explore's+ * reader, so the note about it stands only beside that reader; in the Galaxy+ * tab the root of a scope stands in the middle of its hierarchy.+ */+export const galaxyHierarchyNoteText = {+ /** The hierarchy chip beside Explore while there is no walk and no open symbol. */+ unavailable: 'hierarchy: open a symbol or choose where to start, then this shows what it reaches',+ /** The hierarchy chip in the Galaxy tab before a node is selected. */+ unavailableWorkspace: 'hierarchy: select a node first, then this shows what reaches it and what it reaches',+ /** Beside Explore, when no node of the walk is the symbol open there. */+ noFocus: 'None of these nodes is open in Explore; the ring marks the symbol open there.',+};diff --git a/graph-ui/src/galaxy/graph-scope.ts b/graph-ui/src/galaxy/graph-scope.tsindex 1978b7387..d87f70272 100644--- a/graph-ui/src/galaxy/graph-scope.ts+++ b/graph-ui/src/galaxy/graph-scope.ts@@ -1,6 +1,7 @@import { RpcIntelligenceClient } from '../provider/rpc-client';import { escapeLiteral } from '../provider/cypher';import type { QueryGraphResult } from '../provider/rpc-schemas';+import { graphNodeName, nodeFilePath } from './node-names';import { readerGraphFocus, type SourceFocusRange } from './reader-graph-focus';import type { GraphData, GraphEdge, GraphNode } from './types';import type { GraphNeighborhoodTransaction } from './graph-neighborhood-cache';@@ -77,9 +78,11 @@ export async function readGraphPages(client: GraphQueryClient, project: string,const languageColors: Record<string, string> = { ts: '#6ea6be', tsx: '#6ea6be', js: '#c3b775', jsx: '#c3b775', c: '#92a8b4', h: '#92a8b4', cpp: '#b28da6', py: '#8daf88', go: '#77b2b4', rs: '#bd947c', java: '#bd9281', cs: '#a392bb', rb: '#b78288', swift: '#bf9b85', kt: '#af97ba' };function readNode(row: Record<string, string>, prefix: string, layout: Map<number, GraphNode>): GraphNode {const identity = id(row[`${prefix}id`]), known = layout.get(identity);- const path = row[`${prefix}file`] || undefined;- return { ...known, id: identity, name: row[`${prefix}name`] || String(identity), label: row[`${prefix}label`] || known?.label || '',- qualified_name: row[`${prefix}qn`] || undefined, file_path: path,+ const name = row[`${prefix}name`] || String(identity), label = row[`${prefix}label`] || known?.label || '', qualifiedName = row[`${prefix}qn`] || undefined;+ // A Branch node answers with the file "{}": no file (round 4, N1).+ const path = nodeFilePath({ name, label, qualified_name: qualifiedName, file_path: row[`${prefix}file`] || undefined });+ return { ...known, id: identity, name, label,+ qualified_name: qualifiedName, file_path: path,start_line: number(row[`${prefix}start_line`]), end_line: number(row[`${prefix}end_line`]),x: known?.x ?? 0, y: known?.y ?? 0, z: known?.z ?? 0,size: known?.size ?? 2.8, color: known?.color ?? languageColors[path?.split('.').pop() ?? ''] ?? '#97a6ad' };@@ -472,7 +475,8 @@ export function scopedHierarchy(scope: ScopedGraph, name: string): import('./hieconst block = new Map(keys.map(key => {const entries = columns.get(key)!;const cols = !named(key) && entries.length > SCOPED_HIERARCHY_WRAP_AT ? Math.ceil(Math.sqrt(entries.length)) : 1;- const label = named(key) ? Math.max(...entries.map(node => hierarchyLabelWidth(node.name))) : 0;+ // The width of the name that is drawn: "django-demo · detached HEAD" for a Branch node (round 4, N1).+ const label = named(key) ? Math.max(...entries.map(node => hierarchyLabelWidth(graphNodeName(node)))) : 0;const gapX = named(key) ? label + LABEL_GUTTER : SCOPED_HIERARCHY_ROW_GAP * 1.25;return [key, { entries, cols, rows: Math.ceil(entries.length / cols), gapX, width: (cols - 1) * gapX, label }] as const;}));@@ -529,7 +533,7 @@ export function scopedHierarchy(scope: ScopedGraph, name: string): import('./hieconst bandNamed = names === 'all';const rows = bandNamed ? Math.min(band.length, Math.max(BAND_MIN_ROWS, Math.ceil(Math.sqrt(band.length * 2)))) : Math.ceil(Math.sqrt(band.length));const groups = Array.from({ length: Math.ceil(band.length / rows) }, (_, at) => band.slice(at * rows, at * rows + rows));- const widths = groups.map(group => (bandNamed ? Math.max(...group.map(node => hierarchyLabelWidth(node.name))) : 0));+ const widths = groups.map(group => (bandNamed ? Math.max(...group.map(node => hierarchyLabelWidth(graphNodeName(node)))) : 0));const xs: number[] = [];groups.forEach((_, at) => xs.push(at === 0 ? 0 : xs[at - 1]! + (bandNamed ? (widths[at - 1]! + widths[at]!) / 2 + LABEL_GUTTER : SCOPED_HIERARCHY_ROW_GAP * 1.25)));const shift = -xs.at(-1)! / 2;diff --git a/graph-ui/src/galaxy/hierarchy-frame.labels.test.ts b/graph-ui/src/galaxy/hierarchy-frame.labels.test.tsnew file mode 100644index 000000000..a0d1115fe--- /dev/null+++ b/graph-ui/src/galaxy/hierarchy-frame.labels.test.ts@@ -0,0 +1,27 @@+import { expect, it } from 'vitest';+import { HIERARCHY_LABEL_PAD_X, hierarchyFrame, type HierarchyProjection } from './hierarchy-layout';++/*+ * Hand test 2026-10-04, round 4 (N1), seen in the browser: with its shown+ * name "django-demo · detached HEAD" the Branch node on the left of the+ * .github hierarchy began 23 px left of the canvas. The frame added a fixed+ * 55 units beside the outermost nodes, but a name in the hierarchy of a scope+ * is up to about 300 units wide and stands centred over its node. With the+ * widths of the names the frame reaches as far as the widest outer name.+ */+const projection = (xs: number[]): HierarchyProjection => ({+ data: { nodes: [], edges: [], total_nodes: 0 }, rootId: 0, rootKey: 'r', rootName: 'r', symbols: xs.length, depth: 2, truncated: false, cap: xs.length,+ walkDepth: 1, missing: 0, placements: xs.map((x, id) => ({ id, key: `k${id}`, name: `n${id}`, hop: id === 0 ? 0 : 1, x, y: 0 })),+} as unknown as HierarchyProjection);++it('N1: the frame of a hierarchy reaches past the widest outer name', () => {+ const plain = hierarchyFrame(projection([0, -173, 160]));+ expect(plain.width).toBeCloseTo(333 + 2 * HIERARCHY_LABEL_PAD_X, 5);+ // The left name is 204 units wide: half of it, and a margin, stand left of its node.+ const widths = [62, 204, 80];+ const named = hierarchyFrame(projection([0, -173, 160]), (placement) => widths[placement.id]!);+ const left = named.centerX - named.width / 2, right = named.centerX + named.width / 2;+ expect(left).toBeLessThanOrEqual(-173 - 204 / 2);+ // A narrow name keeps the old allowance.+ expect(right).toBeCloseTo(160 + HIERARCHY_LABEL_PAD_X, 5);+});diff --git a/graph-ui/src/galaxy/hierarchy-layout.ts b/graph-ui/src/galaxy/hierarchy-layout.tsindex 2f1c2902f..7007c0e3b 100644--- a/graph-ui/src/galaxy/hierarchy-layout.ts+++ b/graph-ui/src/galaxy/hierarchy-layout.ts@@ -155,6 +155,8 @@ export const HIERARCHY_LABEL_MAX_TEXT_WIDTH = 500;/** Wie viel Platz die Beschriftungen um die Knoten herum brauchen, fuer die Rahmung. */export const HIERARCHY_LABEL_PAD_X = 55;+/** Der Rand neben einem gemessenen Namen, wo die Rahmung seine Breite kennt (Runde 4, N1). */+export const HIERARCHY_LABEL_MARGIN_X = 12;export const HIERARCHY_LABEL_PAD_TOP = 46;export const HIERARCHY_LABEL_PAD_BOTTOM = 22;@@ -531,23 +533,28 @@ export function hierarchyIndexEdges(* meldet es (NodeLabels.onLayout). Hier wird gerahmt, nicht behauptet.** Total: eine Projektion ohne Knoten ergibt ein Rechteck um den Ursprung.+ *+ * `labelWidth` (Runde 4, N1): die Weltbreite des Namens einer Platzierung,+ * wo die Ansicht sie kennt. In der Hierarchie eines Ausschnitts ist ein Name+ * bis zu rund 300 Einheiten breit und steht mittig ueber seinem Knoten; der+ * feste Zuschlag schnitt "django-demo · detached HEAD" links am Rand ab. Ohne+ * `labelWidth` gilt der feste Zuschlag wie bisher.*/-export function hierarchyFrame(projection: HierarchyProjection): FrameBox {+export function hierarchyFrame(projection: HierarchyProjection, labelWidth?: (placement: HierarchyPlacement) => number): FrameBox {if (projection.placements.length === 0) {return { centerX: 0, centerY: 0, width: HIERARCHY_COLUMN_WIDTH, height: HIERARCHY_ROW_HEIGHT };}- let minX = Infinity;- let maxX = -Infinity;+ let left = Infinity;+ let right = -Infinity;let minY = Infinity;let maxY = -Infinity;for (const placement of projection.placements) {- minX = Math.min(minX, placement.x);- maxX = Math.max(maxX, placement.x);+ const reach = labelWidth === undefined ? HIERARCHY_LABEL_PAD_X : Math.max(HIERARCHY_LABEL_PAD_X, labelWidth(placement) / 2 + HIERARCHY_LABEL_MARGIN_X);+ left = Math.min(left, placement.x - reach);+ right = Math.max(right, placement.x + reach);minY = Math.min(minY, placement.y);maxY = Math.max(maxY, placement.y);}- const left = minX - HIERARCHY_LABEL_PAD_X;- const right = maxX + HIERARCHY_LABEL_PAD_X;const bottom = minY - HIERARCHY_LABEL_PAD_BOTTOM;const top = maxY + HIERARCHY_LABEL_PAD_TOP;return {diff --git a/graph-ui/src/galaxy/layout-source.ts b/graph-ui/src/galaxy/layout-source.tsindex b79e4b7d2..ad237831f 100644--- a/graph-ui/src/galaxy/layout-source.ts+++ b/graph-ui/src/galaxy/layout-source.ts@@ -19,6 +19,7 @@*/import { layoutUrl, LAYOUT_NODE_BUDGET, LAYOUT_ROUTE } from './galaxy-model';+import { nodeFilePath } from './node-names';import type { GraphData, GraphEdge, GraphNode, MissedGraph, NodeStatus } from './types';export interface LayoutSourceOptions {@@ -89,15 +90,18 @@ export function readGraphData(value: unknown): GraphData {if (id === undefined || x === undefined || y === undefined || z === undefined) {continue;}+ const label = text(entry['label']) ?? '';+ const qualifiedName = text(entry['qualified_name']);nodes.push({id,x,y,z,- label: text(entry['label']) ?? '',+ label,name: name ?? String(id),- file_path: text(entry['file_path']),- qualified_name: text(entry['qualified_name']),+ // Der Branch-Knoten traegt im Layout die Datei "{}"; das ist keine Datei (Runde 4, N1).+ file_path: nodeFilePath({ name: name ?? String(id), label, qualified_name: qualifiedName, file_path: text(entry['file_path']) }),+ qualified_name: qualifiedName,start_line: num(entry['start_line']),end_line: num(entry['end_line']),size: size !== undefined && size > 0 ? size : 1,diff --git a/graph-ui/src/galaxy/node-names.test.ts b/graph-ui/src/galaxy/node-names.test.tsnew file mode 100644index 000000000..ad9e27ebc--- /dev/null+++ b/graph-ui/src/galaxy/node-names.test.ts@@ -0,0 +1,50 @@+import { expect, it } from 'vitest';+import { branchNodeOf, graphNodeName, graphNodeTitle, nodeDisplayName, nodeFilePath, scopeDisplayName } from './node-names';+import type { GraphNode } from './types';++/*+ * Hand test 2026-10-04, round 4 (N1): in the hierarchy of .github the node+ * the index puts above the top level folders stood as a bare "DETACHED"+ * (django-demo, a detached HEAD) and in cbm as "working-tree". Both read+ * like a folder of that name. Branch nodes now carry what they are.+ */+const node = (extra: Partial<GraphNode>): GraphNode => ({ id: 2, x: 0, y: 0, z: 0, size: 3, color: '#ffc070', label: 'Branch', name: 'DETACHED', ...extra });+const detached = node({ qualified_name: 'django-demo.__branch__.detached', file_path: '{}' });+const workingTree = node({ name: 'working-tree', qualified_name: 'cbm.__branch__.working-tree' });+const main = node({ name: 'main', qualified_name: 'django-demo.__branch__.main' });++it('N1: a Branch node is named for what it is, with its project', () => {+ expect(graphNodeName(detached)).toBe('django-demo · detached HEAD');+ expect(graphNodeName(workingTree)).toBe('cbm · working tree');+ expect(graphNodeName(main)).toBe('django-demo · branch main');+ // A branch name with a slash and a dot keeps its real spelling, not the slug of its qualified name.+ expect(graphNodeName(node({ name: 'fix/atlas-call-feedback', qualified_name: 'cbm.__branch__.fix-atlas-call-feedback' }))).toBe('cbm · branch fix/atlas-call-feedback');+ expect(graphNodeName(node({ name: 'release-1.2', qualified_name: 'my.project.__branch__.release-1.2' }))).toBe('my.project · branch release-1.2');+});++it('N1: the label Branch and the qualified name pattern are the signals; other nodes keep their names', () => {+ expect(branchNodeOf({ name: 'DETACHED', qualifiedName: 'django-demo.__branch__.detached' })).toEqual({ project: 'django-demo', name: 'DETACHED', state: 'detached' });+ expect(branchNodeOf({ name: 'working-tree', label: 'Branch' })).toEqual({ name: 'working-tree', state: 'working-tree' });+ expect(nodeDisplayName({ name: 'working-tree', label: 'Branch' })).toBe('working tree');+ expect(nodeDisplayName({ name: 'DETACHED', label: 'Branch', project: 'django-demo' })).toBe('django-demo · detached HEAD');+ // A search hit has no name column; its name is the slug of the qualified name.+ expect(nodeDisplayName({ name: 'detached', label: 'Branch', qualifiedName: 'django-demo.__branch__.detached' })).toBe('django-demo · detached HEAD');+ expect(nodeDisplayName({ name: 'Detached', label: 'Branch', qualifiedName: 'p.__branch__.Detached' })).toBe('p · branch Detached');+ // Folders, files and symbols stay as they are, also a symbol in a module called __branch__.+ expect(graphNodeName(node({ label: 'Folder', name: '.github', qualified_name: 'django-demo..github' }))).toBe('.github');+ expect(graphNodeName(node({ label: 'Function', name: 'run', qualified_name: 'p.pkg.__branch__.run' }))).toBe('run');+ expect(branchNodeOf({ name: 'run', label: 'Function', qualifiedName: 'p.pkg.__branch__.run' })).toBeUndefined();+ expect(nodeDisplayName({ name: 'JSONBAgg', qualifiedName: 'django-demo.django.contrib.postgres.aggregates.general.JSONBAgg' })).toBe('JSONBAgg');+});++it('N1: the tooltip keeps the real name, and the "{}" the index stores as a Branch file is no file', () => {+ expect(graphNodeTitle(detached)).toBe('django-demo · detached HEAD: the checkout the index read, above its top level folders and files. '+ + 'Name in the index: DETACHED (django-demo.__branch__.detached).');+ expect(graphNodeTitle(node({ label: 'Folder', name: '.github', qualified_name: 'django-demo..github' }))).toBe('.github');+ expect(nodeFilePath(detached)).toBeUndefined();+ expect(nodeFilePath(node({ label: 'File', name: 'a.py', file_path: 'a.py' }))).toBe('a.py');+ // A scope carries no label; its qualified name is enough.+ expect(scopeDisplayName({ kind: 'node', id: 2, name: 'DETACHED', qualifiedName: 'django-demo.__branch__.detached' })).toBe('django-demo · detached HEAD');+ expect(scopeDisplayName({ kind: 'symbol', name: 'working-tree', qualifiedName: 'cbm.__branch__.working-tree' })).toBe('cbm · working tree');+ expect(scopeDisplayName({ kind: 'folder', path: '.github', name: '.github/' })).toBe('.github/');+});diff --git a/graph-ui/src/galaxy/node-names.ts b/graph-ui/src/galaxy/node-names.tsnew file mode 100644index 000000000..34bfe6c7c--- /dev/null+++ b/graph-ui/src/galaxy/node-names.ts@@ -0,0 +1,95 @@+/*+ * The name a node is shown by (hand test 2026-10-04, round 4, N1).+ *+ * For every node but one kind that is its own name. The exception is the+ * Branch node: the index puts it above the top level folders and files of a+ * project, for the checkout it read (src/pipeline/pipeline.c, pass_structure).+ * Its name is the branch, "DETACHED" for a detached HEAD and "working-tree"+ * where no branch is known, and in the hierarchy of .github a bare "DETACHED"+ * read like a folder of that name. Its qualified name is+ * `<project>.__branch__.<slug>` (src/git/git_context.c,+ * cbm_git_context_branch_qn), so the project comes from there.+ *+ * Two signals, both from the index: the label Branch, and, where a caller only+ * holds a name and a qualified name (a Galaxy scope, a history entry), that+ * pattern. A known label other than Branch always wins, so a function in a+ * module called `__branch__` keeps its name.+ *+ * Only what is shown changes. Scopes, history keys and the chat snapshot keep+ * the name of the index: they are identities, and the chat matches typed+ * names against them.+ */+import type { GraphScope } from './graph-scope';+import { galaxyNodeNameText, type BranchNameWords } from './galaxy-strings';+import type { GraphNode } from './types';++const BRANCH_MARK = '.__branch__.';++/** What a node is known by: its name, and its label or kind and qualified name where the caller has them. */+export interface NodeNameParts { name: string; label?: string; kind?: string; qualifiedName?: string; project?: string }+export interface BranchNode { project?: string; name: string; state: 'detached' | 'working-tree' | 'branch' }++export function branchNodeOf(node: NodeNameParts): BranchNode | undefined {+ const label = node.label || node.kind;+ const at = node.qualifiedName?.indexOf(BRANCH_MARK) ?? -1;+ if (label ? label !== 'Branch' : at <= 0) return undefined;+ const slug = at > 0 ? node.qualifiedName!.slice(at + BRANCH_MARK.length) : undefined;+ const project = at > 0 ? node.qualifiedName!.slice(0, at) : node.project || undefined;+ /*+ * The engine names a detached HEAD "DETACHED" with the slug "detached".+ * A search hit carries no name, only the qualified name, so its name is+ * the slug ("detached"); a branch that is really called "detached" looks+ * the same and is taken for the far more common detached HEAD. The slug+ * keeps the case of the branch, so "Detached" stays a branch.+ */+ const detached = slug === undefined ? node.name === 'DETACHED' : slug === 'detached';+ const state = detached ? 'detached' : node.name === 'working-tree' && (slug === undefined || slug === 'working-tree') ? 'working-tree' : 'branch';+ return { ...project ? { project } : {}, name: node.name, state };+}++/** The shown name: "django-demo · detached HEAD" for a Branch node, the node's own name for every other. */+export function nodeDisplayName(node: NodeNameParts, words: BranchNameWords = galaxyNodeNameText): string {+ const branch = branchNodeOf(node);+ if (!branch) return node.name;+ const what = branch.state === 'detached' ? words.detached : branch.state === 'working-tree' ? words.workingTree : words.branch(branch.name);+ return branch.project ? words.inProject(branch.project, what) : what;+}++const partsOf = (node: GraphNode): NodeNameParts => ({ name: node.name, label: node.label, qualifiedName: node.qualified_name });++export function graphNodeName(node: GraphNode): string {+ return nodeDisplayName(partsOf(node));+}++/** The tooltip: the shown name, and for a Branch node what it is and its name in the index. */+export function graphNodeTitle(node: GraphNode): string {+ const shown = graphNodeName(node);+ return branchNodeOf(partsOf(node)) ? galaxyNodeNameText.branchTitle(shown, node.name, node.qualified_name) : shown;+}++/** The detail line of a Branch node: its name in the index; undefined for every other node. */+export function graphNodeIndexName(node: GraphNode): string | undefined {+ return branchNodeOf(partsOf(node)) ? galaxyNodeNameText.indexName(node.name, node.qualified_name) : undefined;+}++/**+ * The file of a node, without the "{}" the index stores as the file of a+ * Branch node (the layout and query_graph both answer with it). Taken for a+ * path, it made the node look openable: the toolbar offered to open "{}" in+ * Explore and the search listed a file called "{}".+ */+export function nodeFilePath(node: { label?: string; name: string; qualified_name?: string; file_path?: string }): string | undefined {+ if (node.file_path === '{}' && branchNodeOf({ name: node.name, label: node.label, qualifiedName: node.qualified_name })) return undefined;+ return node.file_path;+}++/** The shown name of a Galaxy scope; folders and files keep their paths. */+export function scopeDisplayName(scope: GraphScope): string {+ return scope.kind === 'node' || scope.kind === 'symbol' ? nodeDisplayName({ name: scope.name, qualifiedName: scope.qualifiedName }) : scope.name;+}++/** The tooltip of a Galaxy scope's name. */+export function scopeTitle(scope: GraphScope): string {+ const shown = scopeDisplayName(scope);+ return (scope.kind === 'node' || scope.kind === 'symbol') && shown !== scope.name ? galaxyNodeNameText.branchTitle(shown, scope.name, scope.qualifiedName) : shown;+}diff --git a/graph-ui/src/galaxy/scope-history.ts b/graph-ui/src/galaxy/scope-history.tsindex 930ff0294..e075d2655 100644--- a/graph-ui/src/galaxy/scope-history.ts+++ b/graph-ui/src/galaxy/scope-history.ts@@ -12,6 +12,7 @@import type { NavigationHistoryOptions } from '../graph/navigation-history';import type { GraphScope, TraceDirection } from './graph-scope';import { galaxyHistoryText as text } from './galaxy-strings';+import { scopeDisplayName } from './node-names';export type ScopeTrail = { kind: 'path'; target: number; name: string } | { kind: 'calls' };@@ -45,7 +46,7 @@ export const galaxyHistoryOptions: NavigationHistoryOptions<GalaxyHistoryEntry>/** Wie ein Eintrag in einem Tooltip heisst: "n1 · 2 layers · path to n4". */export function historyEntryLabel(entry: GalaxyHistoryEntry): string {- return entry.scope ? `${entry.scope.name} · ${historyEntryDetail(entry)}` : text.allGraph;+ return entry.scope ? `${scopeDisplayName(entry.scope)} · ${historyEntryDetail(entry)}` : text.allGraph;}/** Dasselbe ohne den Namen, fuer die Zeile unter dem Namen in der Liste der letzten Wurzeln. */diff --git a/graph-ui/src/galaxy/selected-node.ts b/graph-ui/src/galaxy/selected-node.tsindex f01b8acbb..1fc89ccb5 100644--- a/graph-ui/src/galaxy/selected-node.ts+++ b/graph-ui/src/galaxy/selected-node.ts@@ -1,5 +1,6 @@import { galaxyNodeContext } from '../browser-ai/galaxy-context';import type { BrowserChatContext } from '../browser-ai/chat-model';+import { graphNodeName } from './node-names';import type { GraphData, GraphNode } from './types';/** Hierarchy render IDs are local to a projection; symbol names carry identity. */@@ -32,7 +33,7 @@ export function selectedGraphContext(layout: GraphData | undefined, selected: Gr};return {id: snapshotId,- label: `Graph node · ${selected.name.slice(0, 60)}`,+ label: `Graph node · ${graphNodeName(selected).slice(0, 60)}`,text: JSON.stringify({kind: 'graph-selection-snapshot',source: 'selected-graph-node',diff --git a/graph-ui/src/galaxy/selection-evidence.ts b/graph-ui/src/galaxy/selection-evidence.tsindex 2afc79c42..c6e215786 100644--- a/graph-ui/src/galaxy/selection-evidence.ts+++ b/graph-ui/src/galaxy/selection-evidence.ts@@ -2,6 +2,7 @@ import { useEffect } from 'react';import type { BrowserChatContext } from '../browser-ai/chat-model';import { fairShares } from '../browser-ai/galaxy-evidence';import type { GraphScope } from './graph-scope';+import { scopeDisplayName } from './node-names';import type { GraphEdge, GraphNode } from './types';export type SelectionEvidenceListener = (context: BrowserChatContext | undefined) => void;@@ -26,8 +27,9 @@ export function graphNodeEvidence(node: GraphNode) {}/** Related symbols of one edge type and direction, grouped by file. `count` is- * complete; `files` lists at most `RELATED_NAMES_PER_GROUP` symbols. */-export interface RelationshipGroup { type: string; count: number; files: { path: string; symbols: { name: string; kind?: string }[] }[] }+ * complete; `files` lists at most `RELATED_NAMES_PER_GROUP` symbols. A reader+ * gives a Branch symbol the `project` of the snapshot, for its shown name. */+export interface RelationshipGroup { type: string; count: number; files: { path: string; symbols: { name: string; kind?: string; project?: string }[] }[] }export interface ScopeRelationships {incomingSymbols: number;outgoingSymbols: number;@@ -124,10 +126,12 @@ export interface GalaxyScope {}/** Every scope edge is classified against the roots first; only the names are- * bounded afterwards. Render budgets are a drawing concern and stay out of it. */+ * bounded afterwards. Render budgets are a drawing concern and stay out of it.+ * The label is the name the Galaxy shows ("django-demo · detached HEAD" for a+ * Branch node, round 4, N1); the snapshot keeps the names of the index. */export function galaxyScopeEvidence(scope: GalaxyScope): SelectionEvidence {const roots = scope.nodes.filter(node => scope.roots.has(node.id));- return { project: scope.project, view: 'galaxy', source: 'query_graph scoped indexed relationships', label: scope.identity.name,+ return { project: scope.project, view: 'galaxy', source: 'query_graph scoped indexed relationships', label: scopeDisplayName(scope.identity),selected: { scope: scope.identity, rootCount: roots.length, roots: roots.slice(0, ROOTS_LISTED).map(root => ({ ...graphNodeEvidence(root),documentation: root.documentation?.slice(0, ROOT_DOCUMENTATION_CHARACTERS) })), omittedRoots: Math.max(0, roots.length - ROOTS_LISTED) },scope: { depth: scope.depth, direction: scope.direction, edgeTypes: scope.edgeTypes, nodes: scope.nodes.length, edges: scope.edges.length },diff --git a/graph-ui/src/galaxy/test-scope-fetch.ts b/graph-ui/src/galaxy/test-scope-fetch.tsindex c56c2c03c..c68530d5a 100644--- a/graph-ui/src/galaxy/test-scope-fetch.ts+++ b/graph-ui/src/galaxy/test-scope-fetch.ts@@ -42,7 +42,9 @@ export function scopeFetch({ nodes, edges, gate, degrees = {} }: ScopeFetchOptiorows = nodes.filter(entry => names.includes(entry.qualified_name ?? '')).map(entry => [String(entry.id), String(degrees[entry.id]?.in ?? 0), String(degrees[entry.id]?.out ?? 0)]);} else if (query.startsWith('MATCH (n)')) {- cols = columns(''); rows = nodes.filter(entry => names.includes(entry.qualified_name ?? '')).map(values);+ // A file scope finds its roots by path.+ const files = [...query.matchAll(/n\.file_path = "([^"]+)"/g)].map(match => match[1]);+ cols = columns(''); rows = nodes.filter(entry => names.includes(entry.qualified_name ?? '') || files.includes(entry.file_path ?? '')).map(values);} else {if (gate) await gate();const inbound = query.startsWith('MATCH (b)<-');diff --git a/graph-ui/src/why/SelectionContext.branch.test.tsx b/graph-ui/src/why/SelectionContext.branch.test.tsxnew file mode 100644index 000000000..98a68ae23--- /dev/null+++ b/graph-ui/src/why/SelectionContext.branch.test.tsx@@ -0,0 +1,50 @@+// @vitest-environment jsdom+/*+ * Hand test 2026-10-04, round 4 (N1): "Selection details" named the Branch+ * node "DETACHED" and its relationships "DETACHED" as well. It names it for+ * what it is now. The node has no file (the index stores "{}" for it, which+ * Galaxy no longer takes for one), and its relationships still come from the+ * loaded scope; there is no source to read.+ */+import { act } from 'react';+import { createRoot, type Root } from 'react-dom/client';+import { afterEach, beforeEach, expect, it, vi } from 'vitest';+import SelectionContextPanel from './SelectionContext';+import type { GraphData, GraphNode } from '../galaxy/types';++let host: HTMLDivElement, root: Root;+beforeEach(() => {+ (globalThis as unknown as Record<string, unknown>).IS_REACT_ACT_ENVIRONMENT = true;+ host = document.createElement('div'); document.body.append(host); root = createRoot(host);+});+afterEach(async () => { await act(async () => root.unmount()); host.remove(); });++const node = (id: number, extra: Partial<GraphNode>): GraphNode => ({ id, x: 0, y: 0, z: 0, size: 1, color: '#fff', label: 'Folder', name: `n${id}`, ...extra });+const project = node(1, { label: 'Project', name: 'django-demo', qualified_name: 'django-demo' });+const branch = node(2, { label: 'Branch', name: 'DETACHED', qualified_name: 'django-demo.__branch__.detached' });+const github = node(4, { name: '.github', qualified_name: 'django-demo..github', file_path: '.github' });+const readme = node(5, { label: 'File', name: 'README.rst', qualified_name: 'django-demo.README.rst.__file__', file_path: 'README.rst' });+const scope: GraphData = { total_nodes: 4, nodes: [project, branch, github, readme], edges: [+ { source: 1, target: 2, type: 'HAS_BRANCH' }, { source: 2, target: 4, type: 'CONTAINS_FOLDER' }, { source: 2, target: 5, type: 'CONTAINS_FILE' }] };+const open = async () => { for (const details of host.querySelectorAll('details')) details.open = true; };++it('N1: a selected Branch node without a file is named for what it is and keeps its relationships from the scope', async () => {+ const navigate = vi.fn();+ await act(async () => root.render(<SelectionContextPanel selected={branch} path="" onNavigate={navigate} scope={{ graph: scope, complete: true, direction: 'both', depth: 1 }} />));+ await open();+ expect(host.querySelector('.selection-context-subject')?.textContent).toBe('django-demo · detached HEAD');+ expect(host.textContent).not.toContain('Select a file or symbol');+ const summaries = [...host.querySelectorAll('summary')].map(entry => entry.textContent);+ expect(summaries).toContain('Incoming relationships · 1 (HAS_BRANCH 1)');+ expect(summaries).toContain('Outgoing relationships · 2 (CONTAINS_FILE 1 · CONTAINS_FOLDER 1)');+ // Nothing to read: no source button for a node without a file.+ expect([...host.querySelectorAll('button')].map(button => button.textContent)).not.toContain('Read source evidence');+});++it('N1: the relationships of .github name the Branch node above it for what it is', async () => {+ await act(async () => root.render(<SelectionContextPanel selected={github} path=".github" onNavigate={vi.fn()} scope={{ graph: scope, complete: true, direction: 'both', depth: 1 }} />));+ await open();+ const names = [...host.querySelectorAll('.repo-map-nodes strong')].map(name => name.textContent);+ expect(names).toContain('django-demo · detached HEAD');+ expect(names).not.toContain('DETACHED');+});diff --git a/graph-ui/src/why/SelectionContext.tsx b/graph-ui/src/why/SelectionContext.tsxindex 0463767b6..05259af28 100644--- a/graph-ui/src/why/SelectionContext.tsx+++ b/graph-ui/src/why/SelectionContext.tsx@@ -3,6 +3,7 @@ import type { GraphData, GraphNode } from '../galaxy/types';import type { AgentsState } from '../agents/agent-store';import { selectionContext } from './selection-context';import { selectionScopeText } from './selection-strings';+import { graphNodeName } from '../galaxy/node-names';import { RelationshipEvidence } from '../architecture/RepositoryMap';import type { MapEvidence } from '../architecture/repository-map';import type { ScopePartial, TraceDirection } from '../galaxy/graph-scope';@@ -29,15 +30,16 @@ export default function SelectionContextPanel({ graph, selected, path, agents, oscope?: SelectionScope;}) {const inScope = Boolean(scope && selected && scope.graph.nodes.some(node => selected.qualified_name- ? node.qualified_name === selected.qualified_name && node.file_path === path : node.id === selected.id));+ ? node.qualified_name === selected.qualified_name && (node.file_path ?? '') === path : node.id === selected.id));const source = inScope ? scope!.graph : graph;const context = useMemo(() => selectionContext(source, selected, path, agents, { allRelations: inScope }), [source, selected, path, agents, inScope]);const callers = context.incoming.filter(edge => edge.type === 'CALLS');const callerFiles = new Set(callers.map(edge => edge.source.file_path).filter(Boolean));return <section className="selection-context" aria-label="Selection context" data-testid="selection-context"><h3>Selection context</h3>- {!path ? <p>Select a file or symbol to inspect its indexed connections.</p> : <>- <p className="selection-context-subject">{selected?.name ?? path}</p>+ {/* Round 4 (N1): a selected node without a file, such as a Branch node, keeps its connections and its shown name. */}+ {!path && !selected ? <p>{selectionScopeText.selectSomething}</p> : <>+ <p className="selection-context-subject">{selected ? graphNodeName(selected) : path}</p><h4>Graph evidence</h4>{!source ? <p>The repository graph is not available. Relevance cannot be established yet.</p> : <>{scope && <p className="selection-context-source" data-source={inScope ? 'scope' : 'snapshot'}>{inScope ? selectionScopeText.fromScope(scope.depth) : selectionScopeText.fromSnapshot}</p>}@@ -71,7 +73,7 @@ export default function SelectionContextPanel({ graph, selected, path, agents, o</details></li>)}</ul>}</details>}- <div className="selection-context-actions"><button onClick={() => onNavigate(path, context.selected?.start_line, context.selected?.name)}>Read source evidence</button>+ <div className="selection-context-actions">{path && <button onClick={() => onNavigate(path, context.selected?.start_line, context.selected?.name)}>{selectionScopeText.readSource}</button>}{onImpact && <button onClick={onImpact}>Assess change impact</button>}</div></>}</section>;diff --git a/graph-ui/src/why/selection-context.ts b/graph-ui/src/why/selection-context.tsindex fbd08caaa..d0ddcac71 100644--- a/graph-ui/src/why/selection-context.ts+++ b/graph-ui/src/why/selection-context.ts@@ -22,8 +22,9 @@ export interface SelectionContext {export function selectionContext(graph: GraphData | undefined, selected: GraphNode | undefined,path: string, agents?: AgentsState, options: { allRelations?: boolean } = {}): SelectionContext {const result: SelectionContext = { selected, incoming: [], outgoing: [], incomingByType: [], outgoingByType: [], entryPath: [], pathSearchLimited: false, activity: [] };- if (!path) return result;- for (const actor of agents?.actors ?? []) {+ // A selected node without a file (a Branch node, round 4, N1) still has its relationships; only a file has activity.+ if (!path && !selected) return result;+ for (const actor of path ? agents?.actors ?? [] : []) {if (actor.you) continue;for (const event of actor.events) {if (event.path === path) result.activity.push({ agent: actor.name, event });@@ -37,8 +38,8 @@ export function selectionContext(graph: GraphData | undefined, selected: GraphNo// against this snapshot before attributing any relationship to a selection.if (selected) {selected = graph.nodes.find(candidate => selected!.qualified_name- ? candidate.qualified_name === selected!.qualified_name && candidate.file_path === path- : candidate.id === selected!.id && candidate.name === selected!.name && candidate.file_path === path);+ ? candidate.qualified_name === selected!.qualified_name && (candidate.file_path ?? '') === path+ : candidate.id === selected!.id && candidate.name === selected!.name && (candidate.file_path ?? '') === path);result.selected = selected;if (!selected) return result;}diff --git a/graph-ui/src/why/selection-strings.ts b/graph-ui/src/why/selection-strings.tsindex 7e4b784d0..87adafaf6 100644--- a/graph-ui/src/why/selection-strings.ts+++ b/graph-ui/src/why/selection-strings.ts@@ -6,6 +6,8 @@const byType = (types: readonly [string, number][]) => types.map(([type, count]) => `${type} ${count.toLocaleString()}`).join(' · ');export const selectionScopeText = {+ selectSomething: 'Select a file or symbol to inspect its indexed connections.',+ readSource: 'Read source evidence',incoming: (count: number, types: readonly [string, number][]) =>`Incoming relationships · ${count.toLocaleString()}${types.length ? ` (${byType(types)})` : ''}`,outgoing: (count: number, types: readonly [string, number][]) =>