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.

fix(ui): drop the prompt capacity note from a card with listed facts

Bernhard Jackiewicz8c3491f7cc01
diff --git a/graph-ui/src/browser-ai/BrowserChatDock.test.tsx b/graph-ui/src/browser-ai/BrowserChatDock.test.tsx
index f5cb9204b..03148fae3 100644
--- a/graph-ui/src/browser-ai/BrowserChatDock.test.tsx
+++ b/graph-ui/src/browser-ai/BrowserChatDock.test.tsx
@@ -1332,6 +1332,16 @@ describe('grounded automatic explanations (K14, K7)', () => {
expect(card().textContent).toContain("The model's sentence named something the evidence does not show and was left out.");
});
+ it('does not show a prompt capacity note on a card whose facts are listed in full', async () => {
+ vi.useFakeTimers(); const { props } = fixture();
+ const callers = Array.from({ length: 40 }, (_, index) => ({ id: 2000 + index, name: `caller_with_a_long_descriptive_name_number_${index}`, label: 'Function',
+ file_path: `tests/postgres_tests/callers/test_module_number_${index}.py`, x: 0, y: 0, z: 0, size: 1, color: '#999' }));
+ const evidence = jsonbAggEvidence({ edges: callers.map(caller => ({ source: caller.id, target: 32360, type: 'CALLS' })), nodes: callers });
+ await render({ ...props, proactive: true, proactiveSelection: evidence, readSource: vi.fn(async () => snippet) }); await click('Download & load'); await settle();
+ expect(card().textContent).toContain('Incoming relationships: 40 from 40 symbols (CALLS 40).');
+ expect(card().textContent).not.toContain('too large for the local');
+ });
+
it('does not ask the model at all without source: the listed facts are the explanation', async () => {
vi.useFakeTimers(); const { props, runtime } = fixture();
const readSource = vi.fn(async () => { throw new Error('source unavailable'); });
diff --git a/graph-ui/src/browser-ai/BrowserChatDock.tsx b/graph-ui/src/browser-ai/BrowserChatDock.tsx
index 8fc7f61d3..b88af05ec 100644
--- a/graph-ui/src/browser-ai/BrowserChatDock.tsx
+++ b/graph-ui/src/browser-ai/BrowserChatDock.tsx
@@ -49,7 +49,8 @@ export interface BrowserChatDockProps {
type Phase = 'off' | 'preparing' | 'ready' | 'counting' | 'generating' | 'removing';
type ChatTurn = BrowserChatTurn & { evidence?: PreparedExplanationContext };
-type Explanation = { key: string; label: string; answer: string; status: string; error?: string; packet?: PreparedExplanationContext; citation?: ReturnType<typeof citedInterpretation>; mode?: 'interpretation'; shortened?: boolean; limit?: TokenLimits; evidence?: string };
+/** `grounded`: the facts are listed in the card, so the prompt's name budget is not the reader's limit. */
+type Explanation = { key: string; label: string; answer: string; status: string; error?: string; packet?: PreparedExplanationContext; citation?: ReturnType<typeof citedInterpretation>; mode?: 'interpretation'; shortened?: boolean; limit?: TokenLimits; evidence?: string; grounded?: boolean };
/** Finished explanations per selection, so returning to one does not run the model again. */
const EXPLANATION_CACHE_SIZE = 32;
const initialModel = BROWSER_MODELS.find(model => model.availability === 'available')!;
@@ -348,7 +349,7 @@ export default function BrowserChatDock({ proactiveSelection, selectionScope = "
// Without source the model could only restate the facts or guess from names (an area
// became "a high-level web framework"): the listed facts are the explanation (K7).
if (summary.length && explanationMode(packet) === 'graph') {
- const complete: Explanation = { key: snapshot.key, label: snapshot.label, answer: groundedExplanation(summary, undefined, false), status: 'complete', packet,
+ const complete: Explanation = { key: snapshot.key, label: snapshot.label, answer: groundedExplanation(summary, undefined, false), status: 'complete', packet, grounded: true,
...snapshot.evidence ? { evidence: snapshot.evidence } : {} };
remember(complete); setExplanation(complete);
if (!followExplanation.current) setNewExplanation(true);
@@ -381,7 +382,7 @@ export default function BrowserChatDock({ proactiveSelection, selectionScope = "
const checked = result.status === 'generated' ? explanationSentence(result.markdown, packet, request.map(message => message.content).join('\n')) : {};
if (summary.length || (result.status === 'generated' && checked.dropped)) {
const markdown = summary.length ? groundedExplanation(summary, checked.sentence, checked.dropped !== undefined) : `_${browserChatText.explanationDropped}_`;
- const complete: Explanation = { key: snapshot.key, label: snapshot.label, answer: markdown, status: 'complete', mode: 'interpretation', packet,
+ const complete: Explanation = { key: snapshot.key, label: snapshot.label, answer: markdown, status: 'complete', mode: 'interpretation', packet, grounded: summary.length > 0,
...shortened && checked.sentence ? { shortened, limit: { inputTokens: autoInput, outputTokens: autoOutput } } : {}, ...snapshot.evidence ? { evidence: snapshot.evidence } : {} };
remember(complete); setExplanation(complete);
} else if (result.status === 'generated') {
@@ -699,7 +700,7 @@ export default function BrowserChatDock({ proactiveSelection, selectionScope = "
</SourceDisclosure>
{explanation?.key === selected.key ? <>
<ChatMarkdown text={explanation.answer || (explanation.status === 'generating' ? 'Explaining selection…' : explanation.status === 'stopped' ? 'Explanation stopped.' : '')} />
- {explanation.status !== 'generating' && <AnswerNotes shortened={limitNote(explanation.shortened, explanation.limit, true)} packet={explanation.packet} model={model.displayName} />}
+ {explanation.status !== 'generating' && <AnswerNotes shortened={limitNote(explanation.shortened, explanation.limit, true)} packet={explanation.grounded ? undefined : explanation.packet} model={model.displayName} />}
{explanation.error && <p className="cbm-chat-turn-error" role="alert">{explanation.error}</p>}
{explanation.status !== 'generating' && <button type="button" className="cbm-chat-retry" disabled={phase !== 'ready' || !!selected.waiting} onClick={() => {
lastAttempt.current = undefined; explanations.current.delete(selected.key); setRetryExplanation(value => value + 1);