From 624262fccab76ac8cec332ee6b0ad6b6ca79f9ec Mon Sep 17 00:00:00 2001 From: Sulthan Nauval Abdillah Date: Mon, 10 Aug 2026 11:59:48 +0000 Subject: [PATCH] fix(ops): re-extract toast reports failed chunks with the reason MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - backend (RantAIClaw plan 109) now counts extractor failures and 502s on total failure; partial failures arrive as failed_chunks + error on the 200 response — render them as a warning toast instead of presenting a partial extraction as a clean success - total failure already lands in the catch arm and shows the 502's extraction_failed detail - KbReExtractResult type widened (optional fields; older gateways omit them and keep today's behaviour) --- src/components/ops/doc-intelligence-drawer.tsx | 17 +++++++++++++---- src/lib/types.ts | 5 +++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/components/ops/doc-intelligence-drawer.tsx b/src/components/ops/doc-intelligence-drawer.tsx index 0928aa2..693cdc9 100644 --- a/src/components/ops/doc-intelligence-drawer.tsx +++ b/src/components/ops/doc-intelligence-drawer.tsx @@ -57,10 +57,19 @@ export function DocIntelligenceBody({ documentId }: { documentId: string }) { const t = toast.loading("Re-extracting intelligence…"); try { const r = await api.kbReExtractDocument(documentId); - toast.success( - `Found ${formatNumber(r.entities)} entities · ${formatNumber(r.relations)} relations in this document`, - { id: t }, - ); + if ((r.failed_chunks ?? 0) > 0) { + // Partial failure: some chunks extracted, some did not — say both. + toast.warning( + `Found ${formatNumber(r.entities)} entities · ${formatNumber(r.relations)} relations — ` + + `${formatNumber(r.failed_chunks ?? 0)} chunks failed${r.error ? ` (${r.error})` : ""}`, + { id: t }, + ); + } else { + toast.success( + `Found ${formatNumber(r.entities)} entities · ${formatNumber(r.relations)} relations in this document`, + { id: t }, + ); + } intel.refresh(); } catch (e) { toast.error(`Re-extract failed: ${e instanceof Error ? e.message : String(e)}`, { id: t }); diff --git a/src/lib/types.ts b/src/lib/types.ts index 3697a0a..8bf2544 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -281,6 +281,11 @@ export interface KbReExtractResult { document_id: string; entities: number; relations: number; + /** Chunks the extractor failed on. Non-zero with zero entities means the + * extraction failed — not "no entities". Older gateways omit it. */ + failed_chunks?: number; + /** First failure reason (short; never the upstream body). */ + error?: string; } export interface ChannelsInfo {