fix(web): live progress in the archive and a working state at 0%
- the archive re-fetches every 3 s while any job is queued or processing; it loaded once, so its progress bars never moved - ProgressBar shows a moving bar while no progress has been reported yet, with "Getting ready" in place of 0%, and falls back to a pulse under prefers-reduced-motion - the job page uses the translated percent string, so English no longer shows the Persian percent sign
This commit is contained in:
7 files changed
+62
-16
No files matched your search
@@ -81,6 +81,11 @@ The format follows [Keep a Changelog](https://keepachangelog.com/) and the proje
|
||||
its progress sat at 0% for the whole job and then jumped to 100%. The
|
||||
Whisper engine reports how far into the chunk it is as each segment is
|
||||
decoded; the worker saves that at most once a second.
|
||||
- The archive page refreshes itself while any job is queued or processing;
|
||||
its progress bars never moved before. A job with no progress reported yet
|
||||
shows a moving bar and "Getting ready" instead of an empty, stuck-looking
|
||||
bar at 0%, and the job page shows the percentage with the right sign in
|
||||
English.
|
||||
|
||||
## [1.4.1] - 2026-11-26
|
||||
|
||||
|
||||
@@ -100,6 +100,7 @@
|
||||
"statusFailed": "Failed",
|
||||
"progressLabel": "Processing progress",
|
||||
"percent": "{value}%",
|
||||
"preparing": "Getting ready…",
|
||||
"emptyTitle": "No transcriptions yet",
|
||||
"emptyDesc": "Upload your first file and it will show up here.",
|
||||
"emptyCta": "New transcription",
|
||||
|
||||
@@ -100,6 +100,7 @@
|
||||
"statusFailed": "ناموفق",
|
||||
"progressLabel": "پیشرفت پردازش",
|
||||
"percent": "{value}٪",
|
||||
"preparing": "در حال آمادهسازی…",
|
||||
"emptyTitle": "هنوز رونویسیای نداری",
|
||||
"emptyDesc": "اولین فایل را بارگذاری کن تا همینجا فهرست شود.",
|
||||
"emptyCta": "رونویسی تازه",
|
||||
|
||||
@@ -67,6 +67,7 @@ export default function JobDetailPage() {
|
||||
const { id: jobId } = useParams<{ id: string }>();
|
||||
const locale = useLocale();
|
||||
const t = useTranslations("jobDetail");
|
||||
const tj = useTranslations("jobs");
|
||||
const tc = useTranslations("common");
|
||||
const te = useTranslations("errors");
|
||||
const router = useRouter();
|
||||
@@ -275,12 +276,15 @@ export default function JobDetailPage() {
|
||||
<h2 className="font-bold text-stone-900">{t("processingTitle")}</h2>
|
||||
<p className="mt-1.5 text-sm leading-7 text-stone-600">{t("processingDesc")}</p>
|
||||
<div className="mt-4">
|
||||
<ProgressBar value={job.progress} label={t("metaDuration")} />
|
||||
<p className="mt-1.5 text-xs text-stone-500">
|
||||
{new Intl.NumberFormat(locale).format(
|
||||
Math.min(100, Math.max(0, Math.round(job.progress))),
|
||||
)}
|
||||
٪
|
||||
<ProgressBar value={job.progress} label={tj("progressLabel")} />
|
||||
<p className="mt-1.5 text-xs text-stone-500" aria-live="polite">
|
||||
{job.progress > 0
|
||||
? tj("percent", {
|
||||
value: new Intl.NumberFormat(locale).format(
|
||||
Math.min(100, Math.round(job.progress)),
|
||||
),
|
||||
})
|
||||
: tj("preparing")}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -24,6 +24,8 @@ function formatDate(iso: string, locale: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
const REFRESH_INTERVAL_MS = 3000;
|
||||
|
||||
export default function JobsPage() {
|
||||
const t = useTranslations("jobs");
|
||||
const tc = useTranslations("common");
|
||||
@@ -35,6 +37,8 @@ export default function JobsPage() {
|
||||
const [query, setQuery] = useState("");
|
||||
const [items, setItems] = useState<JobListItem[] | null>(null);
|
||||
const [listError, setListError] = useState<string | null>(null);
|
||||
// Bumped to re-fetch the list while any job is still queued or processing.
|
||||
const [refreshTick, setRefreshTick] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
if (!getToken()) router.replace("/login");
|
||||
@@ -72,7 +76,15 @@ export default function JobsPage() {
|
||||
cancelled = true;
|
||||
clearTimeout(timer);
|
||||
};
|
||||
}, [query]);
|
||||
}, [query, refreshTick]);
|
||||
|
||||
const hasRunningJobs =
|
||||
items?.some((job) => job.status === "queued" || job.status === "processing") ?? false;
|
||||
useEffect(() => {
|
||||
if (!hasRunningJobs) return;
|
||||
const timer = setTimeout(() => setRefreshTick((tick) => tick + 1), REFRESH_INTERVAL_MS);
|
||||
return () => clearTimeout(timer);
|
||||
}, [hasRunningJobs, items]);
|
||||
|
||||
const hasQuery = query.trim().length > 0;
|
||||
|
||||
@@ -169,13 +181,15 @@ export default function JobsPage() {
|
||||
<StatusBadge status={job.status} />
|
||||
</div>
|
||||
</div>
|
||||
{job.status === "processing" ? (
|
||||
{job.status === "queued" || job.status === "processing" ? (
|
||||
<div className="mt-4">
|
||||
<ProgressBar value={job.progress} label={t("progressLabel")} />
|
||||
<p className="mt-1.5 text-xs text-stone-500">
|
||||
{t("percent", {
|
||||
value: nf.format(Math.min(100, Math.max(0, job.progress))),
|
||||
})}
|
||||
{job.progress > 0
|
||||
? t("percent", {
|
||||
value: nf.format(Math.min(100, Math.round(job.progress))),
|
||||
})
|
||||
: t("preparing")}
|
||||
</p>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
@@ -3,6 +3,16 @@
|
||||
@theme {
|
||||
--font-vazir: var(--font-vazirmatn, Vazirmatn), var(--font-inter, Inter), ui-sans-serif,
|
||||
system-ui, sans-serif;
|
||||
--animate-progress-indeterminate: progress-indeterminate 1.4s ease-in-out infinite;
|
||||
|
||||
@keyframes progress-indeterminate {
|
||||
0% {
|
||||
transform: translateX(-100%);
|
||||
}
|
||||
100% {
|
||||
transform: translateX(250%);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
body {
|
||||
|
||||
@@ -34,8 +34,14 @@ export function StatusBadge({ status }: { status: JobStatus }) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determinate bar once the worker reports progress. While nothing has been
|
||||
* reported yet (queued, model loading, first seconds of decoding) it shows
|
||||
* a moving bar instead of an empty track that looks stuck.
|
||||
*/
|
||||
export function ProgressBar({ value, label }: { value: number; label?: string }) {
|
||||
const clamped = Math.min(100, Math.max(0, value));
|
||||
const indeterminate = clamped <= 0;
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -43,13 +49,18 @@ export function ProgressBar({ value, label }: { value: number; label?: string })
|
||||
role="progressbar"
|
||||
aria-valuemin={0}
|
||||
aria-valuemax={100}
|
||||
aria-valuenow={Math.round(clamped)}
|
||||
aria-valuenow={indeterminate ? undefined : Math.round(clamped)}
|
||||
aria-busy={indeterminate || undefined}
|
||||
aria-label={label}
|
||||
>
|
||||
<div
|
||||
className="h-full rounded-full bg-teal-700 transition-[width] duration-500 ease-out"
|
||||
style={{ width: `${clamped}%` }}
|
||||
/>
|
||||
{indeterminate ? (
|
||||
<div className="h-full w-2/5 rounded-full bg-teal-700/70 animate-progress-indeterminate motion-reduce:w-full motion-reduce:animate-pulse" />
|
||||
) : (
|
||||
<div
|
||||
className="h-full rounded-full bg-teal-700 transition-[width] duration-500 ease-out"
|
||||
style={{ width: `${clamped}%` }}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user