[bug][ai-search] "Reindex now" counter does not update (stale until reload) — reindex runs async but the UI reads coverage once and never polls #134
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Severity: medium (UI/UX) — reindexing works, but the coverage counter does not reflect it until a manual page reload.
Symptom
After a base index exists, clicking "Reindex now" (AI settings → Embeddings) does not change the "Indexed X of Y pages" counter / the unindexed count never drops — it looks like reindex does nothing.
What's actually happening (reproduced + isolated on a fresh stand)
Reindex does work — it just runs as a background BullMQ job that indexes pages one-by-one via the embedding provider, while the UI reads the counter once, immediately, before the job has done anything, and never refreshes.
Reproduction (OpenRouter
text-embedding-3-large, fresh DB):indexed=44, total=84→ unindexed=40, stable.POST /api/workspace/ai-settings/reindex:indexed 44 / total 84(unindexed 40 — unchanged).GET(i.e. a manual page reload) afterwards correctly showsindexed=84 / total=84→ unindexed=0.So the indexing is correct; only the displayed counter is stale between the click and a manual reload.
Root cause
apps/server/src/integrations/ai/ai-settings.controller.ts:88-90— thereindexendpoint enqueues the async job and immediately returnsgetMasked()(which reads the current, pre-job counts). The code comment "Return refreshed masked settings so the client can update the counter" is misleading: the job has not run yet, so the counts are stale.apps/client/src/features/workspace/queries/ai-settings-query.ts(reindex mutation) — invalidates/refetches the coverage query once on success (job barely started) and does not poll while the reindex job is in progress. The counter therefore stays at the old value until the user manually reloads the settings page.The effect is masked on small workspaces / fast providers (the job can finish within the request round-trip), which is why it's intermittent.
Suggested fix
While a reindex job is in progress, the client should poll the coverage endpoint until it stabilizes (or the endpoint should expose an "indexing in progress" flag + remaining count, and the client polls until it clears). At minimum, show a "indexing in background…" state so the static counter isn't read as "reindex did nothing".
Found while investigating a user report; reproduced live on
develop@v0.93.0-64-gb60190ffwith a fresh DB and an OpenRouter embedding provider.