From 68c0a37cab71206d0e8697ef65420e023eee0c6e Mon Sep 17 00:00:00 2001 From: chriscrosstalk <49691103+chriscrosstalk@users.noreply.github.com> Date: Fri, 15 May 2026 23:01:45 -0700 Subject: [PATCH] fix(RAG): anchor continuation-batch initial progress to overall-file frame (#889) Each continuation batch of a multi-batch ZIM embed runs as a fresh BullMQ job, so handle() ran the hardcoded `safeUpdateProgress(job, 5)` even when the file was already 100k articles into a 600k-article ZIM. The UI gauge briefly dropped to 5% before the per-batch onProgress callback caught up to the true overall percentage, reading as a backward jump every time a new batch started. Compute initialPercent from batchOffset / totalArticles when available, falling back to 5 for single-batch files (uploaded PDFs, txts) where totalArticles isn't set. Capped at 99 to leave headroom for the 100% final-batch marker. Follow-up to PR #880 (which fixed the 0-100% scaling during a batch but still had the initial-frame regression). --- admin/app/jobs/embed_file_job.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/admin/app/jobs/embed_file_job.ts b/admin/app/jobs/embed_file_job.ts index 4607a9a..844af7d 100644 --- a/admin/app/jobs/embed_file_job.ts +++ b/admin/app/jobs/embed_file_job.ts @@ -85,8 +85,16 @@ export class EmbedFileJob { logger.info(`[EmbedFileJob] Services ready. Processing file: ${fileName}`) - // Update progress starting - await this.safeUpdateProgress(job, 5) + // Anchor initial progress to where we are in the overall file. For a + // continuation batch midway through a multi-batch ZIM (e.g. offset 100k of + // 600k), the hardcoded 5 used to make the gauge briefly flash 0→5→real, + // which read as a backward jump. Fall back to 5 for single-batch files + // where totalArticles isn't set. + const initialPercent = + totalArticles && totalArticles > 0 + ? Math.min(99, Math.round(((batchOffset || 0) / totalArticles) * 100)) + : 5 + await this.safeUpdateProgress(job, initialPercent) await job.updateData({ ...job.data, status: 'processing',