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

Function Turn

graph-ui/src/chat/AtlasChatPanel.tsx:246–511  ·  view source on GitHub ↗

One turn: the question, the answer with its citations, and the evidence.

(props: {
    turn: ChatTurn;
    /** The depth the control is set to NOW. The turn carries the one it was asked with. */
    depth: NeighborDepth;
    /** True for the turn the offer may appear on: the last one that carries an answer. */
    offerRerun: boolean;
    onOpenCard: (source: CardSource) => void;
    onPickCandidate: (turn: ChatTurn, candidate: SubjectCandidate) => void;
    onAskAgain: (turn: ChatTurn) => void;
    aiAvailable?: boolean;
    modelName?: string;
    requestModel?: string;
})

Source from the content-addressed store, hash-verified

244
245/** One turn: the question, the answer with its citations, and the evidence. */
246function Turn(props: {
247 turn: ChatTurn;
248 /** The depth the control is set to NOW. The turn carries the one it was asked with. */
249 depth: NeighborDepth;
250 /** True for the turn the offer may appear on: the last one that carries an answer. */
251 offerRerun: boolean;
252 onOpenCard: (source: CardSource) => void;
253 onPickCandidate: (turn: ChatTurn, candidate: SubjectCandidate) => void;
254 onAskAgain: (turn: ChatTurn) => void;
255 aiAvailable?: boolean;
256 modelName?: string;
257 requestModel?: string;
258}): JSX.Element {
259 const { turn } = props;
260 const [open, setOpen] = useState(false);
261 const cardIds = turn.cards.map((card) => card.id);
262 const byId = new Map(turn.cards.map((card) => [card.id, card] as const));
263 const lines = turn.answer.length === 0 ? [] : claimLines(turn.answer);
264 const shown = lines.length === 0 && turn.answer.trim().length > 0
265 ? [turn.answer.trim()]
266 : lines;
267 const message = messageOf(turn);
268 const uncited = turn.check?.violations.filter((entry) => entry.reason === 'no-citation') ?? [];
269 const unknown = turn.check?.unknown ?? [];
270
271 /*
272 * Das Angebot aus AC6b.
273 *
274 * Es steht nur an der LETZTEN Antwort, und nur, wenn die Einstellung seit
275 * ihr eine andere ist. An jeder Antwort waere es eine Zeile Rauschen unter
276 * jedem alten Zug; an keiner waere es der Satz im Kopf, den der Leser
277 * ueberlesen hat.
278 */
279 const rerun = props.offerRerun && turn.depth !== props.depth;
280 const builtLines = readerLines(shown.map((text, index) => ({ id: `chat-${index}`, text })));
281 const [aiLines, setAiLines] = useState<readonly string[] | undefined>(undefined);
282 const [aiState, setAiState] = useState<'idle' | 'running' | 'applied' | 'refused'>('idle');
283 const [aiReason, setAiReason] = useState('');
284 useEffect(() => {
285 globalThis.__atlasChatReader = {
286 subject: builtLines.map((line) => ({ id: line.id, text: line.text, facts: [...line.facts] })),
287 validateRewrite: (answer: string) => {
288 const outcome = applyReaderRewrite(builtLines, answer);
289 return outcome.kind === 'applied'
290 ? { applied: true, reason: '' }
291 : { applied: false, reason: outcome.reason };
292 },
293 };
294 return () => {
295 globalThis.__atlasChatReader = undefined;
296 };
297 }, [builtLines]);
298 const askAi = (): void => {
299 if (!props.aiAvailable || builtLines.length === 0) return;
300 setAiState('running');
301 void askModel({
302 origin: SIDECAR_ORIGIN,
303 system: READER_SYSTEM_PROMPT,

Callers

nothing calls this directly

Calls 15

claimLinesFunction · 0.90
readerLinesFunction · 0.90
applyReaderRewriteFunction · 0.90
chatFocusFallbackLineFunction · 0.90
segmentsOfFunction · 0.90
chatAiProvenanceFunction · 0.90
chatCitationWarningFunction · 0.90
chatUnknownCardWarningFunction · 0.90
chatCardsFoldLabelFunction · 0.90
chatCardsLabelFunction · 0.90
chatProvenanceFunction · 0.90
chatRerunTooltipFunction · 0.90

Tested by

no test coverage detected