Suno-style web UI for a self-hosted MiniMax-Music3 inference server
TypeScript ai-musicdiffusersdockerexpressminimaxminimax-musicmusic-generationreactself-hostedsgl-omnisunotailwindcsstext-to-musictypescriptvite
ui: real stage stepper and playable-while-rendering cards
Adam Benhassenb7e338fb77d0
diff --git a/web/src/components/HealthPill.tsx b/web/src/components/HealthPill.tsxindex d53ad04..92133f7 100644--- a/web/src/components/HealthPill.tsx+++ b/web/src/components/HealthPill.tsx@@ -8,7 +8,7 @@ export function HealthPill({ health }: { health: Health | null }) {if (!health.upstreamReachable) { dot = 'bg-red-500'; text = 'Inference server offline'; }else if (!health.ready) { dot = 'bg-amber-400'; text = 'Loading model…'; pulse = true; }else if (health.busy) { dot = 'bg-accent'; text = `Rendering${health.queued ? ` · ${health.queued} queued` : ''}`; pulse = true; }- else { dot = 'bg-emerald-400'; text = 'Idle · ready'; }+ else { dot = 'bg-emerald-400'; text = `Idle · ready${health.capabilities?.includes('stream') ? ' · live progress' : ''}`; }}return (<div className="inline-flex items-center gap-2 rounded-full bg-ink-800 border border-ink-600 px-3 py-1 text-xs text-zinc-300" title={health?.error ?? ''}>diff --git a/web/src/components/ProgressDetail.tsx b/web/src/components/ProgressDetail.tsxindex a0b784f..2afe8cd 100644--- a/web/src/components/ProgressDetail.tsx+++ b/web/src/components/ProgressDetail.tsx@@ -1,24 +1,25 @@import type { Track } from '../types';import { fmtEta, fmtTime } from '../lib/format';-import { parseStage, PHASES, phaseIndex } from '../lib/stage';+import { parseStage, phasesFor, 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 info = parseStage(t.stage, t.status === 'queued' ? 'queued' : 'running', t.renderedSeconds);+ const phases = phasesFor(info.real);+ const cur = phaseIndex(phases, info.phase);const pct = Math.round(t.progress * 100);const indeterminate = t.status === 'queued';return (<div className="mt-2 space-y-1.5">- <ol className="flex items-center gap-1 text-[10px]">- {PHASES.map((p, i) => {+ <ol className="flex flex-wrap items-center gap-x-1 gap-y-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}</span>- {i < PHASES.length - 1 && <span className={`w-3 h-px ${i < cur ? 'bg-zinc-500' : 'bg-ink-600'}`} />}+ {i < phases.length - 1 && <span className={`w-3 h-px ${i < cur ? 'bg-zinc-500' : 'bg-ink-600'}`} />}</li>);})}@@ -31,10 +32,11 @@ export function ProgressDetail({ track: t }: { track: Track }) {/></div>- <div className="flex items-center justify-between text-[11px] text-zinc-400 tabular-nums">+ <div className="flex flex-wrap items-center justify-between gap-x-2 gap-y-0.5 text-[11px] text-zinc-400 tabular-nums"><span className="truncate">{info.label}</span>- <span className="shrink-0 flex items-center gap-2">- {!indeterminate && <span className="text-zinc-300">~{pct}%</span>}+ <span className="flex flex-wrap items-center gap-x-2">+ {!indeterminate && <span className="text-zinc-300">{info.real ? '' : '~'}{pct}%</span>}+ {info.real && (t.renderedSeconds ?? 0) > 0 && <span title="audio rendered so far">{fmtTime(t.renderedSeconds!)} / {fmtTime(t.duration)} rendered</span>}{typeof t.elapsed === 'number' && t.elapsed > 0 && <span title="elapsed">{fmtTime(t.elapsed)} elapsed</span>}{t.eta !== null && t.eta > 0 && !indeterminate && <span title="estimated remaining" className="text-zinc-300">≈ {fmtEta(t.eta)}</span>}</span>diff --git a/web/src/components/SettingsPanel.tsx b/web/src/components/SettingsPanel.tsxindex 86656af..78fe05c 100644--- a/web/src/components/SettingsPanel.tsx+++ b/web/src/components/SettingsPanel.tsx@@ -127,7 +127,7 @@ export function SettingsPanel({ onSaved }: { onSaved: () => void }) {{test && (<div className={`text-xs rounded-lg px-3 py-2 border ${test.ok ? 'text-emerald-300 bg-emerald-500/10 border-emerald-500/30' : 'text-red-300 bg-red-500/10 border-red-500/30'}`}>{test.ok- ? <>Reachable at <span className="font-mono">{test.musicApi}</span>{test.health?.models?.length ? ` · models: ${test.health.models.join(', ')}` : ''}{test.health?.formats?.length ? ` · formats: ${test.health.formats.join(', ')}` : ''}</>+ ? <>Reachable at <span className="font-mono">{test.musicApi}</span>{test.health?.models?.length ? ` · models: ${test.health.models.join(', ')}` : ''}{test.health?.formats?.length ? ` · formats: ${test.health.formats.join(', ')}` : ''}{test.health?.capabilities?.length ? ` · extras: ${test.health.capabilities.join(', ')}` : ''}</>: <>Could not reach <span className="font-mono">{test.musicApi}</span>: {test.error}</>}</div>)}diff --git a/web/src/components/TrackCard.tsx b/web/src/components/TrackCard.tsxindex ce286a1..6bacf48 100644--- a/web/src/components/TrackCard.tsx+++ b/web/src/components/TrackCard.tsx@@ -1,5 +1,5 @@import { useState } from 'react';-import { isInflight, type Track } from '../types';+import { isInflight, isPlayable, type Track } from '../types';import { coverStyle } from '../lib/cover';import { fmtAgo, fmtTime } from '../lib/format';import { api } from '../api';@@ -21,24 +21,25 @@ export function TrackCard({ track: t, groupSize, active, playing, onPlay, onDeleconst [open, setOpen] = useState(false);const inflight = isInflight(t);const done = t.status === 'done';+ const playable = isPlayable(t);const err = t.status === 'error';return (<div className={`group rounded-xl border transition ${active ? 'border-accent/60 bg-ink-800' : 'border-ink-700 bg-ink-900 hover:bg-ink-800'} `}><div className="flex gap-3 p-3"><button- onClick={() => done && onPlay(t)}- disabled={!done}+ onClick={() => playable && onPlay(t)}+ disabled={!playable}className="relative w-16 h-16 shrink-0 rounded-lg overflow-hidden flex items-center justify-center text-white disabled:cursor-default"style={coverStyle(t.id)}- aria-label={done ? (active && playing ? 'Pause' : 'Play') : t.status}+ aria-label={playable ? (active && playing ? 'Pause' : 'Play') : t.status}>- {done && (+ {inflight && <span className={`absolute inset-0 bg-black/40 flex items-center justify-center text-[11px] font-mono tabular-nums ${playable ? 'group-hover:opacity-0 transition' : ''}`}>{Math.round(t.progress * 100)}%</span>}+ {playable && (<span className={`absolute inset-0 flex items-center justify-center bg-black/30 transition ${active ? 'opacity-100' : 'opacity-0 group-hover:opacity-100'}`}>{active && playing ? <Pause width={22} height={22} /> : <Play width={22} height={22} />}</span>)}- {inflight && <span className="absolute inset-0 bg-black/40 flex items-center justify-center text-[11px] font-mono tabular-nums">{Math.round(t.progress * 100)}%</span>}{err && <span className="absolute inset-0 bg-black/50 flex items-center justify-center text-red-300"><Alert width={20} height={20} /></span>}</button>diff --git a/web/src/lib/stage.ts b/web/src/lib/stage.tsindex 6a1dd66..a39d03e 100644--- a/web/src/lib/stage.ts+++ b/web/src/lib/stage.ts@@ -1,21 +1,29 @@-export type PhaseId = 'queued' | 'rendering' | 'download';+export type PhaseId = 'queued' | 'semantic' | 'denoise' | 'download';-export const PHASES: { id: PhaseId; label: string }[] = [+const ALL: { id: PhaseId; label: string }[] = [{ id: 'queued', label: 'Queued' },- { id: 'rendering', label: 'Rendering' },+ { id: 'semantic', label: 'Generating' },+ { id: 'denoise', label: 'Rendering' },{ id: 'download', label: 'Download' },];+/** Estimated renders (blocking upstream) have no observable Generating stage. */+export const phasesFor = (real: boolean) => (real ? ALL : ALL.filter((p) => p.id !== 'semantic'));+export interface StageInfo {phase: PhaseId;label: string;+ /** true when the server streams real progress */+ real: boolean;}-export function parseStage(stage: string, status: 'queued' | 'running'): StageInfo {+export function parseStage(stage: string, status: 'queued' | 'running', renderedSeconds: number | null): StageInfo {const s = (stage || '').toLowerCase().trim();- if (status === 'queued') return { phase: 'queued', label: 'Waiting for the GPU — one render at a time' };- if (s.includes('download')) return { phase: 'download', label: 'Saving render' };- return { phase: 'rendering', label: 'Rendering — progress is estimated (~3× realtime); the server reports none' };+ if (status === 'queued') return { phase: 'queued', label: 'Waiting for the GPU — one render at a time', real: false };+ if (s === 'semantic') return { phase: 'semantic', label: 'Generating — composing the song', real: true };+ if (s === 'denoise') return { phase: 'denoise', label: renderedSeconds ? 'Rendering — you can listen now' : 'Rendering audio', real: true };+ if (s.includes('download')) return { phase: 'download', label: 'Saving render', real: false };+ return { phase: 'denoise', label: 'Rendering — progress is estimated (~3× realtime); the server reports none', real: false };}-export const phaseIndex = (p: PhaseId) => PHASES.findIndex((x) => x.id === p);+export const phaseIndex = (phases: { id: PhaseId }[], p: PhaseId) => phases.findIndex((x) => x.id === p);diff --git a/web/src/types.ts b/web/src/types.tsindex 46d0ec8..777dda8 100644--- a/web/src/types.ts+++ b/web/src/types.ts@@ -16,6 +16,8 @@ export interface Track {stage: string;eta: number | null;elapsed?: number | null;+ /** seconds of audio on disk while a streamed render is running; null when the server can't stream */+ renderedSeconds: number | null;error: string | null;file: string | null;createdAt: string;@@ -29,6 +31,8 @@ export interface Health {queued: number;formats: string[];models?: string[];+ /** optional upstream extras, e.g. "stream" (live progress + play-while-rendering) */+ capabilities?: string[];error?: string;}@@ -67,3 +71,4 @@ export interface SettingsTestResult {}export const isInflight = (t: Track) => t.status === 'queued' || t.status === 'running';+export const isPlayable = (t: Track) => t.status === 'done' || (t.status === 'running' && (t.renderedSeconds ?? 0) > 0);