MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / chatTopic

Function chatTopic

graph-ui/src/browser-ai/chat-context.ts:10–23  ·  view source on GitHub ↗
(scope: string, sources: { reader?: BrowserChatReaderContext; graph?: BrowserChatContext; attachment?: BrowserChatAttachment;
    context?: readonly BrowserChatContext[] })

Source from the content-addressed store, hash-verified

8export interface ChatTopic { key: string; label: string; kind: 'file' | 'graph' | 'attachment' | 'context' }
9
10export function chatTopic(scope: string, sources: { reader?: BrowserChatReaderContext; graph?: BrowserChatContext; attachment?: BrowserChatAttachment;
11 context?: readonly BrowserChatContext[] }): ChatTopic | undefined {
12 const { reader, graph, attachment, context = [] } = sources;
13 if (reader?.source) return { kind: 'file', label: reader.source.path, key: JSON.stringify([scope, 'file', reader.source.path]) };
14 if (graph) {
15 // The selected item itself; depth, direction and edge types only redraw its scope.
16 const galaxy = readGalaxyEvidence(graph.text);
17 // Named as the Galaxy names it, a Branch node "django-demo · detached HEAD" (round 4, N1); the key stays the identity.
18 return { kind: 'graph', label: galaxy ? selectionName(galaxy, relationshipWords.en) : graph.label, key: JSON.stringify([scope, 'graph', galaxy ? galaxy.identity : graph.label]) };
19 }
20 if (attachment) return { kind: 'attachment', label: attachment.path, key: JSON.stringify([scope, 'attachment', attachment.path]) };
21 if (context.length) return { kind: 'context', label: context.map(item => item.label).join(', '), key: JSON.stringify([scope, 'context', ...context.map(item => item.id)]) };
22 return undefined;
23}
24
25/** The earlier turns a question about `topic` carries: its own, also from before the reader
26 * went to another file or selection and came back, and never those of another topic (K17).

Callers 4

sendFunction · 0.90

Calls 2

readGalaxyEvidenceFunction · 0.90
selectionNameFunction · 0.90

Tested by

no test coverage detected