Detail card: per-session understanding notes next to the session list
The extractor's per-proposition understanding observations (named-word scale: solid/shaky/accepted/...) were ledger data since the redesign, with no surface. This exposes them at read time and shows each session's note as a small chip on its session row in the node detail card — the per-session confidence history the user asked for, one observation per (node, chat), latest wins within a chat. - GraphSnapshot.nodeObservations: nodeId -> chatId -> note, built in graphSnapshot() from observation events (pure read-time join). - Sessions list rows: link + observation chip. - Session-relative judgments stay session-scoped: they render next to their session, never as node state (the state model stays pending).
This commit is contained in:
+22
-1
@@ -447,5 +447,26 @@ export function graphSnapshot(deps: GraphDeps): GraphSnapshot {
|
||||
if (ids.length > 0) nodeSessions[nodeId] = ids;
|
||||
}
|
||||
|
||||
return { nodes, edges, sessions, nodeSessions };
|
||||
// Understanding observations per (node, chat) — the extractor's
|
||||
// session-relative note (latest wins within a chat). Read-time join for
|
||||
// the detail card: the confidence history next to the session list.
|
||||
const nodeObservations: Record<string, Record<string, string>> = {};
|
||||
const latestObs = new Map<string, { at: string; note: string; index: number }>();
|
||||
events.forEach((event, index) => {
|
||||
if (event.kind !== "observation" || event.nodeId === null) return;
|
||||
if (!event.note) return;
|
||||
const key = `${event.nodeId}\u0000${event.chatId}`;
|
||||
const current = latestObs.get(key);
|
||||
if (!current || event.at > current.at || (event.at === current.at && index > current.index)) {
|
||||
latestObs.set(key, { at: event.at, note: event.note, index });
|
||||
}
|
||||
});
|
||||
for (const [key, { note }] of latestObs) {
|
||||
const sep = key.indexOf("\u0000");
|
||||
const nodeId = key.slice(0, sep);
|
||||
const chatId = key.slice(sep + 1);
|
||||
(nodeObservations[nodeId] ??= {})[chatId] = note;
|
||||
}
|
||||
|
||||
return { nodes, edges, sessions, nodeSessions, nodeObservations };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user