fix(progress): separate model warmup state
All checks were successful
Build & Push Docker Image / test (push) Successful in 11s
Build & Push Docker Image / build-and-push (push) Successful in 42s

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-05-12 00:52:33 +02:00
parent 929c482497
commit f70cefc5e9
9 changed files with 194 additions and 72 deletions

View File

@@ -123,7 +123,7 @@ describe('setJobStatus', () => {
it('transitions through all valid statuses', () => {
const job = createJob('src', 'title', 'auto');
const statuses = ['downloading', 'preparing', 'transcribing', 'processing', 'done'] as const;
const statuses = ['downloading', 'preparing', 'warming_model', 'transcribing', 'processing', 'done'] as const;
for (const status of statuses) {
setJobStatus(job.id, status, 50);
expect(getJob(job.id)!.status).toBe(status);

View File

@@ -0,0 +1,49 @@
import { describe, expect, it } from 'vitest';
import { getDisplayJobProgress, getJobStatusLabel, isTerminalJobStatus } from '$lib/job-progress.js';
import type { Job } from '$lib/types.js';
function makeJob(overrides: Partial<Job> = {}): Job {
return {
id: 'job-1',
status: 'transcribing',
title: 'Job',
source: 'https://example.com/audio.mp3',
audioMode: 'auto',
meanVolume: null,
whisperJobId: null,
progress: 42,
outputDir: null,
segmentsJson: null,
error: null,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
...overrides
};
}
describe('job progress helpers', () => {
it('keeps active jobs below 100 percent', () => {
expect(getDisplayJobProgress(makeJob({ status: 'transcribing', progress: 100 }))).toBe(99);
});
it('keeps model loading in an early progress band', () => {
expect(getDisplayJobProgress(makeJob({ status: 'warming_model', progress: 80 }))).toBe(15);
});
it('allows 100 percent once finished job has transcript payload', () => {
expect(
getDisplayJobProgress(makeJob({ status: 'done', progress: 100, segmentsJson: JSON.stringify([]) }), {
hasTranscript: true
})
).toBe(100);
});
it('holds done jobs below 100 percent until transcript data exists', () => {
expect(getDisplayJobProgress(makeJob({ status: 'done', progress: 100 }))).toBe(99);
});
it('exposes model-loading label as active state', () => {
expect(getJobStatusLabel('warming_model')).toBe('Loading model');
expect(isTerminalJobStatus('warming_model')).toBe(false);
});
});