Suno-style web UI for a self-hosted MiniMax-Music3 inference server
TypeScript ai-musicdiffusersdockerexpressminimaxminimax-musicmusic-generationreactself-hostedsgl-omnisunotailwindcsstext-to-musictypescriptvite
feat: phase stepper with step counter, elapsed and ETA on in-flight tracks
Adam Benhassen56e887f8b151
diff --git a/server/src/poller.ts b/server/src/poller.tsindex 4e1d297..b116681 100644--- a/server/src/poller.ts+++ b/server/src/poller.ts@@ -65,6 +65,7 @@ export class Poller {progress: typeof job.progress === 'number' ? job.progress : track.progress,stage: job.stage ?? track.stage,eta: typeof job.eta === 'number' ? job.eta : null,+ elapsed: typeof job.elapsed === 'number' ? job.elapsed : track.elapsed ?? null,seed: typeof job.seed === 'number' ? job.seed : track.seed,};diff --git a/server/src/types.ts b/server/src/types.tsindex c01fd00..a5724fd 100644--- a/server/src/types.ts+++ b/server/src/types.ts@@ -16,6 +16,8 @@ export interface Track {progress: number;stage: string;eta: number | null;+ /** seconds the upstream job has been running (from /jobs/{id}) */+ elapsed?: number | null;error: string | null;file: string | null;createdAt: string;diff --git a/server/test/fakeUpstream.ts b/server/test/fakeUpstream.tsindex 2bf40b8..1cb1d8c 100644--- a/server/test/fakeUpstream.ts+++ b/server/test/fakeUpstream.ts@@ -32,9 +32,9 @@ export function defaultScript(jobId: string, body: Record<string, unknown>): Upsconst seed = typeof body.seed === 'number' ? body.seed : 424242;return [{ job_id: jobId, status: 'queued', progress: 0, stage: 'queued', eta: null, seed, duration, format },- { job_id: jobId, status: 'running', progress: 0.1, stage: 'generating audio tokens', eta: duration * 2.7, seed, duration, format },- { job_id: jobId, status: 'running', progress: 0.5, stage: 'step 210/420', eta: duration * 1.3, seed, duration, format },- { job_id: jobId, status: 'running', progress: 0.95, stage: 'decoding audio', eta: 5, seed, duration, format },+ { job_id: jobId, status: 'running', progress: 0.1, stage: 'generating audio tokens', eta: duration * 2.7, elapsed: 4.2, seed, duration, format },+ { job_id: jobId, status: 'running', progress: 0.5, stage: 'step 210/420', eta: duration * 1.3, elapsed: duration * 1.4, seed, duration, format },+ { job_id: jobId, status: 'running', progress: 0.95, stage: 'decoding audio', eta: 5, elapsed: duration * 2.6, seed, duration, format },{job_id: jobId, status: 'done', progress: 1, stage: 'done', eta: 0, seed, duration, format,audio_url: `/jobs/${jobId}/audio`, sampling_rate: 44100, channels: 2, encoding: 'PCM_24', peak_dbfs: -1.2, clipped: false,diff --git a/server/test/poller.test.ts b/server/test/poller.test.tsindex 8cfa4b8..b13e652 100644--- a/server/test/poller.test.ts+++ b/server/test/poller.test.ts@@ -35,7 +35,7 @@ describe('Poller', () => {await poller.tick(); // queuedexpect(lib.get('t1')?.status).toBe('queued');await poller.tick(); // running 0.1- expect(lib.get('t1')).toMatchObject({ status: 'running', progress: 0.1, stage: 'generating audio tokens', seed: 424242 });+ expect(lib.get('t1')).toMatchObject({ status: 'running', progress: 0.1, stage: 'generating audio tokens', seed: 424242, elapsed: 4.2 });await poller.tick(); await poller.tick(); // 0.5, 0.95await poller.tick(); // done → downloadconst t = lib.get('t1')!;diff --git a/web/src/components/ProgressDetail.tsx b/web/src/components/ProgressDetail.tsxnew file mode 100644index 0000000..dd874be--- /dev/null+++ b/web/src/components/ProgressDetail.tsx@@ -0,0 +1,57 @@+import type { Track } from '../types';+import { fmtEta, fmtTime } from '../lib/format';+import { parseStage, PHASES, phaseIndex } from '../lib/stage';++export function ProgressDetail({ track: t }: { track: Track }) {+ const info = parseStage(t.stage, t.status === 'queued' ? 'queued' : 'running');+ const cur = phaseIndex(info.phase);+ const pct = Math.round(t.progress * 100);+ const indeterminate = t.progress <= 0 && info.phase !== 'download';++ return (+ <div className="mt-2 space-y-1.5">+ {/* phase stepper */}+ <ol className="flex items-center gap-1 text-[10px]">+ {PHASES.map((p, i) => {+ const state = i < cur ? 'done' : i === cur ? 'active' : 'todo';+ return (+ <li key={p.id} className="flex items-center gap-1 min-w-0">+ <span+ className={`px-1.5 py-0.5 rounded-md whitespace-nowrap transition ${+ state === 'active' ? 'bg-accent-soft text-white ring-1 ring-accent/60' : state === 'done' ? 'text-zinc-400' : 'text-zinc-600'+ }`}+ >+ {state === 'done' ? '✓ ' : ''}{p.label}+ {state === 'active' && info.step ? <span className="tabular-nums text-zinc-300"> {info.step.n}/{info.step.total}</span> : null}+ </span>+ {i < PHASES.length - 1 && <span className={`w-3 h-px ${i < cur ? 'bg-zinc-500' : 'bg-ink-600'}`} />}+ </li>+ );+ })}+ </ol>++ {/* bar */}+ <div className="h-1.5 rounded-full bg-ink-700 overflow-hidden relative">+ <div+ className={`h-full rounded-full bg-gradient-to-r from-accent to-purple-400 transition-[width] duration-700 ease-out ${indeterminate ? 'animate-pulseBar w-1/12' : ''}`}+ style={indeterminate ? undefined : { width: `${Math.max(2, pct)}%` }}+ />+ {info.step && (+ <div className="absolute inset-0 pointer-events-none">+ {[0.25, 0.5, 0.75].map((f) => <span key={f} className="absolute top-0 h-full w-px bg-ink-900/60" style={{ left: `${f * 100}%` }} />)}+ </div>+ )}+ </div>++ {/* numbers */}+ <div className="flex items-center justify-between text-[11px] text-zinc-400 tabular-nums">+ <span className="truncate">{info.label}</span>+ <span className="shrink-0 flex items-center gap-2">+ <span className="text-zinc-300">{indeterminate ? '' : `${pct}%`}</span>+ {typeof t.elapsed === 'number' && t.elapsed > 0 && <span title="elapsed">{fmtTime(t.elapsed)} elapsed</span>}+ {t.eta !== null && t.eta > 0 && <span title="estimated remaining" className="text-zinc-300">{fmtEta(t.eta)}</span>}+ </span>+ </div>+ </div>+ );+}diff --git a/web/src/components/TrackCard.tsx b/web/src/components/TrackCard.tsxindex 2d7a96c..64953df 100644--- a/web/src/components/TrackCard.tsx+++ b/web/src/components/TrackCard.tsx@@ -1,9 +1,10 @@import { useState } from 'react';import { isInflight, type Track } from '../types';import { coverStyle } from '../lib/cover';-import { fmtAgo, fmtEta, fmtTime, FORMAT_LABEL } from '../lib/format';+import { fmtAgo, fmtTime, FORMAT_LABEL } from '../lib/format';import { api } from '../api';import { Alert, Download, Pause, Play, Refresh, Reuse, Trash, X } from './Icons';+import { ProgressDetail } from './ProgressDetail';interface Props {track: Track;@@ -76,17 +77,7 @@ export function TrackCard({ track: t, groupSize, active, playing, onPlay, onDele)}</div>- {inflight && (- <div className="mt-2">- <div className="h-1.5 rounded-full bg-ink-700 overflow-hidden">- <div className={`h-full rounded-full bg-gradient-to-r from-accent to-purple-400 transition-all ${t.progress === 0 ? 'animate-pulseBar w-1/12' : ''}`} style={t.progress > 0 ? { width: `${Math.max(2, t.progress * 100)}%` } : undefined} />- </div>- <div className="flex justify-between text-[11px] text-zinc-400 mt-1">- <span>{t.stage}</span>- <span>{fmtEta(t.eta)}</span>- </div>- </div>- )}+ {inflight && <ProgressDetail track={t} />}{err && <div className="mt-2 text-[11px] text-red-400 break-words">{t.error}</div>}</div>diff --git a/web/src/lib/stage.ts b/web/src/lib/stage.tsnew file mode 100644index 0000000..f0c8219--- /dev/null+++ b/web/src/lib/stage.ts@@ -0,0 +1,34 @@+export type PhaseId = 'queued' | 'tokens' | 'diffusion' | 'decode' | 'download';++export const PHASES: { id: PhaseId; label: string }[] = [+ { id: 'queued', label: 'Queued' },+ { id: 'tokens', label: 'Audio tokens' },+ { id: 'diffusion', label: 'Diffusion' },+ { id: 'decode', label: 'Decode' },+ { id: 'download', label: 'Download' },+];++export interface StageInfo {+ phase: PhaseId;+ /** human label for the current stage, e.g. "Diffusion step 176 / 420" */+ label: string;+ step?: { n: number; total: number };+}++/** Map the upstream `stage` string (+ status) onto a coarse phase. */+export function parseStage(stage: string, status: 'queued' | 'running'): StageInfo {+ const s = (stage || '').toLowerCase().trim();+ const m = /step\s+(\d+)\s*\/\s*(\d+)/.exec(s);+ if (m) {+ const n = Number(m[1]);+ const total = Number(m[2]);+ return { phase: 'diffusion', label: `Diffusion · step ${n} / ${total}`, step: { n, total } };+ }+ if (s.includes('token')) return { phase: 'tokens', label: 'Generating audio tokens' };+ if (s.includes('decod')) return { phase: 'decode', label: 'Decoding audio' };+ if (s.includes('download')) return { phase: 'download', label: 'Downloading render' };+ if (status === 'queued' || s === 'queued' || s === 'submitting' || s === '') return { phase: 'queued', label: s === 'submitting' ? 'Submitting to inference server' : 'Waiting in queue' };+ return { phase: 'tokens', label: stage };+}++export const phaseIndex = (p: PhaseId) => PHASES.findIndex((x) => x.id === p);diff --git a/web/src/types.ts b/web/src/types.tsindex 5e2308e..148837e 100644--- a/web/src/types.ts+++ b/web/src/types.ts@@ -16,6 +16,8 @@ export interface Track {progress: number;stage: string;eta: number | null;+ /** seconds the upstream job has been running (from /jobs/{id}) */+ elapsed?: number | null;error: string | null;file: string | null;createdAt: string;