From f9a9aacc961705b104e6bddd3953618817b2d432 Mon Sep 17 00:00:00 2001 From: HCL Date: Sat, 21 Mar 2026 12:10:49 +0800 Subject: [PATCH] fix(ui): use server total for cron badge count on fresh load MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The cron badge count used Math.max(meta.total, state.cronJobs.length) on every load, including fresh (non-paginated) loads. When a job was deleted between loads, the stale Math.max preserved the old higher count — badge showed 4 while list showed 3. Root cause: ui/src/ui/controllers/cron.ts:291. Math.max is correct for paginated appends (accumulating across pages) but wrong for fresh loads where the server total is authoritative. Fix: on fresh load (append=false) use meta.total directly; on paginated append keep Math.max to account for accumulation. Closes #51382 Co-Authored-By: Claude Opus 4.6 Signed-off-by: HCL --- ui/src/ui/controllers/cron.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/ui/controllers/cron.ts b/ui/src/ui/controllers/cron.ts index c6073a8e626..8ee22f2825f 100644 --- a/ui/src/ui/controllers/cron.ts +++ b/ui/src/ui/controllers/cron.ts @@ -288,7 +288,7 @@ export async function loadCronJobsPage(state: CronState, opts?: { append?: boole hasMoreRaw: res.hasMore, pageCount: jobs.length, }); - state.cronJobsTotal = Math.max(meta.total, state.cronJobs.length); + state.cronJobsTotal = append ? Math.max(meta.total, state.cronJobs.length) : meta.total; state.cronJobsHasMore = meta.hasMore; state.cronJobsNextOffset = meta.nextOffset; if (