Skip to content

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.

feat(ui): replace semantic twin with selected code inspector

Martin Vogelf9ba36e5c052
diff --git a/graph-ui/src/App.tsx b/graph-ui/src/App.tsx
index 7112f49c6..bbe60d15d 100644
--- a/graph-ui/src/App.tsx
+++ b/graph-ui/src/App.tsx
@@ -172,8 +172,10 @@ import { badgesForLines } from './core/step-badge-decorator';
import type { SymbolRef } from './core/focus-protocol';
import type { SemanticIR } from './core/semantic-ir';
import { buildIr } from './ir/semantic-ir-builder';
-import TwinPanel from './twin/TwinPanel';
-import type { TwinBodyView, TwinStatus } from './twin/TwinPanel';
+import { PseudocodeView, type TwinStatus } from './twin/TwinPanel';
+import SelectedCodePanel from './twin/SelectedCodePanel';
+import { loadFileSymbols, type FileSymbolResult } from './twin/selected-code-context';
+import { inspectorChatContext, matchingInspectorIr, type SelectedCodeSnapshot } from './twin/selected-code-snapshot';
import { IrCache } from './twin/ir-cache';
import { ATLAS_WORKSPACE_ROOT, twinLocationOf, twinTargetOf, workspacePathOf } from './twin/twin-target';
import GalaxyPanel from './galaxy/GalaxyPanel';
@@ -206,11 +208,11 @@ import {
searchRows,
} from './search/overlay-model';
import type { SearchRow, SearchRowSource } from './search/overlay-model';
-import { Facet, resolvePresentation } from './twin/presentation-profile';
-import type { PresentationOverrides, PresentationProfile } from './twin/presentation-profile';
+import { Facet } from './twin/presentation-profile';
+import type { PresentationProfile } from './twin/presentation-profile';
import type { TwinRow } from './twin/twin-view-model';
import WhyPanel from './why/WhyPanel';
-import { WHY_MENU_LABEL, profileFor } from './why/why-model';
+import { WHY_MENU_LABEL } from './why/why-model';
import type { WhyIntent } from './why/why-model';
import { readWhyAnswer, recordWhyAnswer } from './why/why-store';
import type { WhyAnswer } from './why/why-store';
@@ -263,20 +265,15 @@ import { readImpact } from './impact/impact-source';
import { refRejection } from './impact/impact-model';
import type { ImpactModel, ImpactTarget } from './impact/impact-model';
import { IMPACT_MENU_LABEL, impactRefRejected } from './impact/impact-strings';
-import SidecarPanel from './llm/SidecarPanel';
-import { probeSidecar, SIDECAR_ORIGIN, SIDECAR_POLL_MS } from './llm/sidecar';
+import { SIDECAR_ORIGIN } from './llm/sidecar';
import type { CacheModel, SidecarReading, SidecarState } from './llm/sidecar';
import AtlasChatPanel from './chat/AtlasChatPanel';
import { askAtlas } from './chat/ask-atlas';
import type { ChatTurn } from './chat/ask-atlas';
-import { askModel } from './chat/chat-client';
import { commandIntent } from './chat/command-intent';
import {
CHAT_HINT_OFF,
CHAT_HINT_READY,
- REFINE_APPLIED,
- REFINE_RUNNING,
- refineRejected,
} from './chat/chat-strings';
import ExplainZone from './layout/ExplainZone';
import Splitter from './layout/Splitter';
@@ -299,13 +296,11 @@ import { NEIGHBOR_DEPTHS, NEIGHBOR_DEPTH_DEFAULT } from './compiler/fact-recipes
import type { NeighborDepth, ObservedFact, SubjectCandidate } from './compiler/fact-recipes';
import { modelClassOf } from './compiler/card-compiler';
import type { CardSource } from './compiler/card-compiler';
-import { buildRefinePrompt, nonThinkingFor, REFINE_SYSTEM_PROMPT } from './compiler/prompt-contract';
-import { applyRefinement, refineMaxTokens, refineSubjectText } from './pseudocode/refine';
+import { applyRefinement } from './pseudocode/refine';
import { readLlmPolicy } from './llm/policy';
import type { PolicyReading } from './llm/policy';
import { resolveLlmState } from './llm/llm-state';
-import { readLlmPreference, recordLlmPreference } from './llm/preference';
-import { llmChipValue, llmMenuLabel, llmMenuTitle } from './llm/strings';
+import { llmChipValue } from './llm/strings';
import SettingsPanel from './settings/SettingsPanel';
import type { SettingsMeasurement } from './settings/SettingsPanel';
import ProjectsPanel from './projects/ProjectsPanel';
@@ -762,6 +757,8 @@ export default function App(): JSX.Element {
});
const [browserAiOpen, setBrowserAiOpen] = useState(false);
const [readerSelection, setReaderSelection] = useState<ReaderSelection>();
+ const [pinnedCode, setPinnedCode] = useState<SelectedCodeSnapshot>();
+ const [fileSymbols, setFileSymbols] = useState<FileSymbolResult & { project: string; path: string; status: 'loading' | 'ready' | 'error' }>({ project: '', path: '', symbols: [], message: '', status: 'ready' });
const [chatAttachment, setChatAttachment] = useState<BrowserChatAttachment>();
const [chatGraphSelection, setChatGraphSelection] = useState<BrowserChatContext>();
const [galaxySelection, setGalaxySelection] = useState<GraphNode>();
@@ -840,6 +837,20 @@ export default function App(): JSX.Element {
const [readerMessage, setReaderMessage] = useState('pick a file in the explorer');
const [command, setCommand] = useState('');
+ useEffect(() => { setPinnedCode(undefined); }, [project]);
+ useEffect(() => {
+ if (!project || !activePath) return;
+ let cancelled = false;
+ setFileSymbols({ project, path: activePath, symbols: [], message: '', status: 'loading' });
+ void loadFileSymbols(client, project, activePath).then(result => {
+ if (!cancelled) setFileSymbols({ ...result, project, path: activePath, status: 'ready' });
+ }).catch((error: unknown) => {
+ if (!cancelled) setFileSymbols({ project, path: activePath, symbols: [], status: 'error',
+ message: error instanceof Error ? error.message : String(error) });
+ });
+ return () => { cancelled = true; };
+ }, [client, project, activePath]);
+
// Zaehler gegen Wettlaeufe: klickt jemand schnell durch zwei Dateien, darf
// die langsamere Antwort die schnellere nicht ueberschreiben.
const loadTicket = useRef(0);
@@ -855,14 +866,11 @@ export default function App(): JSX.Element {
// ------------------------------------------------------- Twin ----------
const provider = useMemo(() => new CbmRpcProvider(client, { generation: 1 }), [client]);
- const [overrides, setOverrides] = useState<PresentationOverrides>({});
// Das Profil ist seit W4a beweglich: die Antwort auf "warum bist du hier"
// setzt es. Die Regler des Lesers liegen als Overlay darauf, so wie vorher,
// und werden beim Profilwechsel geleert: eine abgeschaltete Linse, die ueber
// ein neues Profil hinweg abgeschaltet bliebe, waere eine Sektion, die
// fehlt, ohne dass jemand sagt warum.
- const [profile, setProfile] = useState<PresentationProfile>(TWIN_PROFILE);
- const presentation = useMemo(() => resolvePresentation(profile, overrides), [profile, overrides]);
const [twinSymbol, setTwinSymbol] = useState<SymbolRef | undefined>(undefined);
const [twinIr, setTwinIr] = useState<SemanticIR | undefined>(undefined);
@@ -980,7 +988,6 @@ export default function App(): JSX.Element {
const [flowView, setFlowView] = useState<FlowView | undefined>(undefined);
const [flowStep, setFlowStep] = useState(-1);
const [flowMessage, setFlowMessage] = useState(FLOW_LOADING);
- const [twinView, setTwinView] = useState<TwinBodyView>('facts');
const [imports, setImports] = useState<ImportsGroup | undefined>(undefined);
const [pseudocode, setPseudocode] = useState<PseudocodeDocument | undefined>(undefined);
const flowTicket = useRef(0);
@@ -1407,7 +1414,7 @@ export default function App(): JSX.Element {
* src/llm/llm-state.ts, Regel 3.
*/
const [llmPolicy, setLlmPolicy] = useState<PolicyReading | undefined>(undefined);
- const [llmPreferenceOn, setLlmPreferenceOn] = useState(false);
+ const llmPreferenceOn = false;
const [llmProbe, setLlmProbe] = useState<SidecarReading>(EMPTY_SIDECAR_READING);
const llmProbes = useRef(0);
@@ -1425,7 +1432,6 @@ export default function App(): JSX.Element {
const [selectedModel, setSelectedModel] = useState('');
const selectedModelRef = useRef('');
selectedModelRef.current = selectedModel;
- const askSidecarRef = useRef<((model?: string) => void) | undefined>(undefined);
// ------------------------------------------- Der Atlas-Chat (W5b) ------
@@ -1459,7 +1465,6 @@ export default function App(): JSX.Element {
* ihn zu ersetzen: das Original muss jederzeit zurueckholbar sein, und ein
* ueberschriebener Block waere genau das nicht mehr.
*/
- const [refined, setRefined] = useState<PseudocodeDocument | undefined>(undefined);
const [refineState, setRefineState] = useState<'idle' | 'running' | 'applied' | 'refused'>('idle');
const [refineMessage, setRefineMessage] = useState('');
@@ -1759,6 +1764,16 @@ export default function App(): JSX.Element {
setWhyDismissed(true);
setTabs((current) => (current.includes(path) ? current : [...current, path]));
setActivePath(path);
+ setReaderSelection(undefined);
+ // Flow steps retain their root across files. Reloading the same
+ // document also keeps ready facts until the caret resolves again.
+ if (!flowPinned.current && documentRef.current?.path !== path) {
+ setTwinSymbol(undefined);
+ setTwinIr(undefined);
+ setTwinStatus('empty');
+ setTwinName(messages.twin.noSymbol);
+ }
+ setImports(undefined);
setDocument(undefined);
loadTicket.current += 1;
const ticket = loadTicket.current;
@@ -1931,6 +1946,7 @@ export default function App(): JSX.Element {
return;
}
setTwinSymbol(symbol);
+ setTwinIr(undefined);
setTwinName(symbol.name);
setTwinStatus('loading');
setTwinMessage(TWIN_LOADING);
@@ -1958,7 +1974,7 @@ export default function App(): JSX.Element {
// dieses Effekts, und eine Abhaengigkeit darauf waere eine Schleife.
// Gelesen wird es nur, um zu entscheiden, ob schon etwas dasteht.
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [provider, irCache, project, activePath, settledCaret]);
+ }, [provider, irCache, project, activePath, settledCaret, flowStep]);
/**
* Einem Ziel folgen: das Subjekt wechselt sofort, der Editor kommt nach.
@@ -1998,6 +2014,8 @@ export default function App(): JSX.Element {
const followTarget = useCallback(
(target: SymbolRef) => {
setWorkspace('explore');
+ setFlowStep(-1);
+ flowPinned.current = false;
markFollowed(target);
const location = twinLocationOf(target);
const keepReadyTwin = location.path.length > 0
@@ -2020,6 +2038,7 @@ export default function App(): JSX.Element {
openFile(location.path);
}
setReveal((previous) => ({ line: location.line, nonce: (previous?.nonce ?? 0) + 1 }));
+ if (location.path === activePath) setSettledCaret(location.line);
},
[activePath, markFollowed, openFile, twinStatus],
);
@@ -2070,6 +2089,7 @@ export default function App(): JSX.Element {
return;
}
setFlowStep(index);
+ flowPinned.current = true;
if (step.line.sourceRef !== undefined) {
openLine(step.line.sourceRef);
}
@@ -2140,7 +2160,6 @@ export default function App(): JSX.Element {
*/
useEffect(() => {
const ir = twinIr;
- setRefined(undefined);
setRefineState('idle');
setRefineMessage('');
if (ir === undefined) {
@@ -2157,8 +2176,9 @@ export default function App(): JSX.Element {
// ist der Text, den der Reader ohnehin schon geladen hat; siehe
// src/pseudocode/imports-source.ts.
useEffect(() => {
- const ir = twinIr;
- if (ir === undefined || project.length === 0 || activePath.length === 0) {
+ const ir = matchingInspectorIr(twinIr, twinSymbol, project, activePath);
+ const uri = ir?.symbol.uri ?? twinTargetOf({ name: baseName(activePath), filePath: activePath, kind: 'module' })?.uri;
+ if (!uri || project.length === 0 || activePath.length === 0) {
setImports(undefined);
return;
}
@@ -2174,7 +2194,7 @@ export default function App(): JSX.Element {
if (cancelled || ticket !== importsTicket.current) {
return;
}
- setImports(buildImportsGroup({ imports: answer, irs: [ir], uri: ir.symbol.uri }));
+ setImports(buildImportsGroup({ imports: answer, irs: ir ? [ir] : [], uri }));
})
.catch(() => {
if (!cancelled && ticket === importsTicket.current) {
@@ -2186,7 +2206,7 @@ export default function App(): JSX.Element {
return () => {
cancelled = true;
};
- }, [activePath, document, project, provider, twinIr]);
+ }, [activePath, document, project, provider, twinIr, twinSymbol]);
/*
* Der Walk hinter dem Kasten.
@@ -2739,8 +2759,6 @@ export default function App(): JSX.Element {
const chooseIntent = useCallback(
(intent: WhyIntent) => {
- setProfile(profileFor(intent, TWIN_PROFILE));
- setOverrides({});
setWhyAnswer(recordWhyAnswer(store, project, intent));
setWhyReopened(false);
if (intent === 'understand') {
@@ -3122,7 +3140,6 @@ export default function App(): JSX.Element {
* und an nichts sonst.
*/
useEffect(() => {
- setLlmPreferenceOn(readLlmPreference(store, project).on);
setLlmPolicy(undefined);
setLlmProbe(EMPTY_SIDECAR_READING);
// Die Modellwahl und die Anzeige haengen am selben Projekt und werden
@@ -3173,56 +3190,8 @@ export default function App(): JSX.Element {
};
}, [client, project]);
- const llmMode = resolveLlmState(llmPolicy?.verdict, llmPreferenceOn);
-
- /*
- * Die Probe. Der ganze Opt-out haengt an der ersten Zeile dieses Effekts.
- *
- * Ist das LLM nicht an, wird der Timer gar nicht erst aufgehaengt und
- * `probeSidecar` nie gerufen. Es gibt keinen zweiten Aufrufer: der Zaehler
- * `llmProbes` steht hier und nur hier, und der Beweislauf liest ihn neben
- * dem Netz-Mitschnitt, damit "null Anfragen" von zwei Seiten belegt ist.
- */
- useEffect(() => {
- if (llmMode !== 'on') {
- askSidecarRef.current = undefined;
- return;
- }
- let cancelled = false;
- const ask = (model = selectedModelRef.current): void => {
- llmProbes.current += 1;
- /*
- * Die Modellwahl geht mit, und nur im Router-Modus wirkt sie
- * (src/llm/sidecar.ts). Sie kommt aus dem Ref und nicht aus der
- * Abhaengigkeitsliste: an ihr zu haengen hiesse, den Timer bei jeder
- * Wahl ab- und wieder aufzuhaengen.
- */
- void probeSidecar((url) => window.fetch(url), SIDECAR_ORIGIN, {
- model,
- })
- .then((reading) => {
- if (!cancelled) {
- setLlmProbe(reading);
- }
- })
- .catch(() => {
- if (!cancelled) {
- setLlmProbe(EMPTY_SIDECAR_READING);
- }
- });
- };
- // Der Griff fuer den Aktualisieren-Knopf des Panels. Er zeigt auf
- // dieselbe Funktion, damit jede Anfrage des Panels im selben Zaehler
- // landet wie die des Managers.
- askSidecarRef.current = ask;
- ask();
- const timer = window.setInterval(ask, SIDECAR_POLL_MS);
- return () => {
- cancelled = true;
- askSidecarRef.current = undefined;
- window.clearInterval(timer);
- };
- }, [llmMode]);
+ // Browser models have their own explicit opt-in. Saved sidecar settings cannot enable them.
+ const llmMode = resolveLlmState(llmPolicy?.verdict, false);
const llmState: SidecarState =
llmMode === 'disabled-by-policy' ? 'disabled-by-policy' : llmMode === 'off' ? 'off' : llmProbe.state;
@@ -3260,7 +3229,6 @@ export default function App(): JSX.Element {
* on the same router id. */
selectedModelRef.current = selected;
setSelectedModel(selected);
- askSidecarRef.current?.(selected);
},
[project, store],
);
@@ -3282,15 +3250,8 @@ export default function App(): JSX.Element {
* ploetzlich etwas einschaltet, um das an dieser Stelle niemand gebeten hat.
*/
const toggleLlm = useCallback(() => {
- if (llmMode === 'disabled-by-policy') {
- return;
- }
- const next = !llmPreferenceOn;
- setLlmPreferenceOn(recordLlmPreference(store, project, next).on);
- if (!next) {
- setLlmProbe(EMPTY_SIDECAR_READING);
- }
- }, [llmMode, llmPreferenceOn, project, store]);
+ setBrowserAiOpen(open => !open);
+ }, []);
// ------------------------------------------- Der Atlas-Chat (W5b) ------
@@ -3448,59 +3409,6 @@ export default function App(): JSX.Element {
[askQuestion],
);
- /**
- * Der Knopf am Pseudocode-Block.
- *
- * Er existiert nur, wenn das Modell bereit ist (die Anzeige entscheidet
- * das), und er ersetzt nichts: das Ergebnis liegt neben dem Original, und
- * eine abgelehnte Antwort laesst das Original stehen und sagt den Grund.
- */
- const refinePseudocode = useCallback(() => {
- const document = pseudocode;
- if (document === undefined || llmState !== 'ready') {
- return;
- }
- setRefineState('running');
- setRefineMessage(REFINE_RUNNING);
- void askModel({
- origin: SIDECAR_ORIGIN,
- system: REFINE_SYSTEM_PROMPT,
- user: buildRefinePrompt(refineSubjectText(document)),
- chatTemplateKwargs: nonThinkingFor(llmModel).chatTemplateKwargs,
- maxTokens: refineMaxTokens(document),
- fetch: (url, init) => window.fetch(url, init),
- // Dieselbe Wahl wie im Chat: es ist derselbe Sidecar und dieselbe
- // Route, und ein Pfad, der ein anderes Modell benutzt als der
- // andere, waere ein Panel, das aus einem zweiten Modell erklaert.
- ...(requestModel === undefined ? {} : { model: requestModel }),
- })
- .then((reply) => {
- const outcome = applyRefinement(document, reply.content);
- if (outcome.kind === 'applied') {
- setRefined(outcome.document);
- setRefineState('applied');
- setRefineMessage(REFINE_APPLIED);
- return;
- }
- setRefined(undefined);
- setRefineState('refused');
- setRefineMessage(refineRejected(outcome.reason));
- })
- .catch((error: unknown) => {
- setRefined(undefined);
- setRefineState('refused');
- setRefineMessage(
- refineRejected(error instanceof Error ? error.message : String(error)),
- );
- });
- }, [llmModel, llmState, pseudocode, requestModel]);
-
- const restorePseudocode = useCallback(() => {
- setRefined(undefined);
- setRefineState('idle');
- setRefineMessage('');
- }, []);
-
/*
* Der Layout-Griff, bei jedem Bild neu geschrieben.
*
@@ -4496,8 +4404,8 @@ export default function App(): JSX.Element {
{
key: 'llm',
shortcut: 'l',
- label: llmMenuLabel(llmState),
- title: llmMenuTitle(llmState),
+ label: messages.browserChat.menuLabel,
+ title: messages.browserChat.menuTitle,
onSelect: toggleLlm,
},
/*
@@ -4714,61 +4622,62 @@ export default function App(): JSX.Element {
/>
);
- const llm = (
- <SidecarPanel
- explained={guidance === 'explained'}
- state={llmState}
- facts={llmFacts}
- project={project}
- policyDetail={llmPolicy?.detail ?? ''}
- detail={llmProbe.detail}
- onToggle={toggleLlm}
- />
- );
-
- const twin = (
- <TwinPanel
- status={twinStatus}
- message={twinMessage}
- hint={twinHint}
- symbolName={twinName}
- symbolQualifiedName={twinSymbol?.qualifiedName}
- ir={twinIr}
- presentation={presentation}
- caretLine={caretLine}
- onDepth={(depth) => setOverrides((current) => ({ ...current, depth }))}
- onToggleFacet={(facet) =>
- setOverrides((current) => {
- const on = presentation.facets.has(facet);
- const added = (current.facetsAdded ?? []).filter((entry) => entry !== facet);
- const removed = (current.facetsRemoved ?? []).filter((entry) => entry !== facet);
- return {
- ...current,
- facetsAdded: on ? added : [...added, facet],
- facetsRemoved: on ? [...removed, facet] : removed,
- };
- })
- }
- onFollow={followTarget}
- onPointRow={pointRow}
- imports={imports}
- flow={flowView}
- flowOpen={flowOpen}
- onToggleFlow={toggleFlow}
- flowStep={flowStep}
- view={twinView}
- onView={setTwinView}
- pseudocode={refined ?? pseudocode}
- onOpenLine={openLine}
- refineAvailable={llmState === 'ready'}
- refineState={refineState}
- refineMessage={refineMessage}
- onRefine={refinePseudocode}
- onRestoreOriginal={restorePseudocode}
- voiceModel={selectedModelName}
- voiceRequestModel={requestModel}
- />
- );
+ const liveIr = matchingInspectorIr(twinIr, readerFocusSymbol, project, activePath);
+ const liveOutline = useMemo(() => liveIr ? buildPseudocode(
+ { kind: 'symbol', label: liveIr.symbol.name },
+ { irs: [liveIr], ...(layout === undefined ? {} : { graph: layout }) },
+ ) : undefined, [liveIr, layout]);
+ const liveSelection = readerSelection?.path === activePath && document?.path === activePath
+ ? readerSelection : undefined;
+ const symbolList = fileSymbols.project === project && fileSymbols.path === activePath ? fileSymbols : undefined;
+ const liveCode: SelectedCodeSnapshot = {
+ project, filePath: activePath, symbol: readerFocusSymbol, ir: liveIr,
+ selection: liveSelection, document: document?.path === activePath ? document : undefined,
+ imports: activePath ? imports : undefined,
+ pseudocode: liveOutline,
+ status: liveIr ? 'ready' : readerStatus === 'loading' ? 'loading'
+ : twinStatus === 'failed' ? 'failed' : twinStatus === 'not-indexed' ? 'not-indexed'
+ : readerFocusSymbol ? 'loading' : 'empty',
+ message: twinHint || twinMessage,
+ coverageNote: coverageNote?.text,
+ fileSymbols: symbolList?.symbols,
+ fileSymbolsStatus: symbolList?.status ?? (activePath ? 'loading' : 'ready'),
+ fileSymbolsMessage: symbolList?.message,
+ };
+ const inspector = pinnedCode?.project === project ? pinnedCode : liveCode;
+ const followInspectorTarget = (target: SymbolRef): void => {
+ setPinnedCode(undefined);
+ followTarget(target);
+ };
+ const askInspector = (): void => {
+ if (!inspector.filePath) return;
+ setChatAttachment(inspector.selection ? { ...inspector.selection, project: inspector.project, id: crypto.randomUUID() } : undefined);
+ setChatGraphSelection(inspectorChatContext(inspector, crypto.randomUUID()));
+ setBrowserAiOpen(true);
+ };
+ const showInspectorGraph = (): void => {
+ const node = layout?.nodes.find(entry => inspector.symbol?.qualifiedName
+ ? entry.qualified_name === inspector.symbol.qualifiedName
+ : entry.file_path === inspector.filePath && (entry.label === 'File' || entry.label === 'Module'));
+ if (node) {
+ setGalaxySelection(node);
+ setGalaxySelectionProject(project);
+ changeWorkspace('galaxy');
+ } else {
+ setGalaxyOn(true);
+ if (inspector.symbol) followTarget(inspector.symbol);
+ else if (inspector.filePath) openFile(inspector.filePath);
+ }
+ };
+ const selectedCode = <SelectedCodePanel {...inspector}
+ pinned={pinnedCode?.project === project}
+ onTogglePin={() => setPinnedCode(current => current?.project === project ? undefined : { ...liveCode,
+ selection: liveCode.selection ? { ...liveCode.selection } : undefined })}
+ onAsk={askInspector} onShowGraph={showInspectorGraph} onFollow={followInspectorTarget}
+ onPointRow={inspector.filePath === activePath ? pointRow : undefined}
+ onOpenFlow={inspector.symbol && inspector.symbol.qualifiedName === twinSymbol?.qualifiedName ? toggleFlow : undefined}
+ callOutline={inspector.pseudocode && inspector.symbol ? <PseudocodeView document={inspector.pseudocode}
+ symbolName={inspector.symbol.name} imports={inspector.imports} onOpenLine={openLine} /> : undefined} />;
/*
* Die fuenf Reiter des Erklaeren-Bereichs, und was gerade dahinter liegt.
@@ -4919,9 +4828,9 @@ export default function App(): JSX.Element {
testId={testId}
orientation={orientation}
label={label}
- value={shownZones[key]}
- min={bounds.min}
- max={bounds.max}
+ value={key === 'rightWidth' ? Math.max(360, shownZones[key]) : shownZones[key]}
+ min={key === 'rightWidth' ? Math.max(360, bounds.min) : bounds.min}
+ max={key === 'rightWidth' ? Math.max(360, bounds.max) : bounds.max}
invert={invert}
onChange={(value) => changeZone(key, value)}
onReset={() => resetZone(key)}
@@ -4930,7 +4839,13 @@ export default function App(): JSX.Element {
};
const attachSelection = (selection: ReaderSelection): void => {
+ if (selection.path !== activePath || document?.path !== activePath) return;
+ const range = { startLine: selection.startLine, endLine: selection.endLine
+ - (selection.endColumn === 1 && selection.endLine > selection.startLine ? 1 : 0) };
+ const symbol = symbolMatchesReader(liveCode.symbol, selection.path, range) ? liveCode.symbol : undefined;
setChatAttachment({ ...selection, project, id: crypto.randomUUID() });
+ setChatGraphSelection(inspectorChatContext({ ...liveCode, symbol,
+ ir: matchingInspectorIr(liveCode.ir, symbol, project, activePath), selection }, crypto.randomUUID()));
setBrowserAiOpen(true);
};
const clearAttachment = (id: string): void => {
@@ -4952,12 +4867,11 @@ export default function App(): JSX.Element {
chatOpen={browserAiOpen}
chatDock={<BrowserChatDock open={browserAiOpen} onClose={() => setBrowserAiOpen(false)}
pendingContext={chatGraphSelection} onContextConsumed={clearGraphSelection} onContextRemoved={clearGraphSelection}
- context={browserGraphContext(twinIr, project, activePath, twinPath)}
+ context={browserGraphContext(inspector.ir, project, inspector.filePath, inspector.symbol ? workspacePathOf(inspector.symbol.uri) : '')}
attachment={chatAttachment} onAttachmentConsumed={clearAttachment} onAttachmentRemoved={clearAttachment} />}
readerActions={<>
- {browserAiOpen && <button type="button" onClick={() => setBrowserAiOpen(false)}>{workspaceText.graphContext}</button>}
- <button type="button" disabled={!readerSelection} aria-keyshortcuts="Control+Shift+L Meta+Shift+L"
- onClick={() => { if (readerSelection) attachSelection(readerSelection); }}>{workspaceText.askSelection}</button>
+ <button type="button" disabled={!liveSelection} aria-keyshortcuts="Control+Shift+L Meta+Shift+L"
+ onClick={() => { if (liveSelection) attachSelection(liveSelection); }}>{workspaceText.askSelection}</button>
</>}
globalOverlay={<>{welcomeOpen && <WelcomePanel workspace={workspace} guidance={guidance}
onWorkspace={changeWorkspace} onGuidance={changeGuidance} onContinue={finishSetup}
@@ -4966,9 +4880,9 @@ export default function App(): JSX.Element {
onOpenProject={openProject} onClose={() => setProjectsOpen(false)} />}
{helpOpen && <HelpOverlay onClose={() => setHelpOpen(false)} />}
{settingsOpen && <SettingsPanel project={project} state={llmState} facts={llmFacts}
+ onOpenBrowserModels={() => { setSettingsOpen(false); setBrowserAiOpen(true); }}
router={llmRouter} models={llmModels} selectedModel={selectedModel}
onSelectModel={chooseModel}
- onRefresh={llmMode === 'on' ? () => askSidecarRef.current?.() : undefined}
display={display} onDisplay={changeDisplay}
onMeasurement={(measurement) => setMeasurements((current) => ({
...current, [measurement.setting]: measurement,
@@ -5046,8 +4960,7 @@ export default function App(): JSX.Element {
}
menus={menus}
status={status}
- llm={llm}
- twin={twin}
+ selectionInspector={selectedCode}
galaxy={galaxy}
zones={{
leftWidth: shownZones.leftWidth,
diff --git a/graph-ui/src/app/AtlasChrome.tsx b/graph-ui/src/app/AtlasChrome.tsx
index d14f081c1..435764253 100644
--- a/graph-ui/src/app/AtlasChrome.tsx
+++ b/graph-ui/src/app/AtlasChrome.tsx
@@ -142,6 +142,8 @@ export interface AtlasChromeProps {
onOpenBrowserAi?: () => void;
chatOpen?: boolean;
chatDock?: ReactNode;
+ /** Persistent code context, shared by the Explore sidebar and chat column. */
+ selectionInspector?: ReactNode;
readerActions?: ReactNode;
onOpenSystem?: () => void;
daemonState?: 'connected' | 'disconnected' | 'checking';
@@ -538,6 +540,23 @@ export default function AtlasChrome(props: AtlasChromeProps): JSX.Element {
const searchOpener = useRef<HTMLElement | null>(null);
const inlineGalaxyHost = useRef<HTMLDivElement>(null);
const chatGalaxyHost = useRef<HTMLDivElement>(null);
+ const inlineInspectorHost = useRef<HTMLDivElement>(null);
+ const chatInspectorHost = useRef<HTMLDivElement>(null);
+ const hasInspector = props.selectionInspector !== undefined;
+ const isExplore = (props.workspace ?? 'explore') === 'explore';
+ const inspectorAboveChat = props.chatOpen === true && isExplore && hasInspector;
+ // Moving the portal host preserves disclosures and focusable context controls.
+ const [inspectorMount] = useState(() => {
+ if (typeof document === 'undefined') return null;
+ const element = document.createElement('div');
+ element.className = 'atlas-selection-mount';
+ return element;
+ });
+ useLayoutEffect(() => {
+ const host = inspectorAboveChat ? chatInspectorHost.current : inlineInspectorHost.current;
+ if (host !== null && inspectorMount !== null) host.appendChild(inspectorMount);
+ return () => { inspectorMount?.remove(); };
+ }, [hasInspector, inspectorAboveChat, inspectorMount]);
// A stable portal keeps the WebGL canvas and its camera alive between hosts.
const [galaxyMount] = useState(() => {
if (typeof document === 'undefined') return null;
@@ -610,7 +629,7 @@ export default function AtlasChrome(props: AtlasChromeProps): JSX.Element {
*/
const zones = props.zones ?? LAYOUT_DEFAULT;
const hasSide =
- props.twin !== undefined || props.galaxy !== undefined || props.llm !== undefined;
+ hasInspector || props.twin !== undefined || props.galaxy !== undefined || props.llm !== undefined;
const stopTabKeys = (event: KeyboardEvent<HTMLInputElement>): void => {
if (event.key === 'Escape') {
@@ -793,7 +812,7 @@ export default function AtlasChrome(props: AtlasChromeProps): JSX.Element {
data-twin={hasSide}
style={{
'--atlas-left-w': `${zones.leftWidth}px`,
- '--atlas-right-w': `${zones.rightWidth}px`,
+ '--atlas-right-w': `${hasInspector ? Math.max(360, zones.rightWidth) : zones.rightWidth}px`,
'--atlas-twin-h': `${zones.twinHeight}px`,
} as CSSProperties}
>
@@ -846,10 +865,13 @@ export default function AtlasChrome(props: AtlasChromeProps): JSX.Element {
{hasSide && (
<>
{props.splitRight}
- <div className="atlas-side" data-galaxy={props.galaxy !== undefined}>
- {props.llm}
- {props.twin}
- {props.splitTwin}
+ <div className="atlas-side" data-galaxy={props.galaxy !== undefined} data-selection-inspector={hasInspector}>
+ <div ref={inlineInspectorHost} className="atlas-selection-host" hidden={!isExplore || !hasInspector || inspectorAboveChat}>
+ {inspectorMount === null && props.selectionInspector}
+ </div>
+ {!hasInspector && props.llm}
+ {!hasInspector && props.twin}
+ {!hasInspector && props.splitTwin}
<div ref={inlineGalaxyHost} className="atlas-galaxy-host">{galaxyMount === null && props.galaxy}</div>
</div>
</>
@@ -861,8 +883,9 @@ export default function AtlasChrome(props: AtlasChromeProps): JSX.Element {
</div>
{props.chatOpen === true && <Splitter testId="atlas-split-chat" orientation="vertical" label={workspaceStrings.chatWidth} value={chatWidth}
min={300} max={600} invert onChange={setChatWidth} onReset={() => setChatWidth(420)} />}
- <div className="atlas-chat-column" hidden={props.chatOpen !== true} data-graph={graphBelowChat}
+ <div className="atlas-chat-column" hidden={props.chatOpen !== true} data-graph={graphBelowChat} data-selection-inspector={inspectorAboveChat}
style={{ '--atlas-chat-graph-height': `${graphHeight}px` } as CSSProperties}>
+ <div ref={chatInspectorHost} className="atlas-selection-host" hidden={!inspectorAboveChat} />
{props.chatDock}
{graphBelowChat && <Splitter testId="atlas-split-chat-graph" orientation="horizontal"
label={workspaceStrings.chatGraphHeight} value={graphHeight} min={320} max={640} invert
@@ -870,6 +893,7 @@ export default function AtlasChrome(props: AtlasChromeProps): JSX.Element {
<div ref={chatGalaxyHost} className="atlas-galaxy-host" hidden={!graphBelowChat} />
</div>
{galaxyMount !== null && createPortal(props.galaxy, galaxyMount)}
+ {inspectorMount !== null && createPortal(props.selectionInspector, inspectorMount)}
</div>
{/*
diff --git a/graph-ui/src/app/workspace-navigation.test.tsx b/graph-ui/src/app/workspace-navigation.test.tsx
index e08d583eb..6a583e600 100644
--- a/graph-ui/src/app/workspace-navigation.test.tsx
+++ b/graph-ui/src/app/workspace-navigation.test.tsx
@@ -80,6 +80,73 @@ it('moves the same live galaxy below Explore chat and back into Galaxy', async (
expect(host.querySelector('[aria-label="Local question"]')).toBe(draft);
});
+it('keeps one selected-code inspector and its open details when chat opens and closes', async () => {
+ const props = makeProps();
+ const inspector = <section data-testid="selected-code"><details><summary>Calls</summary>Source-linked calls</details></section>;
+ const galaxy = <section className="atlas-galaxy"><canvas /></section>;
+ const chatDock = <input aria-label="Selection question" defaultValue="explain the selection" />;
+ const render = (chatOpen: boolean) => root.render(<AtlasChrome {...props} selectionInspector={inspector}
+ galaxy={galaxy} chatDock={chatDock} chatOpen={chatOpen} workspace="explore" />);
+ await act(async () => render(false));
+ const panel = host.querySelector('[data-testid="selected-code"]');
+ const details = panel!.querySelector('details')!;
+ const canvas = host.querySelector('canvas');
+ details.open = true;
+ expect(panel?.closest('.atlas-side')).not.toBeNull();
+ expect(panel?.closest('[hidden]')).toBeNull();
+
+ await act(async () => render(true));
+ const chatColumn = host.querySelector('.atlas-chat-column')!;
+ const draft = chatColumn.querySelector('[aria-label="Selection question"]')!;
+ expect(host.querySelectorAll('[data-testid="selected-code"]')).toHaveLength(1);
+ expect(host.querySelector('[data-testid="selected-code"]')).toBe(panel);
+ expect(details.open).toBe(true);
+ expect(panel?.closest('.atlas-chat-column')).toBe(chatColumn);
+ expect(panel?.closest('[hidden]')).toBeNull();
+ expect(canvas?.closest('.atlas-chat-column')).toBe(chatColumn);
+ expect(canvas?.closest('[hidden]')).toBeNull();
+ expect(panel!.compareDocumentPosition(draft) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
+ expect(draft.compareDocumentPosition(canvas!) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
+
+ await act(async () => render(false));
+ expect(host.querySelector('[data-testid="selected-code"]')).toBe(panel);
+ expect(details.open).toBe(true);
+ expect(panel?.closest('.atlas-side')).not.toBeNull();
+ expect(panel?.closest('[hidden]')).toBeNull();
+ expect(host.querySelector('canvas')).toBe(canvas);
+});
+
+it('hides selected-code context outside Explore without losing its state', async () => {
+ const props = makeProps();
+ const inspector = <input aria-label="Pinned code context" defaultValue="keep context" />;
+ await act(async () => root.render(<AtlasChrome {...props} selectionInspector={inspector} chatOpen workspace="explore" />));
+ const panel = host.querySelector('[aria-label="Pinned code context"]');
+ for (const workspace of ['galaxy', 'architecture', 'agents', 'system'] as const) {
+ await act(async () => root.render(<AtlasChrome {...props} selectionInspector={inspector} chatOpen workspace={workspace} />));
+ expect(host.querySelector('[aria-label="Pinned code context"]')).toBe(panel);
+ expect(panel?.closest('[hidden]')).not.toBeNull();
+ expect(host.querySelector('.atlas-chat-column')?.hasAttribute('hidden')).toBe(false);
+ }
+ await act(async () => root.render(<AtlasChrome {...props} selectionInspector={inspector} chatOpen workspace="explore" />));
+ expect(host.querySelector('[aria-label="Pinned code context"]')).toBe(panel);
+ expect(panel?.closest('[hidden]')).toBeNull();
+});
+
+it('replaces legacy model and twin controls when selected-code context is supplied', async () => {
+ const props = { ...makeProps(), twin: <div>Legacy twin</div>, llm: <div>Legacy sidecar</div>,
+ splitTwin: <div data-testid="legacy-twin-splitter" /> };
+ await act(async () => root.render(<AtlasChrome {...props} selectionInspector={<div>Selected context</div>} />));
+ expect(host.textContent).toContain('Selected context');
+ expect(host.textContent).not.toContain('Legacy twin');
+ expect(host.textContent).not.toContain('Legacy sidecar');
+ expect(host.querySelector('[data-testid="legacy-twin-splitter"]')).toBeNull();
+
+ await act(async () => root.render(<AtlasChrome {...props} />));
+ expect(host.textContent).toContain('Legacy twin');
+ expect(host.textContent).toContain('Legacy sidecar');
+ expect(host.querySelector('[data-testid="legacy-twin-splitter"]')).not.toBeNull();
+});
+
it('opens search on demand, retains its query, and returns keyboard focus on Escape', async () => {
const props = { ...makeProps(), commandValue: 'index', onCommandKeyDown: vi.fn() };
await act(async () => root.render(<AtlasChrome {...props} />));
diff --git a/graph-ui/src/i18n/messages.ts b/graph-ui/src/i18n/messages.ts
index 8eb624aad..c66f0eb98 100644
--- a/graph-ui/src/i18n/messages.ts
+++ b/graph-ui/src/i18n/messages.ts
@@ -58,6 +58,14 @@ const CLOSE = 'close';
const TOUR_FAILED_TEXT = 'the walk could not be prepared';
export const messages = {
+ browserChat: {
+ menuLabel: '[l]ocal chat',
+ menuTitle: 'Open local browser chat',
+ subtitle: 'Graph display and local browser models',
+ title: 'Browser models',
+ detail: 'Choose or download an optional model in chat settings. Answers run locally in this browser; code exploration works without a model.',
+ open: 'Open local chat',
+ },
/** Die Kopfzeile und die Flaechen, die zu keinem Panel gehoeren. */
app: {
brand: 'CODEATLAS',
diff --git a/graph-ui/src/settings/SettingsPanel.test.tsx b/graph-ui/src/settings/SettingsPanel.test.tsx
index e6ff99fa3..9d3e87b00 100644
--- a/graph-ui/src/settings/SettingsPanel.test.tsx
+++ b/graph-ui/src/settings/SettingsPanel.test.tsx
@@ -136,6 +136,38 @@ describe('das Panel als Ganzes', () => {
});
});
+describe('browser model settings', () => {
+ it.each(['off', 'not-running', 'ready'] as const)('replaces sidecar setup with one browser model entry when sidecar state is %s', async (state) => {
+ await render({ state, onOpenBrowserModels: vi.fn() });
+ expect(all('atlas-settings-section').map((node) => node.getAttribute('data-section')))
+ .toEqual(['browser-models', 'display']);
+ expect(find('atlas-settings-browser-models')).not.toBeNull();
+ expect(find('atlas-settings-running')).toBeNull();
+ expect(find('atlas-settings-models')).toBeNull();
+ expect(find('atlas-settings-repo-input')).toBeNull();
+ expect(find('atlas-settings-model-storage')).toBeNull();
+ expect(container.textContent).not.toMatch(/llm\/start|llm\/fetch|GGUF|\.gguf|atlas-model:/);
+ });
+
+ it('opens local chat and preserves the graph display controls', async () => {
+ const onOpenBrowserModels = vi.fn();
+ const props = await render({ onOpenBrowserModels });
+ expect(textOf(find('atlas-settings-browser-models'))).toBe('Open local chat');
+ await act(async () => (find('atlas-settings-browser-models') as HTMLButtonElement).click());
+ expect(onOpenBrowserModels).toHaveBeenCalledOnce();
+ expect(props.onSelectModel).not.toHaveBeenCalled();
+ expect(props.onRefresh).not.toHaveBeenCalled();
+ expect(find('atlas-settings-perf')).not.toBeNull();
+ expect(textOf(find('atlas-settings-storage'))).toContain('atlas-display:atlas-sample');
+ const halos = all('atlas-settings-effect')
+ .find((node) => node.getAttribute('data-effect') === 'halos');
+ const off = halos?.querySelector<HTMLButtonElement>('[data-option="false"]');
+ expect(off).not.toBeNull();
+ await act(async () => off!.click());
+ expect(props.onDisplay).toHaveBeenCalledWith({ ...DEFAULT_GRAPH_DISPLAY, halos: false });
+ });
+});
+
describe('das laufende Modell', () => {
it('zeigt die vier Zahlen, jede mit ihrer Herkunft', async () => {
await render();
diff --git a/graph-ui/src/settings/SettingsPanel.tsx b/graph-ui/src/settings/SettingsPanel.tsx
index 6923a5fe7..12f7d7b6c 100644
--- a/graph-ui/src/settings/SettingsPanel.tsx
+++ b/graph-ui/src/settings/SettingsPanel.tsx
@@ -79,6 +79,7 @@ import {
import { modelKey } from './model-preference';
const text = messages.settings;
+const browserModelsText = messages.browserChat;
/** Der Router-Aufruf, den die Meldung "kein Router" vorschlaegt. */
export const ROUTER_START_COMMAND = 'llm/start.sh';
@@ -117,6 +118,8 @@ export interface SettingsMeasurement {
}
export interface SettingsPanelProps {
+ /** Opens local browser chat instead of the legacy sidecar setup. */
+ onOpenBrowserModels?: () => void;
/** Das Projekt, dessen Wahl gespeichert wird. Leer heisst: nichts wird gemerkt. */
project: string;
/** Die Lage des Sidecars, so wie die Karte in der Seitenleiste sie zeigt. */
@@ -470,8 +473,8 @@ export default function SettingsPanel(props: SettingsPanelProps): JSX.Element {
aria-modal="false"
tabIndex={-1}
ref={root}
- data-llm={props.state}
- data-router={props.router}
+ data-llm={props.onOpenBrowserModels === undefined ? props.state : 'browser'}
+ data-router={props.onOpenBrowserModels === undefined ? props.router : undefined}
onKeyDown={(event) => {
if (event.key === 'Escape') {
event.preventDefault();
@@ -483,7 +486,7 @@ export default function SettingsPanel(props: SettingsPanelProps): JSX.Element {
<span className="atlas-settings-title" data-testid="atlas-settings-title">
{text.title}
</span>
- <span className="atlas-settings-subtitle">{text.subtitle}</span>
+ <span className="atlas-settings-subtitle">{props.onOpenBrowserModels === undefined ? text.subtitle : browserModelsText.subtitle}</span>
<button
type="button"
className="atlas-settings-close"
@@ -495,6 +498,15 @@ export default function SettingsPanel(props: SettingsPanelProps): JSX.Element {
</button>
</header>
+ {props.onOpenBrowserModels !== undefined ? (
+ <Section name="browser-models" title={browserModelsText.title}>
+ <p className="atlas-settings-text">{browserModelsText.detail}</p>
+ <button type="button" className="atlas-settings-refresh"
+ data-testid="atlas-settings-browser-models" onClick={props.onOpenBrowserModels}>
+ {browserModelsText.open}
+ </button>
+ </Section>
+ ) : <>
{/* ---------------------------------------- das laufende Modell */}
<Section name="model-running" title={text.modelTitle}>
{!llmOn && (
@@ -842,6 +854,7 @@ export default function SettingsPanel(props: SettingsPanelProps): JSX.Element {
)}
</div>
</Section>
+ </>}
{/* ---------------------------------------- Darstellung und Leistung */}
<Section name="display" title={text.displayTitle}>
@@ -1107,9 +1120,9 @@ export default function SettingsPanel(props: SettingsPanelProps): JSX.Element {
<p className="atlas-settings-note-line" data-testid="atlas-settings-storage">
{text.displayStored(displayKey(props.project))}
</p>
- <p className="atlas-settings-note-line" data-testid="atlas-settings-model-storage">
+ {props.onOpenBrowserModels === undefined && <p className="atlas-settings-note-line" data-testid="atlas-settings-model-storage">
{text.displayStored(modelKey(props.project))}
- </p>
+ </p>}
<h4 className="atlas-settings-subtitle-inline">{text.keepsTitle}</h4>
<p className="atlas-settings-text" data-testid="atlas-settings-keeps">
diff --git a/graph-ui/src/styles/workspace.css b/graph-ui/src/styles/workspace.css
index d346f8e16..d9c6ad75e 100644
--- a/graph-ui/src/styles/workspace.css
+++ b/graph-ui/src/styles/workspace.css
@@ -172,9 +172,19 @@
.atlas-chat-column { display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; }
.atlas-chat-column > .cbm-chat-dock { flex: 1; height: auto; min-height: 0; }
.atlas-chat-column[data-graph=true] { overflow-y: auto; }
-.atlas-chat-column[data-graph=true] > .cbm-chat-dock { flex: 1 0 260px; }
+.atlas-chat-column[data-graph=true] > .cbm-chat-dock { flex: 1 0 440px; min-height: 440px; }
.atlas-chat-column[data-graph=true] > .atlas-galaxy-host { flex: 0 0 var(--atlas-chat-graph-height); min-height: 320px; border-left: 1px solid var(--atlas-line); }
.atlas-chat-column > .atlas-splitter { flex: 0 0 8px; }
+.atlas-selection-host { flex: 0 0 auto; min-width: 0; min-height: 0; max-height: min(300px, 34vh); overflow: auto; border-bottom: 1px solid var(--atlas-line); }
+.atlas-selection-host[hidden] { display: none; }
+.atlas-selection-mount { min-width: 0; }
+.atlas-chat-column[data-selection-inspector=true] { overflow-y: auto; }
+.atlas-chat-column[data-selection-inspector=true] > .cbm-chat-dock { flex: 1 0 440px; min-height: 440px; }
+.atlas-chat-column:is([data-graph=true], [data-selection-inspector=true]) > .cbm-chat-dock:has(> .cbm-chat-settings) { flex-basis: 740px; min-height: 740px; }
+.atlas-chat-column:is([data-graph=true], [data-selection-inspector=true]) :is(.cbm-chat-header, .cbm-chat-modelbar) { flex-shrink: 0; }
+.atlas-chat-column:is([data-graph=true], [data-selection-inspector=true]) .cbm-chat-settings { flex-shrink: 0; max-height: 260px; }
+.atlas-chat-column:is([data-graph=true], [data-selection-inspector=true]) .cbm-chat-composer { max-height: min(50%, 240px); }
+.atlas-side[data-selection-inspector=true] > .atlas-galaxy-host { border-top: none; }
.atlas-chat-column .atlas-galaxy { min-height: 0; height: 100%; }
.atlas-chat-column .atlas-galaxy-title, .atlas-chat-column .atlas-galaxy-edgenote { display: none; }
/* Keep the canvas usable in both Explore hosts, including short windows. */
diff --git a/graph-ui/src/twin/SelectedCodePanel.test.tsx b/graph-ui/src/twin/SelectedCodePanel.test.tsx
new file mode 100644
index 000000000..61c2b7583
--- /dev/null
+++ b/graph-ui/src/twin/SelectedCodePanel.test.tsx
@@ -0,0 +1,188 @@
+// @vitest-environment jsdom
+import { act } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+import { CREATE_USER_IR } from '../test-support/twin-fixtures';
+import type { ImportsGroup } from '../pseudocode/imports-group';
+import SelectedCodePanel, { type SelectedCodePanelProps } from './SelectedCodePanel';
+
+let container: HTMLDivElement;
+let root: Root;
+
+beforeEach(() => {
+ (globalThis as unknown as Record<string, unknown>).IS_REACT_ACT_ENVIRONMENT = true;
+ container = document.createElement('div');
+ document.body.appendChild(container);
+ root = createRoot(container);
+});
+
+afterEach(async () => {
+ await act(async () => root.unmount());
+ container.remove();
+});
+
+function props(overrides: Partial<SelectedCodePanelProps> = {}): SelectedCodePanelProps {
+ return {
+ filePath: 'src/services/userService.ts',
+ symbol: CREATE_USER_IR.symbol,
+ ir: CREATE_USER_IR,
+ status: 'ready',
+ pinned: false,
+ onTogglePin: vi.fn(),
+ onAsk: vi.fn(),
+ onShowGraph: vi.fn(),
+ onFollow: vi.fn(),
+ ...overrides,
+ };
+}
+
+async function render(overrides: Partial<SelectedCodePanelProps> = {}) {
+ const value = props(overrides);
+ await act(async () => root.render(<SelectedCodePanel {...value} />));
+ return value;
+}
+
+async function click(selector: string) {
+ const element = container.querySelector<HTMLElement>(selector);
+ expect(element).not.toBeNull();
+ await act(async () => element?.click());
+}
+
+describe('Selected code inspector', () => {
+ it('starts with one file-opening hint and no empty control wall', async () => {
+ await render({ filePath: '', symbol: undefined, ir: undefined, status: 'empty' });
+ expect(container.textContent).toContain('Open a file');
+ expect(container.querySelector('.selected-code-actions')).toBeNull();
+ expect(container.querySelector('.selected-code-pin')?.hasAttribute('disabled')).toBe(true);
+ expect(container.querySelectorAll('.selected-code-fact')).toHaveLength(0);
+ });
+
+ it('offers actual file symbols before a caret has resolved a function', async () => {
+ const value = await render({ symbol: undefined, ir: undefined, status: 'empty',
+ fileSymbols: [CREATE_USER_IR.symbol], fileSymbolsStatus: 'ready',
+ fileSymbolsMessage: 'Showing the first 100 indexed symbols.' });
+ expect(container.textContent).toContain('Symbols in this file');
+ expect(container.textContent).toContain('function · 23');
+ expect(container.textContent).toContain('Showing the first 100 indexed symbols.');
+ await click('.selected-code-file li button');
+ expect(value.onFollow).toHaveBeenCalledWith(CREATE_USER_IR.symbol);
+ });
+
+ it('distinguishes unavailable file symbols from a completed empty result', async () => {
+ await render({ symbol: undefined, ir: undefined, status: 'empty',
+ fileSymbolsStatus: 'error', fileSymbolsMessage: 'Index service unavailable.' });
+ expect(container.textContent).toContain('Index service unavailable.');
+ expect(container.textContent).not.toContain('No symbols found');
+ await render({ symbol: undefined, ir: undefined, status: 'empty',
+ fileSymbolsStatus: 'ready', fileSymbols: [] });
+ expect(container.textContent).toContain('No symbols found in the current index.');
+ });
+
+ it('keeps failed symbol resolution separate from still useful file navigation', async () => {
+ await render({ symbol: undefined, ir: undefined, status: 'not-indexed',
+ message: 'This file has not been indexed.', fileSymbolsStatus: 'ready', fileSymbols: [] });
+ expect(container.querySelector('[role="status"]')?.textContent).toBe('This file has not been indexed.');
+ expect(container.querySelector('.selected-code-actions')).not.toBeNull();
+ expect(container.querySelector('[data-section="steps"]')).toBeNull();
+ });
+
+ it('preserves exact marked text and makes broader relationship scope explicit', async () => {
+ const selection = { startLine: 24, startColumn: 3, endLine: 25, endColumn: 17,
+ text: ' validateUser(input);\n\treturn `<User>`;' };
+ await render({ selection });
+ expect(container.querySelector('.selected-code-selection code')?.textContent).toBe(selection.text);
+ expect(container.textContent).toContain('24:3 to 25:17');
+ expect(container.textContent).toContain('Relationships below describe createUser');
+ expect(container.querySelector('.selected-code-selection code User')).toBeNull();
+ });
+
+ it('offers explicit graph, chat and controlled pin actions without model setup', async () => {
+ const value = await render();
+ await click('.selected-code-ask');
+ await click('.selected-code-actions button:last-child');
+ await click('.selected-code-pin');
+ expect(value.onAsk).toHaveBeenCalledOnce();
+ expect(value.onShowGraph).toHaveBeenCalledOnce();
+ expect(value.onTogglePin).toHaveBeenCalledOnce();
+ expect(container.querySelector('.selected-code-pin')?.getAttribute('aria-pressed')).toBe('false');
+ await render({ pinned: true });
+ expect(container.querySelector('.selected-code-pin')?.getAttribute('aria-pressed')).toBe('true');
+ expect(container.textContent).toContain('Context pinned.');
+ expect(container.textContent).not.toMatch(/SEMANTIC_TWIN|Reading preferences|LOCAL LLM|start\.sh|Changes/);
+ });
+
+ it('does not pin transient loading context, but lets an existing pin be released', async () => {
+ await render({ status: 'loading', ir: undefined });
+ expect(container.querySelector('.selected-code-pin')?.hasAttribute('disabled')).toBe(true);
+ await render({ status: 'loading', ir: undefined, pinned: true });
+ expect(container.querySelector('.selected-code-pin')?.hasAttribute('disabled')).toBe(false);
+ });
+
+ it('waits for file symbols before pinning file context and still allows unpinning', async () => {
+ const value = await render({ symbol: undefined, ir: undefined, status: 'empty', fileSymbolsStatus: 'loading' });
+ expect(container.querySelector('.selected-code-pin')?.hasAttribute('disabled')).toBe(true);
+ await click('.selected-code-pin');
+ expect(value.onTogglePin).not.toHaveBeenCalled();
+ const pinned = await render({ symbol: undefined, ir: undefined, status: 'empty', fileSymbolsStatus: 'loading', pinned: true });
+ expect(container.querySelector('.selected-code-pin')?.hasAttribute('disabled')).toBe(false);
+ await click('.selected-code-pin');
+ expect(pinned.onTogglePin).toHaveBeenCalledOnce();
+ await render({ symbol: undefined, ir: undefined, status: 'empty', fileSymbolsStatus: 'ready', fileSymbols: [] });
+ expect(container.querySelector('.selected-code-pin')?.hasAttribute('disabled')).toBe(false);
+ });
+
+ it('keeps outgoing facts source-linked with the original citation', async () => {
+ const value = await render();
+ expect(container.querySelector('[data-section="steps"]')?.hasAttribute('open')).toBe(false);
+ await click('[data-section="steps"] > summary');
+ await click('[data-section="steps"] .atlas-twin-row button');
+ expect(value.onFollow).toHaveBeenCalledWith(expect.objectContaining({ name: 'validateUser',
+ uri: 'file:///workspace/atlas-sample/src/util/validate.ts',
+ range: expect.objectContaining({ start: { line: 18, character: 0 } }) }));
+ await click('[data-section="steps"] [data-factpath="steps[0]"]');
+ expect(container.querySelector('.atlas-evidence-attribution')?.textContent).toContain('cbm');
+ expect(container.querySelector('.atlas-evidence-loc')?.textContent).toContain('validate.ts');
+ });
+
+ it('does not turn an unavailable answer into a checked-empty assertion', async () => {
+ await render({ ir: { ...CREATE_USER_IR,
+ steps: { value: [], state: 'unknown', evidence: [] },
+ tests: { value: [], state: 'notIndexed', evidence: [] } } });
+ const calls = container.querySelector('[data-section="steps"]');
+ expect(calls?.querySelector('summary')?.textContent).toContain('Unavailable');
+ expect(calls?.textContent).toContain('unavailable from the current index');
+ expect(container.querySelector('[data-section="tests"]')?.textContent).toContain('not indexed yet');
+ expect(container.querySelector('[data-section="tests"]')?.textContent).toContain('not test results or measured coverage');
+ });
+
+ it('shows runtime only for real observations and retains optional outline navigation', async () => {
+ await render();
+ expect(container.querySelector('[data-section="runtime"]')).toBeNull();
+ const onOpenFlow = vi.fn();
+ await render({ onOpenFlow, callOutline: <div>Deterministic outline</div>, ir: {
+ ...CREATE_USER_IR,
+ runtime: { state: 'known', evidence: [], value: [{ targetName: 'validateUser', count: 3, unexpected: false }] },
+ } });
+ expect(container.querySelector('[data-section="runtime"]')?.textContent).toContain('validateUser');
+ expect(container.querySelector('[data-section="outline"]')?.textContent).toContain('not complete control flow');
+ await click('.selected-code-flow');
+ expect(onOpenFlow).toHaveBeenCalledOnce();
+ });
+
+ it('retains imports and their source evidence for a file without a resolved symbol', async () => {
+ const imports: ImportsGroup = { heading: 'Imports', entries: [{ id: 'import-0',
+ factPath: 'imports[0]', label: 'validateUser', module: '../util/validate',
+ usage: 'used', marker: 'used', text: 'Used by this file.', note: 'Matched an indexed call.',
+ sourceRef: { uri: CREATE_USER_IR.symbol.uri, line: 4 }, finding: false, origin: 'source',
+ evidence: [{ source: 'source-text', file: CREATE_USER_IR.symbol.uri,
+ range: { startLine: 4, endLine: 4 }, engineGeneration: 2, providerId: 'codeatlas' }] }],
+ hidden: 0, tally: '1 import', used: 1, unused: 0, unknown: 0, sourceRead: true };
+ const value = await render({ symbol: undefined, ir: undefined, status: 'empty', imports });
+ await click('[data-section="imports"] .atlas-twin-row-chip button');
+ expect(value.onFollow).toHaveBeenCalledWith(expect.objectContaining({ uri: CREATE_USER_IR.symbol.uri,
+ range: expect.objectContaining({ start: { line: 3, character: 0 } }) }));
+ await click('[data-factpath="imports[0]"]');
+ expect(container.querySelector('.atlas-evidence-loc')?.textContent).toContain('userService.ts:4');
+ });
+});
diff --git a/graph-ui/src/twin/SelectedCodePanel.tsx b/graph-ui/src/twin/SelectedCodePanel.tsx
new file mode 100644
index 000000000..bdce9f331
--- /dev/null
+++ b/graph-ui/src/twin/SelectedCodePanel.tsx
@@ -0,0 +1,207 @@
+import { useEffect, useState, type ReactNode } from 'react';
+
+import type { SymbolRef } from '../core/focus-protocol';
+import type { Evidence, SemanticIR } from '../core/semantic-ir';
+import type { ImportsGroup } from '../pseudocode/imports-group';
+import { SectionView, type TwinStatus } from './TwinPanel';
+import {
+ buildSections, evidenceFor, importsSection, runtimeSection,
+ type TwinRow, type TwinSection,
+} from './twin-view-model';
+import './selected-code.css';
+
+export interface SelectedCodeRange {
+ /** Editor coordinates, 1-based. Text is the literal selection, unmodified. */
+ startLine: number;
+ startColumn: number;
+ endLine: number;
+ endColumn: number;
+ text: string;
+}
+
+export interface SelectedCodePanelProps {
+ filePath: string;
+ symbol?: SymbolRef;
+ ir?: SemanticIR;
+ status: TwinStatus;
+ message?: string;
+ selection?: SelectedCodeRange;
+ fileSymbols?: readonly SymbolRef[];
+ fileSymbolsStatus?: 'loading' | 'ready' | 'error';
+ fileSymbolsMessage?: string;
+ coverageNote?: string;
+ pinned: boolean;
+ onTogglePin: () => void;
+ onAsk: () => void;
+ onShowGraph: () => void;
+ onFollow: (symbol: SymbolRef) => void;
+ onPointRow?: (row: TwinRow | undefined) => void;
+ onOpenFlow?: () => void;
+ callOutline?: ReactNode;
+ imports?: ImportsGroup;
+}
+
+const SECTION_TITLES: Readonly<Record<string, string>> = {
+ purpose: 'Indexed summary',
+ steps: 'Outgoing calls',
+ callers: 'Called by',
+ state: 'References and environment',
+ errors: 'Error types',
+ effects: 'External effects',
+ tests: 'Related tests',
+ risks: 'Structural observations',
+ runtime: 'Recorded runtime calls',
+ imports: 'File imports',
+};
+
+function unavailableText(section: TwinSection): string | undefined {
+ if (section.state === 'notIndexed') return 'This information is not indexed yet.';
+ if (section.state === 'unsupported') return 'The current index does not provide this information.';
+ if (section.state === 'unknown') return 'This information is unavailable from the current index.';
+ return undefined;
+}
+
+function sectionSummary(section: TwinSection): string {
+ if (section.rows.length > 0) return String(section.rows.length);
+ if (unavailableText(section)) return 'Unavailable';
+ if (section.text) return '';
+ return section.state === 'ambiguous' ? 'Unresolved' : 'None found';
+}
+
+/** Reuse evidence-bearing rows without the legacy reader levels or model controls. */
+function FactDisclosure(props: {
+ section: TwinSection;
+ openEvidence?: string;
+ entriesFor: (path: string) => Evidence[];
+ onToggleEvidence: (path: string) => void;
+ onFollow: (symbol: SymbolRef) => void;
+ onPointRow?: (row: TwinRow | undefined) => void;
+}) {
+ const title = SECTION_TITLES[props.section.name] ?? props.section.title;
+ const unavailable = unavailableText(props.section);
+ const section: TwinSection = {
+ ...props.section,
+ title,
+ // Missing answers must never inherit a checked-empty sentence.
+ emptyText: unavailable ?? props.section.emptyText,
+ ...(props.section.name === 'tests'
+ ? { note: 'Links inferred from indexed callers; these are not test results or measured coverage.' }
+ : {}),
+ };
+ return (
+ <details className="selected-code-fact" data-section={section.name}>
+ <summary>
+ <span>{title}</span>
+ <span className="selected-code-count">{sectionSummary(section)}</span>
+ </summary>
+ <SectionView
+ section={section}
+ voiceOf={() => undefined}
+ openEvidence={props.openEvidence}
+ entriesFor={props.entriesFor}
+ onToggleEvidence={props.onToggleEvidence}
+ onActivate={(row) => { if (row.target) props.onFollow(row.target); }}
+ onPoint={props.onPointRow}
+ />
+ </details>
+ );
+}
+
+export default function SelectedCodePanel(props: SelectedCodePanelProps) {
+ const { filePath, symbol, selection, ir, imports } = props;
+ const [openEvidence, setOpenEvidence] = useState<string>();
+ const identity = `${filePath}:${symbol?.qualifiedName ?? symbol?.name ?? ''}:${ir?.generation ?? ''}`;
+ useEffect(() => setOpenEvidence(undefined), [identity]);
+ const ready = props.status === 'ready' && ir !== undefined && symbol !== undefined;
+ const sections = ready ? buildSections(ir).filter((section) =>
+ section.name !== 'purpose' && (section.name !== 'effects' || section.populated)
+ && (section.name !== 'risks' || section.populated)) : [];
+ const runtime = ready && ir.runtime && ir.runtime.value.length > 0 ? runtimeSection(ir) : undefined;
+ if (runtime) sections.push(runtime);
+ if (imports) sections.push(importsSection(imports));
+ const entriesFor = (path: string): Evidence[] =>
+ imports?.entries.find((entry) => entry.factPath === path)?.evidence
+ ?? (ready ? evidenceFor(ir, path) : []);
+ const hasFile = filePath.length > 0;
+ const range = symbol
+ ? `${symbol.range.start.line + 1}-${Math.max(symbol.range.start.line + 1, symbol.range.end.line + (symbol.range.end.character > 0 ? 1 : 0))}`
+ : undefined;
+ const noSymbolMessage = props.status === 'loading' ? 'Reading selected code...'
+ : props.status === 'failed' ? (props.message || 'Could not read symbol details.')
+ : props.status === 'not-indexed' ? (props.message || 'This file is not indexed yet.')
+ : undefined;
+ return (
+ <section className="selected-code" aria-label="Selected code" data-testid="selected-code-panel" data-pinned={props.pinned}>
+ <header className="selected-code-header">
+ <h2>Selected code</h2>
+ <button type="button" className="selected-code-pin" disabled={!hasFile || (!props.pinned && (props.status === 'loading' || props.fileSymbolsStatus === 'loading'))}
+ aria-pressed={props.pinned} onClick={props.onTogglePin}
+ title={props.pinned ? 'Follow the current editor selection' : 'Keep this context while exploring elsewhere'}>
+ {props.pinned ? 'Pinned' : 'Pin'}
+ </button>
+ </header>
+ {!hasFile ? (
+ <p className="selected-code-message">Open a file to inspect its symbols and connections.</p>
+ ) : (
+ <>
+ <div className="selected-code-identity">
+ {symbol && <div className="selected-code-symbol"><strong>{symbol.name}</strong><span>{symbol.kind}</span></div>}
+ <div className="selected-code-path" title={filePath}>{filePath}{range && <span>:{range}</span>}</div>
+ {props.pinned && <p className="selected-code-note">Context pinned. Unpin to follow the editor.</p>}
+ {ready && ir.signature?.value && <code className="selected-code-signature">{ir.signature.value}</code>}
+ </div>
+ {selection && selection.text.length > 0 && (
+ <div className="selected-code-selection" data-testid="selected-code-selection">
+ <details>
+ <summary>Exact selection <span>{selection.startLine}:{selection.startColumn} to {selection.endLine}:{selection.endColumn}</span></summary>
+ <pre><code>{selection.text}</code></pre>
+ </details>
+ <p className="selected-code-note">Chat receives the marked text.{symbol ? ` Relationships below describe ${symbol.name}.` : ' File connections remain separate from the selection.'}</p>
+ </div>
+ )}
+ <div className="selected-code-actions">
+ <button type="button" className="selected-code-ask" onClick={props.onAsk}>Ask about this</button>
+ <button type="button" onClick={props.onShowGraph}>Show in graph</button>
+ </div>
+ {noSymbolMessage && <p className="selected-code-message" role="status">{noSymbolMessage}</p>}
+ {!symbol && (
+ <div className="selected-code-file" data-testid="selected-code-file">
+ <h3>Symbols in this file</h3>
+ {props.fileSymbolsStatus === 'loading' ? <p className="selected-code-note">Loading symbols...</p>
+ : props.fileSymbolsStatus === 'error' ? <p className="selected-code-note" role="status">{props.fileSymbolsMessage || 'Could not load file symbols.'}</p>
+ : props.fileSymbols && props.fileSymbols.length > 0 ? (
+ <ul>{props.fileSymbols.map((entry) => <li key={`${entry.qualifiedName ?? entry.name}:${entry.range.start.line}`}>
+ <button type="button" onClick={() => props.onFollow(entry)}>
+ <span>{entry.name}</span><span>{entry.kind} · {entry.range.start.line + 1}</span>
+ </button>
+ </li>)}</ul>
+ ) : <p className="selected-code-note">{props.fileSymbolsStatus === 'ready' ? 'No symbols found in the current index.' : 'Select code in the reader to inspect it.'}</p>}
+ {props.fileSymbolsMessage && props.fileSymbolsStatus !== 'error' && <p className="selected-code-note">{props.fileSymbolsMessage}</p>}
+ </div>
+ )}
+ <div className="selected-code-facts" key={identity}>
+ {sections.map((section) => <FactDisclosure key={section.name} section={section}
+ openEvidence={openEvidence} entriesFor={entriesFor}
+ onToggleEvidence={(path) => setOpenEvidence((current) => current === path ? undefined : path)}
+ onFollow={props.onFollow} onPointRow={props.onPointRow} />)}
+ {ready && (props.callOutline || props.onOpenFlow) && (
+ <details className="selected-code-fact" data-section="outline">
+ <summary><span>Call outline</span></summary>
+ <p className="selected-code-note">Indexed call sequence, not complete control flow.</p>
+ {props.onOpenFlow && <button type="button" className="selected-code-flow" onClick={props.onOpenFlow}>Open flow view</button>}
+ {props.callOutline}
+ </details>
+ )}
+ {ready && (ir.writes.state === 'unsupported' || ir.externalEffects.state === 'unsupported') && (
+ <details className="selected-code-fact" data-section="limits">
+ <summary><span>Index limits</span></summary>
+ <p className="selected-code-note">{[ir.writes.state === 'unsupported' ? 'Assignments and writes are not tracked.' : '', ir.externalEffects.state === 'unsupported' ? 'External side effects are not tracked.' : ''].filter(Boolean).join(' ')} Absence of a relationship is not proof that it cannot occur.</p>
+ </details>
+ )}
+ </div>
+ {props.coverageNote && <p className="selected-code-note selected-code-coverage">{props.coverageNote}</p>}
+ </>
+ )}
+ </section>
+ );
+}
diff --git a/graph-ui/src/twin/TwinPanel.tsx b/graph-ui/src/twin/TwinPanel.tsx
index 1c20c4287..88eb8e786 100644
--- a/graph-ui/src/twin/TwinPanel.tsx
+++ b/graph-ui/src/twin/TwinPanel.tsx
@@ -578,7 +578,7 @@ interface SectionProps {
activeStepRow?: number | undefined;
}
-function SectionView(props: SectionProps): JSX.Element {
+export function SectionView(props: SectionProps): JSX.Element {
const { section } = props;
const allChips = section.rows.length > 0 && section.rows.every((row) => row.display === 'chip');
return (
@@ -1066,7 +1066,7 @@ function LimitsView(props: { limits: readonly TwinLimit[]; say: SayFn }): JSX.El
* Schrittliste waere. Der Block zeigt jeden Schritt, den das Dokument traegt,
* bei zwei Schritten wie bei zwanzig.
*/
-function PseudocodeView(props: {
+export function PseudocodeView(props: {
document: PseudocodeDocument;
imports?: ImportsGroup | undefined;
onOpenLine?: ((ref: PseudocodeSourceRef) => void) | undefined;
diff --git a/graph-ui/src/twin/selected-code-context.test.ts b/graph-ui/src/twin/selected-code-context.test.ts
new file mode 100644
index 000000000..93c70ca53
--- /dev/null
+++ b/graph-ui/src/twin/selected-code-context.test.ts
@@ -0,0 +1,77 @@
+import { describe, expect, it, vi } from 'vitest';
+import { EngineError } from '../provider/engine-errors';
+import { loadFileSymbols } from './selected-code-context';
+
+const row = (name: string, line: number, path = 'src/main.ts', qn = `app.${name}`) => ({
+ 'n.name': name, 'n.qualified_name': qn, 'n.file_path': path,
+ 'n.start_line': String(line), 'n.end_line': String(line + 40), 'n.is_test': 'false',
+});
+
+describe('file symbol context', () => {
+ it('queries fixed labels in parallel for the exact escaped file and project', async () => {
+ const pending: ((value: Record<string, string>[]) => void)[] = [];
+ const queryRows = vi.fn((_project: string, _query: string) => new Promise<Record<string, string>[]>((resolve) => pending.push(resolve)));
+ const result = loadFileSymbols({ queryRows }, 'selected-project', 'src/user"s file.ts');
+ expect(queryRows).toHaveBeenCalledTimes(5);
+ expect(queryRows.mock.calls.every((args) => args[0] === 'selected-project')).toBe(true);
+ for (const [, query] of queryRows.mock.calls) {
+ expect(query).toContain('n.file_path = "src/user\\"s file.ts"');
+ expect(query).toContain('LIMIT 200');
+ }
+ pending.forEach((resolve) => resolve([]));
+ await expect(result).resolves.toEqual({ symbols: [], message: '' });
+ });
+
+ it('sorts and deduplicates declaration targets without inventing full spans', async () => {
+ const queryRows = vi.fn(async (_project: string, query: string) => query.includes('n:Function')
+ ? [row('last', 90), row('first', 4)] : query.includes('n:Method') ? [row('first', 4), row('middle', 18)] : []);
+ const result = await loadFileSymbols({ queryRows }, 'preview', 'src/main.ts');
+ expect(result.symbols.map((symbol) => symbol.name)).toEqual(['first', 'middle', 'last']);
+ expect(result.symbols[0]).toMatchObject({ kind: 'function', projectName: 'preview',
+ uri: 'file:///workspace/src/main.ts', range: { start: { line: 3, character: 0 } } });
+ expect(result.symbols[0].range.end.line).toBe(4);
+ expect(result.message).toBe('');
+ });
+
+ it('retains successful rows and distinguishes absent labels from failures', async () => {
+ const queryRows = vi.fn(async (_project: string, query: string) => {
+ if (query.includes('n:Function')) return [row('survives', 6)];
+ if (query.includes('n:Interface')) throw new EngineError('query_graph', "Unknown node label 'Interface'");
+ if (query.includes('n:Method')) throw new EngineError('query_graph', 'permission denied');
+ return [];
+ });
+ const result = await loadFileSymbols({ queryRows }, 'preview', 'src/main.ts');
+ expect(result.symbols.map((symbol) => symbol.name)).toEqual(['survives']);
+ expect(result.message).toContain('Partial results: queries failed for Method.');
+ expect(result.message).toContain('Labels unavailable in this index: Interface.');
+ });
+
+ it('throws when all requests fail instead of claiming that the file has no symbols', async () => {
+ const queryRows = vi.fn(async () => { throw new Error('connection lost'); });
+ await expect(loadFileSymbols({ queryRows }, 'preview', 'src/main.ts')).rejects.toThrow('Could not load file symbols');
+ });
+
+ it('reports both a query ceiling and a combined display ceiling', async () => {
+ const queryRows = vi.fn(async (_project: string, query: string) => query.includes('n:Function')
+ ? Array.from({ length: 200 }, (_, index) => row(`function${index}`, index + 1))
+ : query.includes('n:Class') ? [row('extra', 250)] : []);
+ const result = await loadFileSymbols({ queryRows }, 'preview', 'src/main.ts');
+ expect(result.symbols).toHaveLength(200);
+ expect(result.message).toContain('Function reached the 200-row query limit');
+ expect(result.message).toContain('Showing the first 200 returned symbols');
+ });
+
+ it('omits rows from a different file and unknown declaration positions with an explicit warning', async () => {
+ const queryRows = vi.fn(async (_project: string, query: string) => query.includes('n:Function')
+ ? [row('valid', 2), row('other', 3, 'src/other.ts'), row('missing', 0)] : []);
+ const result = await loadFileSymbols({ queryRows }, 'preview', 'src/main.ts');
+ expect(result.symbols.map((symbol) => symbol.name)).toEqual(['valid']);
+ expect(result.message).toContain('2 results without a valid declaration');
+ });
+
+ it('rejects missing project identity before making requests', async () => {
+ const queryRows = vi.fn();
+ await expect(loadFileSymbols({ queryRows }, '', 'src/main.ts')).rejects.toThrow('Select a project');
+ expect(queryRows).not.toHaveBeenCalled();
+ });
+});
diff --git a/graph-ui/src/twin/selected-code-context.ts b/graph-ui/src/twin/selected-code-context.ts
new file mode 100644
index 000000000..a34ffd5dc
--- /dev/null
+++ b/graph-ui/src/twin/selected-code-context.ts
@@ -0,0 +1,84 @@
+import type { CodeAtlasSymbolKind, SymbolRef } from '../core/focus-protocol';
+import { COLUMNS, declarationsInFiles } from '../provider/cypher';
+import { EngineError } from '../provider/engine-errors';
+import type { RpcIntelligenceClient } from '../provider/rpc-client';
+import { twinTargetOf } from './twin-target';
+
+const FILE_SYMBOL_LIMIT = 200;
+const LABELS = [
+ ['Function', 'function'], ['Method', 'method'], ['Class', 'class'],
+ ['Interface', 'interface'], ['Type', 'type'],
+] as const satisfies readonly (readonly [string, CodeAtlasSymbolKind])[];
+
+function missingLabel(error: unknown, label: string): boolean {
+ if (!(error instanceof EngineError)) return false;
+ // Only an explicit absent-label answer is benign. Permissions, a missing
+ // project and transport failures must remain partial/error results.
+ return new RegExp(`(?:unknown|unrecognized|missing|no such) (?:node )?label[ :'"]+${label}\\b|(?:node )?label[ :'"]+${label}['"]? (?:not found|does not exist)`, 'i')
+ .test(error.message);
+}
+
+export interface FileSymbolResult {
+ /** Declaration navigation targets; ranges are not complete symbol spans. */
+ symbols: SymbolRef[];
+ /** Empty on a complete answer, otherwise the precise retrieval limitation. */
+ message: string;
+}
+
+export async function loadFileSymbols(
+ client: Pick<RpcIntelligenceClient, 'queryRows'>,
+ project: string,
+ path: string,
+): Promise<FileSymbolResult> {
+ if (project.trim().length === 0 || path.trim().length === 0) {
+ throw new Error('Select a project and file before loading symbols.');
+ }
+ const results = await Promise.allSettled(LABELS.map(async ([label]) => {
+ const query = declarationsInFiles(label, [path], FILE_SYMBOL_LIMIT);
+ if (!query) throw new Error('The file path could not be queried.');
+ return client.queryRows(project, query);
+ }));
+ const symbols = new Map<string, SymbolRef>();
+ const failed: string[] = [];
+ const absent: string[] = [];
+ const capped: string[] = [];
+ let answered = 0;
+ let invalid = 0;
+ for (const [index, result] of results.entries()) {
+ const [label, kind] = LABELS[index];
+ if (result.status === 'rejected') {
+ (missingLabel(result.reason, label) ? absent : failed).push(label);
+ continue;
+ }
+ answered++;
+ if (result.value.length >= FILE_SYMBOL_LIMIT) capped.push(label);
+ for (const row of result.value) {
+ const name = row[COLUMNS.declarations[0]];
+ const qualifiedName = row[COLUMNS.declarations[1]] || undefined;
+ const filePath = row[COLUMNS.declarations[2]];
+ const startLine = Number(row[COLUMNS.declarations[3]]);
+ if (!name || filePath !== path || !Number.isSafeInteger(startLine) || startLine < 1) {
+ invalid++;
+ continue;
+ }
+ const target = twinTargetOf({ name, qualifiedName, filePath, startLine, kind });
+ if (!target) { invalid++; continue; }
+ const key = `${filePath}:${qualifiedName ?? `${name}:${startLine}`}`;
+ if (!symbols.has(key)) symbols.set(key, { ...target, projectName: project });
+ }
+ }
+ if (answered === 0) {
+ throw new Error(failed.length > 0
+ ? `Could not load file symbols. Queries failed for ${failed.join(', ')}.${absent.length ? ` Labels unavailable: ${absent.join(', ')}.` : ''}`
+ : `The current index does not provide these symbol labels: ${absent.join(', ')}.`);
+ }
+ const ordered = [...symbols.values()].sort((a, b) => a.range.start.line - b.range.start.line
+ || (a.qualifiedName ?? a.name).localeCompare(b.qualifiedName ?? b.name));
+ const notes: string[] = [];
+ if (failed.length > 0) notes.push(`Partial results: queries failed for ${failed.join(', ')}.`);
+ if (absent.length > 0) notes.push(`Labels unavailable in this index: ${absent.join(', ')}.`);
+ if (capped.length > 0) notes.push(`Some symbols may be omitted: ${capped.join(', ')} reached the ${FILE_SYMBOL_LIMIT}-row query limit.`);
+ if (ordered.length > FILE_SYMBOL_LIMIT) notes.push(`Showing the first ${FILE_SYMBOL_LIMIT} returned symbols by declaration line.`);
+ if (invalid > 0) notes.push(`${invalid} result${invalid === 1 ? '' : 's'} without a valid declaration in this file omitted.`);
+ return { symbols: ordered.slice(0, FILE_SYMBOL_LIMIT), message: notes.join(' ') };
+}
diff --git a/graph-ui/src/twin/selected-code-snapshot.test.ts b/graph-ui/src/twin/selected-code-snapshot.test.ts
new file mode 100644
index 000000000..213c47f06
--- /dev/null
+++ b/graph-ui/src/twin/selected-code-snapshot.test.ts
@@ -0,0 +1,162 @@
+import { describe, expect, it } from 'vitest';
+import { userMessage } from '../browser-ai/chat-model';
+import type { BrowserChatContext } from '../browser-ai/chat-model';
+import type { SymbolRef } from '../core/focus-protocol';
+import type { ReaderDocument } from '../reader/file-source';
+import { CREATE_USER_IR } from '../test-support/twin-fixtures';
+import { inspectorChatContext, matchingInspectorIr } from './selected-code-snapshot';
+import type { SelectedCodeSnapshot } from './selected-code-snapshot';
+
+const project = CREATE_USER_IR.symbol.projectName!;
+const path = 'src/services/userService.ts';
+const sourceLines = [
+ '// context before the function',
+ 'export function createUser(input: User) {',
+ ' return saveUser(input);',
+ '}',
+ '// unrelated next declaration',
+];
+
+function snapshot(overrides: Partial<SelectedCodeSnapshot> = {}): SelectedCodeSnapshot {
+ // Browser symbol URIs use /workspace; project identity travels separately.
+ const symbol: SymbolRef = { ...CREATE_USER_IR.symbol, uri: `file:///workspace/${path}`, range: {
+ start: { line: 100, character: 0 }, end: { line: 103, character: 0 },
+ } };
+ const document: ReaderDocument = {
+ path, qualifiedName: 'sample.userService', derivedQualifiedName: 'sample.userService',
+ qnSource: 'derived', source: sourceLines.join('\n'), firstLine: 100, lastLine: 104,
+ truncated: true, truncationNote: 'Only this file window is loaded.',
+ };
+ return { project, filePath: path, symbol, ir: { ...CREATE_USER_IR, symbol },
+ status: 'ready', document, ...overrides };
+}
+
+type Payload = {
+ project: string;
+ path: string;
+ symbol?: SymbolRef;
+ scope: string;
+ source?: { firstLine: number; lastLine: number; text: string; note: string };
+ evidence: unknown[];
+ symbols?: unknown[];
+ fileSymbolsNote?: string;
+ coverage?: unknown;
+ limitations: string;
+};
+
+const payload = (context: BrowserChatContext): Payload => JSON.parse(context.text) as Payload;
+
+describe('matching inspector evidence', () => {
+ it('accepts the current project, path, and symbol', () => {
+ const current = snapshot();
+ expect(matchingInspectorIr(current.ir, current.symbol, project, path)).toBe(current.ir);
+ });
+
+ it('rejects a response or selection from a previous project', () => {
+ const current = snapshot();
+ const staleIr = { ...current.ir!, symbol: { ...current.symbol!, projectName: 'previous-project' } };
+ expect(matchingInspectorIr(staleIr, current.symbol, project, path)).toBeUndefined();
+ expect(matchingInspectorIr(current.ir, { ...current.symbol!, projectName: 'previous-project' }, project, path)).toBeUndefined();
+ expect(matchingInspectorIr(current.ir, current.symbol, 'next-project', path)).toBeUndefined();
+ });
+
+ it('rejects stale evidence for a different file or different function in the same file', () => {
+ const current = snapshot();
+ expect(matchingInspectorIr(current.ir, current.symbol, project, 'src/other.ts')).toBeUndefined();
+ const otherFile = { ...current.symbol!, uri: 'file:///workspace/src/other.ts' };
+ expect(matchingInspectorIr({ ...current.ir!, symbol: otherFile }, current.symbol, project, path)).toBeUndefined();
+ const otherFunction = { ...current.symbol!, name: 'deleteUser', qualifiedName: 'sample.userService.deleteUser',
+ nodeId: 'function:deleteUser' };
+ expect(matchingInspectorIr(current.ir, otherFunction, project, path)).toBeUndefined();
+ });
+
+ it('does not reuse evidence while the next symbol is unresolved', () => {
+ const current = snapshot();
+ expect(matchingInspectorIr(current.ir, undefined, project, path)).toBeUndefined();
+ expect(matchingInspectorIr(undefined, current.symbol, project, path)).toBeUndefined();
+ });
+});
+
+describe('selected code chat context', () => {
+ it('attaches exactly the marked text separately from broader symbol evidence', () => {
+ const selection = { path, sourceVersion: 'reader-version-1',
+ startLine: 102, startColumn: 3, endLine: 102, endColumn: 27,
+ text: ' saveUser(`<user>`, "a");\n\t' };
+ const current = snapshot({ selection });
+ const context = inspectorChatContext(current, 'selected');
+ const body = payload(context);
+ expect(body.source).toBeUndefined();
+ expect(body.scope).toContain('not just the selected text');
+ expect(body.evidence.length).toBeGreaterThan(0);
+ expect(context.text).not.toContain(sourceLines[1]);
+ const message = userMessage('Explain this exact code', { ...selection, id: 'literal',
+ path, project, sourceVersion: 'reader-version-1' }, [context]);
+ const exactText = message.split('--- BEGIN EXACT CODE SNAPSHOT ---\n')[1]
+ .split('\n--- END EXACT CODE SNAPSHOT ---')[0];
+ expect(exactText).toBe(selection.text);
+ expect(message).not.toContain(sourceLines[1]);
+ expect(message).not.toContain(sourceLines[4]);
+ });
+
+ it('extracts complete symbol lines from a file window with an exclusive end range', () => {
+ const body = payload(inspectorChatContext(snapshot(), 'symbol'));
+ expect(body.source).toEqual({ firstLine: 101, lastLine: 103,
+ text: 'export function createUser(input: User) {\n return saveUser(input);\n}',
+ note: expect.stringContaining('not an editor text selection') });
+ });
+
+ it('includes the end line when the symbol ends within that line', () => {
+ const current = snapshot();
+ const symbol = { ...current.symbol!, range: {
+ start: { line: 100, character: 0 }, end: { line: 102, character: 1 },
+ } };
+ const body = payload(inspectorChatContext({ ...current, symbol }, 'symbol'));
+ expect(body.source?.lastLine).toBe(103);
+ expect(body.source?.text).toBe(sourceLines.slice(1, 4).join('\n'));
+ });
+
+ it.each(['missing start', 'missing end', 'different file', 'unloaded'] as const)
+ ('omits source when the document is %s', (caseName) => {
+ const current = snapshot();
+ const document = caseName === 'unloaded' ? undefined : {
+ ...current.document!,
+ ...(caseName === 'missing start' ? { firstLine: 102, source: sourceLines.slice(2).join('\n') } : {}),
+ ...(caseName === 'missing end' ? { lastLine: 102, source: sourceLines.slice(0, 3).join('\n') } : {}),
+ ...(caseName === 'different file' ? { path: 'src/other.ts' } : {}),
+ };
+ const body = payload(inspectorChatContext({ ...current, document }, 'incomplete'));
+ expect(body.source).toBeUndefined();
+ expect(body.evidence.length).toBeGreaterThan(0);
+ expect(body.limitations).toContain('Missing information does not establish absence');
+ });
+
+ it('offers file symbols and index limitations without attaching the entire file', () => {
+ const current = snapshot({ symbol: undefined, ir: undefined, fileSymbols: [CREATE_USER_IR.symbol],
+ fileSymbolsStatus: 'ready', fileSymbolsMessage: 'Showing the first 100 indexed symbols.',
+ coverageNote: 'Partial coverage: generated functions are outside this index.' });
+ const context = inspectorChatContext(current, 'file');
+ const body = payload(context);
+ expect(context.label).toBe(`File context · ${path}`);
+ expect(body.source).toBeUndefined();
+ expect(body.evidence).toEqual([]);
+ expect(body.symbols).toEqual([{ name: 'createUser', qualifiedName: CREATE_USER_IR.symbol.qualifiedName,
+ kind: 'function', line: 23 }]);
+ expect(body.fileSymbolsNote).toBe('Showing the first 100 indexed symbols.');
+ expect(body.coverage).toBe('Partial coverage: generated functions are outside this index.');
+ });
+
+ it('keeps captured pinned context stable while subsequent reader context changes', () => {
+ const retainedSnapshot = snapshot();
+ const pinnedContext = inspectorChatContext(retainedSnapshot, 'pinned');
+ const originalText = pinnedContext.text;
+ retainedSnapshot.document!.source = sourceLines.map(line => line.replaceAll('User', 'Order')).join('\n');
+ retainedSnapshot.symbol = { ...retainedSnapshot.symbol!, name: 'createOrder', qualifiedName: 'sample.createOrder' };
+ retainedSnapshot.ir = { ...retainedSnapshot.ir!, symbol: retainedSnapshot.symbol };
+ const newContext = inspectorChatContext(retainedSnapshot, 'current');
+ expect(payload(newContext).source?.text).toContain('createOrder');
+ const prompt = userMessage('Explain the pinned function', undefined, [pinnedContext]);
+ expect(prompt).toContain('createUser');
+ expect(prompt).not.toContain('createOrder');
+ expect(pinnedContext.text).toBe(originalText);
+ });
+});
diff --git a/graph-ui/src/twin/selected-code-snapshot.ts b/graph-ui/src/twin/selected-code-snapshot.ts
new file mode 100644
index 000000000..e18ef5989
--- /dev/null
+++ b/graph-ui/src/twin/selected-code-snapshot.ts
@@ -0,0 +1,63 @@
+import type { SymbolRef } from '../core/focus-protocol';
+import type { SemanticIR } from '../core/semantic-ir';
+import type { ReaderSelection } from '../reader/MonacoReader';
+import type { ReaderDocument } from '../reader/file-source';
+import type { BrowserChatContext } from '../browser-ai/chat-model';
+import { browserGraphContext } from '../browser-ai/graph-context';
+import type { PseudocodeDocument } from '../pseudocode/pseudocode-builder';
+import type { SelectedCodePanelProps } from './SelectedCodePanel';
+import { workspacePathOf } from './twin-target';
+
+export type SelectedCodeSnapshot = Pick<SelectedCodePanelProps,
+ 'filePath' | 'symbol' | 'ir' | 'status' | 'message' | 'imports' | 'coverageNote'
+ | 'fileSymbols' | 'fileSymbolsStatus' | 'fileSymbolsMessage'> & {
+ project: string;
+ selection?: ReaderSelection;
+ document?: ReaderDocument;
+ pseudocode?: PseudocodeDocument;
+ };
+
+/** Keep late responses from lending evidence to a different symbol. */
+export function matchingInspectorIr(ir: SemanticIR | undefined, symbol: SymbolRef | undefined,
+ project: string, path: string): SemanticIR | undefined {
+ if (!ir || !symbol || !path || workspacePathOf(symbol.uri) !== path
+ || workspacePathOf(ir.symbol.uri) !== path
+ || (symbol.projectName && symbol.projectName !== project)
+ || (ir.symbol.projectName && ir.symbol.projectName !== project)) return undefined;
+ const identity = (ref: SymbolRef) => ref.qualifiedName || ref.nodeId
+ || `${ref.uri}:${ref.name}:${ref.range.start.line}:${ref.range.start.character}`;
+ return identity(ir.symbol) === identity(symbol) ? ir : undefined;
+}
+
+/** Explicit context for the next prompt; exact text selections travel separately. */
+export function inspectorChatContext(snapshot: SelectedCodeSnapshot, id: string): BrowserChatContext {
+ const { project, filePath, symbol, ir, selection, document } = snapshot;
+ const firstLine = symbol ? symbol.range.start.line + 1 : undefined;
+ const lastLine = symbol ? symbol.range.end.line + (symbol.range.end.character > 0 ? 1 : 0) : undefined;
+ const sourceAvailable = !selection && document?.path === filePath && firstLine !== undefined
+ && lastLine !== undefined && lastLine >= firstLine
+ && firstLine >= document.firstLine && lastLine <= document.lastLine;
+ return {
+ id,
+ label: `${selection ? 'Selection context' : symbol ? 'Symbol context' : 'File context'} · ${symbol?.name ?? filePath}`,
+ text: JSON.stringify({
+ kind: 'selected-code-context', project, path: filePath, symbol,
+ generation: ir?.generation,
+ scope: selection ? 'Graph relationships describe the named symbol, not just the selected text.'
+ : symbol ? 'Selected symbol and its indexed relationships.' : 'File symbols and import context; file source is not attached.',
+ source: sourceAvailable ? {
+ firstLine, lastLine,
+ text: document.source.split('\n').slice(firstLine - document.firstLine, lastLine - document.firstLine + 1).join('\n'),
+ note: 'Complete source lines covering the indexed symbol; this is not an editor text selection.',
+ } : undefined,
+ evidence: browserGraphContext(ir, project, filePath, symbol ? workspacePathOf(symbol.uri) : '')
+ .map(item => JSON.parse(item.text) as unknown),
+ symbols: !symbol ? snapshot.fileSymbols?.map(ref => ({ name: ref.name, qualifiedName: ref.qualifiedName,
+ kind: ref.kind, line: ref.range.start.line + 1 })) : undefined,
+ fileSymbolsNote: !symbol ? snapshot.fileSymbolsMessage : undefined,
+ imports: snapshot.imports,
+ coverage: snapshot.coverageNote,
+ limitations: 'Static indexed evidence is best-effort. Missing information does not establish absence. Select source text to attach its literal contents.',
+ }, null, 2),
+ };
+}
diff --git a/graph-ui/src/twin/selected-code.css b/graph-ui/src/twin/selected-code.css
new file mode 100644
index 000000000..8e0377dfb
--- /dev/null
+++ b/graph-ui/src/twin/selected-code.css
@@ -0,0 +1,82 @@
+.selected-code {
+ min-width: 0;
+ color: var(--text, #d7e5de);
+ background: rgba(11, 22, 18, .94);
+ font-size: 12px;
+ line-height: 1.5;
+ overflow-wrap: anywhere;
+}
+
+.selected-code-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+ padding: 11px 14px 7px;
+}
+
+.selected-code h2,
+.selected-code h3 { margin: 0; font-size: 12px; font-weight: 600; }
+.selected-code h2 { color: #d7e5de; letter-spacing: .03em; }
+.selected-code button { font: inherit; cursor: pointer; }
+.selected-code button:disabled { opacity: .45; cursor: default; }
+.selected-code button:focus-visible,
+.selected-code summary:focus-visible { outline: 2px solid #61dcc4; outline-offset: 3px; }
+
+.selected-code-pin {
+ padding: 3px 9px;
+ border: 1px solid #294d3d;
+ border-radius: 6px;
+ color: #97b7a8;
+ background: transparent;
+}
+.selected-code-pin[aria-pressed="true"] { color: #39ffad; border-color: #21815b; background: #112d22; }
+.selected-code-identity { padding: 0 14px 9px; }
+.selected-code-symbol { display: flex; align-items: baseline; gap: 10px; }
+.selected-code-symbol strong { font-size: 15px; color: #e3efe8; }
+.selected-code-symbol > span,
+.selected-code-path { color: #8da99b; font-size: 11px; }
+.selected-code-path { font-family: var(--mono, ui-monospace, monospace); }
+.selected-code-signature { display: block; margin-top: 6px; color: #c0dacd; white-space: pre-wrap; }
+.selected-code-actions { display: flex; gap: 7px; flex-wrap: wrap; padding: 0 14px 12px; }
+.selected-code-actions button,
+.selected-code-flow {
+ border: 1px solid #2a5140;
+ border-radius: 6px;
+ padding: 6px 10px;
+ color: #b9d1c5;
+ background: #11221b;
+}
+.selected-code-actions .selected-code-ask { color: #3affa9; border-color: #27764e; background: #102b1f; }
+.selected-code-actions button:hover,
+.selected-code-flow:hover { background: #17372a; }
+.selected-code-message { margin: 0; padding: 8px 14px 14px; color: #aac2b5; }
+.selected-code-note { margin: 6px 0; color: #89a798; font-size: 11px; }
+.selected-code-selection { margin: 0 14px 10px; padding: 7px 9px; border: 1px solid #275342; border-radius: 7px; background: #10251c; }
+.selected-code-selection summary { cursor: pointer; color: #afddc8; }
+.selected-code-selection summary span { color: #829e90; font-size: 10px; }
+.selected-code-selection pre { margin: 8px 0; max-height: 150px; overflow: auto; white-space: pre; color: #ddede2; font-size: 11px; }
+.selected-code-file { padding: 2px 14px 12px; }
+.selected-code-file h3 { margin-bottom: 5px; color: #94b1a1; }
+.selected-code-file ul { margin: 0; padding: 0; list-style: none; max-height: 168px; overflow: auto; }
+.selected-code-file li button { display: flex; justify-content: space-between; gap: 12px; width: 100%; text-align: left; border: 0; border-radius: 4px; padding: 5px 6px; color: #c5d8cb; background: transparent; }
+.selected-code-file li button:hover { background: #142b20; }
+.selected-code-file li button span:last-child { color: #789887; font-size: 10px; flex-shrink: 0; }
+.selected-code-fact { border-top: 1px solid #233c30; }
+.selected-code-fact > summary { padding: 9px 14px; cursor: pointer; color: #afc9ba; }
+.selected-code-fact > summary:hover { background: #10271b; }
+.selected-code-fact[open] > summary { color: #d3e8d9; }
+.selected-code-count { float: right; color: #709a81; font-size: 10px; margin-left: 8px; }
+.selected-code-fact > .selected-code-note { padding: 0 14px 8px; }
+.selected-code-fact > .selected-code-flow { margin: 0 14px 10px; }
+.selected-code-fact .atlas-twin-section { padding: 0 14px 12px; margin: 0; border: 0; }
+.selected-code-fact .atlas-twin-block-label,
+.selected-code-fact .atlas-twin-section-title { display: none; }
+.selected-code-fact .atlas-twin-section-head { min-height: 0; margin-bottom: 5px; }
+.selected-code-fact .atlas-twin-section-empty,
+.selected-code-fact .atlas-twin-section-note,
+.selected-code-fact .atlas-twin-section-text { font-size: 11px; }
+.selected-code-fact .atlas-twin-row,
+.selected-code-fact .atlas-twin-row-chip { font-size: 11px; }
+.selected-code-fact .atlas-pseudocode { padding: 0 14px 14px; }
+.selected-code-coverage { padding: 7px 14px 10px; border-top: 1px solid #233c30; margin: 0; }
diff --git a/graph-ui/verification/w6/stylegate.json b/graph-ui/verification/w6/stylegate.json
index 8dc283f5d..b3064c1a2 100644
--- a/graph-ui/verification/w6/stylegate.json
+++ b/graph-ui/verification/w6/stylegate.json
@@ -139,8 +139,8 @@
"reason": "Docblocks und Zeilenkommentare sind kein Bildschirmtext. Der Parser sieht den Unterschied, ein regulaerer Ausdruck koennte ihn nicht sehen."
}
],
- "filesConsidered": 720,
- "textFiles": 565,
+ "filesConsidered": 727,
+ "textFiles": 572,
"binaryFiles": 155,
- "generatedAt": "2026-09-09T05:07:43.722Z"
+ "generatedAt": "2026-09-09T17:46:30.681Z"
}
diff --git a/graph-ui/verification/w7/promises.json b/graph-ui/verification/w7/promises.json
index fb9c078fe..694a47374 100644
--- a/graph-ui/verification/w7/promises.json
+++ b/graph-ui/verification/w7/promises.json
@@ -3,7 +3,7 @@
"promiseMatches": [],
"deadAffordances": 0,
"deadAffordanceMatches": [],
- "filesScanned": 183,
+ "filesScanned": 186,
"whitelist": [
{
"rule": "disabled",
@@ -102,5 +102,5 @@
"onToggle"
],
"scanned": "src/**/*.{ts,tsx} ohne *.test.*",
- "generatedAt": "2026-09-09T05:07:44.055Z"
+ "generatedAt": "2026-09-09T17:46:31.026Z"
}