From cbe4b0866a35af75009ed791af6f38f4d5d99ccc Mon Sep 17 00:00:00 2001 From: Roland Tannous Date: Thu, 28 May 2026 20:24:15 +0400 Subject: [PATCH] Studio: show total chunks in the aggregate indexing toast The completion toast reported only document count. Capture each job's num_chunks from its complete event into the index-progress store and sum across the batch, so the toast reads 'N documents and M chunks indexed'. Already-indexed (deduped) files contribute 0 new chunks. --- .../src/features/chat/hooks/use-thread-doc-uploads.ts | 2 +- studio/frontend/src/features/chat/shared-composer.tsx | 2 +- .../features/rag/components/ingestion-toast-stack.tsx | 4 +++- .../src/features/rag/stores/index-progress-store.ts | 9 ++++++--- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/studio/frontend/src/features/chat/hooks/use-thread-doc-uploads.ts b/studio/frontend/src/features/chat/hooks/use-thread-doc-uploads.ts index 1de8c445cc..ca355274b8 100644 --- a/studio/frontend/src/features/chat/hooks/use-thread-doc-uploads.ts +++ b/studio/frontend/src/features/chat/hooks/use-thread-doc-uploads.ts @@ -204,7 +204,7 @@ export function useThreadDocUploads(): UseThreadDocUploadsResult { .getState() .setRagSource({ kind: "thread" }); } - indexProgress.setReady(localChipId); + indexProgress.setReady(localChipId, event.num_chunks); releaseSlot(); } else if (event.type === "error") { setPendingDocs((prev) => diff --git a/studio/frontend/src/features/chat/shared-composer.tsx b/studio/frontend/src/features/chat/shared-composer.tsx index 29b655cfc0..338679d26b 100644 --- a/studio/frontend/src/features/chat/shared-composer.tsx +++ b/studio/frontend/src/features/chat/shared-composer.tsx @@ -694,7 +694,7 @@ export function SharedComposer({ .getState() .setRagSource({ kind: "thread" }); } - indexProgress.setReady(localChipId); + indexProgress.setReady(localChipId, event.num_chunks); releaseSlot(); } else if (event.type === "error") { setPendingDocs((prev) => diff --git a/studio/frontend/src/features/rag/components/ingestion-toast-stack.tsx b/studio/frontend/src/features/rag/components/ingestion-toast-stack.tsx index 3c05f77cab..68ce3628c6 100644 --- a/studio/frontend/src/features/rag/components/ingestion-toast-stack.tsx +++ b/studio/frontend/src/features/rag/components/ingestion-toast-stack.tsx @@ -27,6 +27,7 @@ export function IngestionToastStack() { (e) => e.status === "ready" || e.status === "error", ).length; const errored = items.filter((e) => e.status === "error").length; + const totalChunks = items.reduce((sum, e) => sum + (e.chunks || 0), 0); const allDone = total > 0 && done === total; // Overall progress: completed/errored files count as 1, in-flight files // contribute their fractional progress. Smooth even for a handful of files. @@ -74,7 +75,8 @@ export function IngestionToastStack() { if (allDone) { const indexed = total - errored; subtitle = - `${indexed} document${indexed === 1 ? "" : "s"} indexed` + + `${indexed} document${indexed === 1 ? "" : "s"} and ` + + `${totalChunks} chunk${totalChunks === 1 ? "" : "s"} indexed` + (errored > 0 ? ` · ${errored} failed` : ""); } else { subtitle = `${done}/${total} · ${pct}%`; diff --git a/studio/frontend/src/features/rag/stores/index-progress-store.ts b/studio/frontend/src/features/rag/stores/index-progress-store.ts index dd70e30536..fe616ce05e 100644 --- a/studio/frontend/src/features/rag/stores/index-progress-store.ts +++ b/studio/frontend/src/features/rag/stores/index-progress-store.ts @@ -16,6 +16,8 @@ export interface IndexEntry { status: IndexEntryStatus; /** 0..1; only meaningful while `indexing`. */ progress: number; + /** Chunks this file produced (from the job's complete event); 0 until done. */ + chunks: number; } interface IndexProgressState { @@ -23,7 +25,7 @@ interface IndexProgressState { add: (id: string, filename: string) => void; setIndexing: (id: string) => void; setProgress: (id: string, progress: number) => void; - setReady: (id: string) => void; + setReady: (id: string, chunks?: number) => void; setError: (id: string) => void; clear: () => void; } @@ -46,13 +48,14 @@ export const useIndexProgressStore = create((set) => ({ set((s) => ({ entries: { ...s.entries, - [id]: { filename, status: "queued", progress: 0 }, + [id]: { filename, status: "queued", progress: 0, chunks: 0 }, }, })), setIndexing: (id) => patch(set, id, { status: "indexing" }), setProgress: (id, progress) => patch(set, id, { status: "indexing", progress }), - setReady: (id) => patch(set, id, { status: "ready", progress: 1 }), + setReady: (id, chunks = 0) => + patch(set, id, { status: "ready", progress: 1, chunks }), setError: (id) => patch(set, id, { status: "error" }), clear: () => set({ entries: {} }), }));