Align video progress with backend job progress

This commit is contained in:
vineyardbovines
2026-08-04 09:32:23 -04:00
committed by Samuel Newman
parent 590abd05c9
commit f5ca5b14cc
3 changed files with 14 additions and 16 deletions
+1 -4
View File
@@ -2675,10 +2675,7 @@ function VideoUploadToolbar({state}: {state: VideoState}) {
const processingProgress =
state.status === 'processing' ? state.jobStatus?.progress : undefined
const shouldRotate =
state.status === 'processing' &&
(processingProgress === undefined ||
processingProgress <= 0 ||
processingProgress >= 100)
state.status === 'processing' && processingProgress === undefined
let wheelProgress = progress
const rotate = useDerivedValue(() => {
@@ -3,16 +3,17 @@ import {advanceVideoProgress, videoProgressForPhase} from './videoProgress'
describe('videoProgressForPhase', () => {
it('maps each phase onto one continuous timeline', () => {
expect(videoProgressForPhase('compressing', 0)).toBe(0)
expect(videoProgressForPhase('compressing', 1)).toBe(0.4)
expect(videoProgressForPhase('uploading', 0)).toBe(0.4)
expect(videoProgressForPhase('uploading', 1)).toBe(0.55)
expect(videoProgressForPhase('processing', 0)).toBe(0.55)
expect(videoProgressForPhase('processing', 1)).toBe(0.95)
expect(videoProgressForPhase('compressing', 1)).toBe(0.3)
expect(videoProgressForPhase('uploading', 0)).toBe(0.3)
expect(videoProgressForPhase('uploading', 1)).toBe(0.5)
expect(videoProgressForPhase('processing', 0)).toBe(0.5)
expect(videoProgressForPhase('processing', 0.5)).toBe(0.75)
expect(videoProgressForPhase('processing', 1)).toBe(1)
})
it('clamps invalid phase progress', () => {
expect(videoProgressForPhase('uploading', -1)).toBe(0.4)
expect(videoProgressForPhase('uploading', 2)).toBe(0.55)
expect(videoProgressForPhase('uploading', -1)).toBe(0.3)
expect(videoProgressForPhase('uploading', 2)).toBe(0.5)
})
})
+5 -5
View File
@@ -1,12 +1,12 @@
export type VideoProgressPhase = 'compressing' | 'uploading' | 'processing'
// Keep progress monotonic across the full client pipeline instead of showing
// three separate 0 -> 100 cycles. Processing stops short of complete because
// a server-reported 100% can precede the completed blob becoming available.
// three separate 0 -> 100 cycles. Backend processing progress covers the
// entire server-side job, so it maps directly onto the final half.
const PHASE_RANGES: Record<VideoProgressPhase, [number, number]> = {
compressing: [0, 0.4],
uploading: [0.4, 0.55],
processing: [0.55, 0.95],
compressing: [0, 0.3],
uploading: [0.3, 0.5],
processing: [0.5, 1],
}
export function videoProgressForPhase(