fix(scheduler): show progress for any running job with reliable live updates

The dashboard now renders a progress bar for any running job — determinate
when counts are reported, an indeterminate "working" sliver otherwise — so a
scheduled run is as visible as a manual one (progress was never manual-only;
the wiring is shared, but only some jobs reported and the display gated on
counts).

Poll faster (1.5s) while any job runs, easing back to 4s when idle, derived
from the freshest data by react-query's functional refetchInterval. The
earlier React-state approach to this stalled the live updates (the row froze
on the first sampled value); useLiveQuery now accepts a function of the data.
Trilingual phase labels for the newly-reporting jobs.
This commit is contained in:
npeter83 2026-06-19 02:43:46 +02:00
parent 6eb552fa04
commit cd026aaf79
5 changed files with 45 additions and 12 deletions

View file

@ -8,14 +8,22 @@ import { useQuery, type QueryKey } from "@tanstack/react-query";
export function useLiveQuery<T>(
key: QueryKey,
queryFn: () => Promise<T>,
opts: { intervalMs?: number; enabled?: boolean } = {}
// intervalMs may be a function of the latest data, so the poll cadence can adapt to it
// (e.g. poll faster while a job is running). react-query re-evaluates it after each fetch
// against fresh data — the right place for this, vs. a React state toggle that can lag or
// stall the live updates.
opts: { intervalMs?: number | ((data: T | undefined) => number); enabled?: boolean } = {}
) {
const { intervalMs = 4000, enabled = true } = opts;
return useQuery({
queryKey: key,
queryFn,
enabled,
refetchInterval: enabled ? intervalMs : false,
refetchInterval: !enabled
? false
: typeof intervalMs === "function"
? (query) => intervalMs(query.state.data as T | undefined)
: intervalMs,
refetchIntervalInBackground: false,
staleTime: 0,
});