fix(ai): address reindex-progress review round 1 (PR #242)

F1: clear the "Reindex now" spinner once the poll cap fires. Gate the
reindexing part of the button's loading state on the active poll window
(reindexDeadline !== null) so a run that outlives the 120s cap no longer
leaves the button stuck-disabled with a stale `reindexing: true`; the
admin can restart.

F2: rewrite reindexWorkspace JSDoc to describe the EMBEDDABLE page set
(text OR existing embeddings), matching getEmbeddablePageIds /
countEmbeddablePages instead of the old "every non-deleted page".

F3: extract the shared embeddable-content predicate into a private
PageRepo.embeddablePredicate helper, called by both countEmbeddablePages
and getEmbeddablePageIds, removing the verbatim duplication. Behavior is
identical (lockstep int-spec stays green).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
claude code agent 227
2026-06-28 23:39:20 +03:00
parent bf09eec4e1
commit 85b38d6946
3 changed files with 62 additions and 38 deletions
@@ -1084,7 +1084,18 @@ export default function AiProviderSettings() {
// background job keeps running, so also stay loading while the
// server reports `reindexing` (this also blocks a redundant
// re-trigger mid-run; the server de-dupes regardless).
loading={reindexMutation.isPending || settings?.reindexing === true}
//
// Gate the `reindexing` part on the active poll window
// (reindexDeadline !== null): once the 120s poll cap fires it nulls
// reindexDeadline and stops refetching, so `settings.reindexing`
// can be a stale `true` from the last poll. Without this gate the
// spinner would stay stuck (and the button disabled) forever for a
// run that outlives the cap — clearing it here lets the admin
// restart.
loading={
reindexMutation.isPending ||
(reindexDeadline !== null && settings?.reindexing === true)
}
onClick={() =>
reindexMutation.mutate(undefined, {
// Begin bounded polling so the counter climbs as the async