fix(knowledge): say what went wrong when a document's chunks fail to load - #6858
Conversation
…load `combinedError = documentError || searchError || initialError` collapsed three different failures into one, blanked the rows and stripped search, sort and filter — and said nothing. A failed read rendered as an empty table, which is the same thing the page shows when a document genuinely has no chunks. Stripping the search box was the worse half: when it was the *search* that failed, the control the user needed to clear it was the one that disappeared. The three are now told apart: - The document itself failing has no page left to draw, so it gets a full screen, matching the base page's 'Knowledge base not found' one level up. It has to run before the editor branches — `selectedChunkId` renders the chunk editor without checking for a document, so a deep link to a chunk of a deleted document sat on 'Loading chunk…' forever. - A failed chunk read keeps the document, so it keeps the chrome and the controls, and the message goes in the table body through the `emptyState` slot. Tinted with the error token, because at the weight the empty states use a failure is indistinguishable from 'nothing here yet'. - A failed search leaves the loaded chunks intact, so it says the search failed rather than claiming the chunks could not be loaded. `searchError` went through `instanceof Error ? .message : null`, so a rejection that was not an `Error` produced no message and fell back to the silent blank this commit exists to remove. It uses `getErrorMessage` now, like the chunk read beside it always did. Pagination is dropped on a failed read — it was counting pages nothing fetched — and the action bar reads the same value, so it no longer lifts itself clear of a bar that is not there. The not-found screen was about to be copied a second time, so it moves to `ResourceNotFound` and the base page adopts it.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryLow Risk Overview Missing document — Early return with shared Chunk load vs search failure — When the document exists but chunk data or search fails, the table keeps search, sort, filter, and headers; Pagination / chrome — Pagination and the action bar offset are cleared on chunk read errors; breadcrumbs no longer swap the document name for an “Error” crumb. Adds Reviewed by Cursor Bugbot for commit 8a4fc0c. Configure here. |
Greptile SummaryThis PR separates document, chunk-load, and search failures so each renders an appropriate recoverable error state.
Confidence Score: 5/5The PR appears safe to merge, with no concrete changed-code failure identified. The revised branches preserve recovery controls for chunk and search failures, render missing documents before editor states, and retain the existing knowledge-base not-found presentation through a shared component.
|
| Filename | Overview |
|---|---|
| apps/sim/app/workspace/[workspaceId]/knowledge/[id]/[documentId]/document.tsx | Separates document and chunk-query failures, adds descriptive table error states, preserves recovery controls, and handles missing documents before editor branches. |
| apps/sim/app/workspace/[workspaceId]/components/resource/resource-not-found.tsx | Introduces a typed reusable full-page missing-resource presentation component. |
| apps/sim/app/workspace/[workspaceId]/knowledge/[id]/base.tsx | Replaces duplicated missing-knowledge-base markup with the shared component without changing its content. |
| apps/sim/app/workspace/[workspaceId]/components/index.ts | Exports the new shared missing-resource component through the workspace component barrel. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Document page] --> B{Document request failed<br/>with no document data?}
B -->|Yes| C[Render ResourceNotFound]
B -->|No| D{Chunk load or search failed?}
D -->|Yes| E[Keep page controls and chrome]
E --> F[Render ChunkLoadError in table body]
D -->|No| G[Render chunk rows and pagination]
Reviews (1): Last reviewed commit: "fix(knowledge): say what went wrong when..." | Re-trigger Greptile
A document that is not `completed` rejects the chunk read by design — `requireChunkReadable` throws `KnowledgeDocumentNotReadyError` before it queries anything — so `initialError` is set for every pending, processing or failed document. Treating that as a load failure put "Couldn't load chunks" over a document that is simply still working. `chunkRows` already builds the right row for those states, and it turns out nothing could ever see it: the old `combinedError` blanked the rows on exactly the same condition, so "Document processing pending..." has been unreachable for as long as it has existed. Excluding not-ready documents from `chunkError` brings the row back and leaves the error state for reads that genuinely failed.
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 8a4fc0c. Configure here.
Found while surveying empty states for #6855.
const combinedError = documentError || searchError || initialErrorcollapsed three different failures into one. On any of them the page blanked the rows, stripped search, sort and filter — and said nothing. A failed read rendered as an empty table, which is exactly what the page shows when a document genuinely has no chunks.Stripping the search box was the worse half. When it was the search that failed, the one control the user needed to clear it was the control that disappeared. The error was a dead end.
Telling the three apart
The document itself failed. There is no page left to draw, so it gets a full screen — the same treatment the base page already gives a missing knowledge base one level up.
This has to run before the editor branches.
selectedChunkIdrenders the chunk editor without checking for a document, and its inner guard falls through to "Loading chunk…" — so a deep link to a chunk of a deleted document sat on a spinner forever.A chunk read failed. The document is fine, so the page keeps its chrome and all its controls, and the message goes in the table body through the
emptyStateslot. The search box surviving is the point: that is the recovery path.It is tinted with
--text-error. At the muted weight the empty states use, a failure is indistinguishable from "nothing here yet" — a softer version of the bug being fixed.A search failed. The loaded chunks are still intact, so claiming the chunks could not be loaded would be untrue. It says the search failed.
A hole in the same class
A rejection that is not an
Errorinstance produced no message, sochunkErrorstayed falsy and the table went silently blank — the exact bug this PR removes. It usesgetErrorMessagenow, which is what the chunk read beside it always did, and whatglobal.mdrequires.Also
'Error'label is gone. It is unreachable by construction now — a missing document early-returns, and in every other case the document name is known and correct. Replacing a correct name with "Error" was the bug, not a feature.ResourceNotFoundand the base page adopts it. More detail routes are coming.Verification
Type-check, biome, 29/29 audits, 2220 tests. The error state was rendered in both themes rather than eyeballed from the markup.