Background pipeline status: registry + /api/graph/status + graph-view chips
The background extraction pipeline is invisible on the home surface — essential observability per the user's directive: the graph view must show what is currently running (extracting / auditing / merging) and for which chat. - extraction.ts: module-level registry of in-flight runs (chatId, phase, startedAt), updated at each phase transition in runExtraction and cleared in finally (done or failed). extractionStatuses() is the read; one process, one registry. - GET /api/graph/status: thin transport over the registry, chat titles joined from the chat store. - graph-view: polls every 2s and shows one chip per running pipeline (spinner + phase + title + elapsed seconds, bottom-left); when a run finishes (some -> none) the graph refetches, so merges land live. Status is cosmetic — poll errors never surface. - Unit test drives a mocked pipeline run and observes the registry mid-flight: 'extracting' during the extractor's generate, 'auditing' during the auditor's, empty after.
This commit is contained in:
@@ -2,8 +2,8 @@ import { graphView } from "@/src/server";
|
||||
|
||||
/**
|
||||
* The home graph view's data endpoint (W4; vision §1 "Home page") — thin
|
||||
* transport: the server entry (src/server/graph.ts) folds stale chats and
|
||||
* returns nodes, edges, derived node states, and session provenance.
|
||||
* transport: the server entry (src/server/graph.ts) returns nodes, edges,
|
||||
* session provenance, and per-session understanding observations.
|
||||
*/
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* GET /api/graph/status — the in-flight background extraction runs
|
||||
* (vision §1: the pipeline status must be visible on the home graph).
|
||||
* Thin transport over the pipeline's module-level registry: phase
|
||||
* (extracting / auditing / merging) per chat, oldest first. Titles joined
|
||||
* from the chat store; a missing chat record still reports the run.
|
||||
*/
|
||||
import { extractionStatuses } from "@/src/agent/subagents/extraction.ts";
|
||||
import { chatStore } from "@/src/store/chats.ts";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function GET() {
|
||||
const runs = extractionStatuses().map((run) => ({
|
||||
chatId: run.chatId,
|
||||
title: chatStore.getChat(run.chatId)?.title ?? run.chatId,
|
||||
phase: run.phase,
|
||||
startedAt: run.startedAt,
|
||||
}));
|
||||
return Response.json({ runs });
|
||||
}
|
||||
Reference in New Issue
Block a user