fix(ai): stop RAG coverage bar sticking below 100% on empty pages

"Indexed N of M pages" stayed at e.g. "27 of 34" forever even after a
successful full reindex. The numerator counted pages that have embeddings
while the denominator counted ALL non-deleted pages, so empty / text-less
pages (which legitimately store zero embeddings) could never be reached.

Add PageRepo.countEmbeddablePages: counts non-deleted pages that have
non-empty textContent OR already have a stored embedding row, and use it as
the totalPages denominator in AiSettingsService.getMasked. The "has
embeddings" clause covers pages indexed from the content JSON (null
textContent) and guarantees indexedPages <= totalPages. No DB migration.
This commit is contained in:
vvzvlad
2026-06-18 03:33:38 +03:00
parent 4be849f8a1
commit 91a63f0b2c
2 changed files with 42 additions and 1 deletions
@@ -160,9 +160,12 @@ export class AiSettingsService {
hasEmbeddingApiKey = !!creds?.embeddingApiKeyEnc;
}
// totalPages now counts only pages with embeddable content (non-empty text
// or already-stored embeddings), so empty/text-less pages don't keep the
// "Indexed N of M pages" bar below 100% forever.
const [indexedPages, totalPages] = await Promise.all([
this.pageEmbeddingRepo.countIndexedPages(workspaceId),
this.pageRepo.countByWorkspace(workspaceId),
this.pageRepo.countEmbeddablePages(workspaceId),
]);
return {