Report how many documents the reindex actually queues

The index-all trigger returned Boolean(jobId) while the client typed
the field as a number, so the toast read "Indexing true document(s)".
The route now answers with the count of live documents still lacking a
content index, computed from the same live-scoped counts the usage
gauge reads, and an honest 0 when no job was created. OpenAPI schema
updated to the integer shape; the hook's type carries a contract note
so the wire and the toast cannot drift apart again. Route test pins
the number, a component test pins that the toast renders the count and
never the word "true".

Refs #776
This commit is contained in:
Marc-André Bombeck committed 2026-08-13 12:13:55 +02:00
1 parent 4543fa7192
commit 86a3d74187
6 files changed
+290 -8

No files matched your search

+3 -2
View File
@@ -1028,12 +1028,13 @@ export const inboundDocumentPaths: NonNullable<ZodOpenApiObject["paths"]> = {
"Enqueues a background job that content-indexes the caller's not-yet-indexed documents (one provider transcription each, bounded + resumable). Gated on the module, a configured vision provider (422 `documents.inbound.providerUnsupported` otherwise), and the existing AI consent (403 otherwise). Returns immediately; the work runs off-request on the queue.",
responses: {
"200": {
description: "Whether a backfill job was enqueued.",
description:
"How many live documents the enqueued backfill still has to index (0 when everything is indexed or no job was created).",
content: {
"application/json": {
schema: dataEnvelope(
z
.object({ enqueued: z.boolean() })
.object({ enqueued: z.number().int().nonnegative() })
.meta({ id: "DocumentReindexResponse" }),
"DocumentReindexEnvelope",
),