Skip to content

Suno-style web UI for a self-hosted MiniMax-Music3 inference server

feat: compatibility mode switch in Settings — treat any server as stock sgl-omni

Adam Benhassenedfcadc28762
diff --git a/README.md b/README.md
index 82f41bd..b7931aa 100644
--- a/README.md
+++ b/README.md
@@ -29,7 +29,7 @@
- **Library** — every finished render is saved into `data/tracks/` with its metadata (prompt, lyrics, seed, format). Cards show duration, seed and how long the render took. Search, download, delete, "reuse settings".
- **Player** — sticky bottom bar with waveform (decoded client-side), seek, prev/next, keyboard space to play/pause.
- **Health pill** — offline / loading model / idle (· live progress) / rendering · N queued (probes `GET /v1/models` and the optional `GET /health`).
-- **Settings page** — point the app at your inference server (URL + optional API key) from the UI, with a "Test connection" button. Environment variables, when set, take precedence and lock those fields.
+- **Settings page** — point the app at your inference server (URL + optional API key) from the UI, with a "Test connection" button. Environment variables, when set, take precedence and lock those fields. A *Compatibility mode* debug switch makes the UI treat any server as stock `sgl-omni` (no `/health`, no streaming) to check the plain contract still works.
- Responsive down to phone width. No external services; everything runs on your machine or tailnet.
## Architecture
@@ -126,8 +126,8 @@ FAKE_PORT=7998 npm run fake -w server # listen elsewhere (default 7999)
| `GET` | `/api/templates` | Saved templates |
| `POST` | `/api/templates` | `{name, prompt, lyrics?, duration?, format?}` — same name overwrites |
| `DELETE` | `/api/templates/:id` | Remove a template |
-| `GET` | `/api/settings` | Effective inference URL, whether a key is set, and which fields are env-locked (the key itself is never returned) |
-| `PUT` | `/api/settings` | `{musicApi?, apiKey?}` — `apiKey: ""` clears it; env-locked fields are rejected |
+| `GET` | `/api/settings` | Effective inference URL, whether a key is set, `compat` flag, and which fields are env-locked (the key itself is never returned) |
+| `PUT` | `/api/settings` | `{musicApi?, apiKey?, compat?}` — `apiKey: ""` clears it; env-locked fields are rejected; `compat: true` skips `/health` and never streams |
| `POST` | `/api/settings/test` | Probe a candidate `{musicApi?, apiKey?}` against `/v1/models` without saving |
## Upstream API
diff --git a/server/src/app.ts b/server/src/app.ts
index e3a5be3..a2a25a6 100644
--- a/server/src/app.ts
+++ b/server/src/app.ts
@@ -141,10 +141,10 @@ export function createApp(deps: AppDeps) {
app.put('/api/settings', async (req, res, next) => {
try {
const b = (req.body ?? {}) as Record<string, unknown>;
- await settings.update({ musicApi: b.musicApi, apiKey: b.apiKey });
+ await settings.update({ musicApi: b.musicApi, apiKey: b.apiKey, compat: b.compat });
const e = settings.effective();
- upstream.configure(e.musicApi, e.apiKey);
- log(`upstream reconfigured → ${e.musicApi}${e.apiKey ? ' (bearer set)' : ''}`);
+ upstream.configure(e.musicApi, e.apiKey, e.compat);
+ log(`upstream reconfigured → ${e.musicApi}${e.apiKey ? ' (bearer set)' : ''}${e.compat ? ' (compat mode)' : ''}`);
res.json(settings.publicView());
} catch (err) {
next(err);
@@ -164,7 +164,7 @@ export function createApp(deps: AppDeps) {
return res.status(400).json({ ok: false, error: (err as Error).message });
}
try {
- const h = await new UpstreamClient(url, key).health();
+ const h = await new UpstreamClient(url, key, e.compat).health();
res.json({ ok: true, musicApi: url, health: { ...h, formats: FORMATS } });
} catch (err) {
res.json({ ok: false, musicApi: url, error: (err as Error).message });
diff --git a/server/src/index.ts b/server/src/index.ts
index 16f5123..bbe6476 100644
--- a/server/src/index.ts
+++ b/server/src/index.ts
@@ -18,7 +18,7 @@ const settings = new SettingsStore(path.join(config.dataDir, 'settings.json'), {
await settings.load();
const effective = settings.effective();
-const upstream = new UpstreamClient(effective.musicApi, effective.apiKey);
+const upstream = new UpstreamClient(effective.musicApi, effective.apiKey, effective.compat);
const queue = new RenderQueue(library, upstream, tracksDir);
const recovered = await queue.recover();
diff --git a/server/src/settings.ts b/server/src/settings.ts
index e1cf46f..c699603 100644
--- a/server/src/settings.ts
+++ b/server/src/settings.ts
@@ -5,6 +5,8 @@ import { ValidationError } from './validate.js';
export interface StoredSettings {
musicApi: string | null;
apiKey: string | null;
+ /** debug/testing: behave as if the upstream were stock sgl-omni — skip /health, never stream */
+ compat: boolean;
}
export interface EnvOverrides {
@@ -15,6 +17,7 @@ export interface EnvOverrides {
export interface EffectiveUpstream {
musicApi: string;
apiKey: string | null;
+ compat: boolean;
/** where each value came from */
source: { musicApi: 'env' | 'settings' | 'default'; apiKey: 'env' | 'settings' | 'none' };
}
@@ -36,7 +39,7 @@ export function normalizeMusicApi(v: unknown): string {
/** Persists user-editable upstream settings; env vars always win over stored values. */
export class SettingsStore {
- private stored: StoredSettings = { musicApi: null, apiKey: null };
+ private stored: StoredSettings = { musicApi: null, apiKey: null, compat: false };
private writing: Promise<void> = Promise.resolve();
constructor(private readonly file: string, private readonly env: EnvOverrides) {}
@@ -47,6 +50,7 @@ export class SettingsStore {
this.stored = {
musicApi: typeof raw.musicApi === 'string' && raw.musicApi ? raw.musicApi : null,
apiKey: typeof raw.apiKey === 'string' && raw.apiKey ? raw.apiKey : null,
+ compat: raw.compat === true,
};
} catch (err) {
if ((err as NodeJS.ErrnoException).code !== 'ENOENT') throw err;
@@ -59,6 +63,7 @@ export class SettingsStore {
return {
musicApi,
apiKey,
+ compat: this.stored.compat,
source: {
musicApi: this.env.musicApi ? 'env' : this.stored.musicApi ? 'settings' : 'default',
apiKey: this.env.apiKey ? 'env' : this.stored.apiKey ? 'settings' : 'none',
@@ -72,13 +77,14 @@ export class SettingsStore {
return {
musicApi: e.musicApi,
apiKeySet: !!e.apiKey,
+ compat: e.compat,
source: e.source,
locked: { musicApi: this.env.musicApi !== null, apiKey: this.env.apiKey !== null },
};
}
/** Update stored values. `apiKey: ""` clears it; `undefined` leaves it alone. */
- async update(patch: { musicApi?: unknown; apiKey?: unknown }): Promise<void> {
+ async update(patch: { musicApi?: unknown; apiKey?: unknown; compat?: unknown }): Promise<void> {
if (patch.musicApi !== undefined) {
if (this.env.musicApi !== null) throw new ValidationError('MUSIC_API is set in the environment and cannot be changed here');
this.stored.musicApi = normalizeMusicApi(patch.musicApi);
@@ -88,6 +94,10 @@ export class SettingsStore {
if (typeof patch.apiKey !== 'string') throw new ValidationError('apiKey must be a string');
this.stored.apiKey = patch.apiKey.trim() || null;
}
+ if (patch.compat !== undefined) {
+ if (typeof patch.compat !== 'boolean') throw new ValidationError('compat must be a boolean');
+ this.stored.compat = patch.compat;
+ }
await this.persist();
}
diff --git a/server/src/upstream.ts b/server/src/upstream.ts
index f7e8cb6..64d877e 100644
--- a/server/src/upstream.ts
+++ b/server/src/upstream.ts
@@ -54,11 +54,13 @@ export class UpstreamClient {
private capabilities: string[] = [];
private probed = false;
- constructor(private baseUrl: string, private apiKey: string | null = null) {}
+ /** `compat`: pretend the server is stock sgl-omni — skip GET /health, so no loading state and no extras. */
+ constructor(private baseUrl: string, private apiKey: string | null = null, private compat = false) {}
- configure(baseUrl: string, apiKey: string | null): void {
+ configure(baseUrl: string, apiKey: string | null, compat = false): void {
this.baseUrl = baseUrl.replace(/\/+$/, '');
this.apiKey = apiKey;
+ this.compat = compat;
this.modelId = null;
this.capabilities = [];
this.probed = false;
@@ -110,7 +112,7 @@ export class UpstreamClient {
models = (json.data ?? []).map((m) => m.id ?? '').filter(Boolean);
if (models.length) this.modelId = models[0];
}
- const h = await this.probeHealth();
+ const h = this.compat ? { ready: true, capabilities: [] } : await this.probeHealth();
this.capabilities = h.capabilities;
this.probed = true;
return { ready: h.ready, models, capabilities: h.capabilities };
diff --git a/server/test/app.test.ts b/server/test/app.test.ts
index 6b15d09..0d7e407 100644
--- a/server/test/app.test.ts
+++ b/server/test/app.test.ts
@@ -213,7 +213,7 @@ describe('app', () => {
const put = await request(app).put('/api/settings').send({ musicApi: `${fake!.url}/`, apiKey: 'sekrit' });
expect(put.body).toMatchObject({ musicApi: fake!.url, apiKeySet: true, source: { musicApi: 'settings', apiKey: 'settings' } });
expect(upstream.url).toBe(fake!.url);
- expect(JSON.parse(await fs.readFile(path.join(dir, 'settings.json'), 'utf8'))).toEqual({ musicApi: fake!.url, apiKey: 'sekrit' });
+ expect(JSON.parse(await fs.readFile(path.join(dir, 'settings.json'), 'utf8'))).toEqual({ musicApi: fake!.url, apiKey: 'sekrit', compat: false });
await request(app).get('/api/health');
expect(fake!.requests.at(-1)?.auth).toBe('Bearer sekrit');
expect((await request(app).put('/api/settings').send({ apiKey: '' })).body.apiKeySet).toBe(false);
@@ -275,6 +275,22 @@ describe('app', () => {
expect(lib.get(res.body[0].id)?.renderedSeconds).toBeNull();
});
+ it('compat mode ignores /health and never streams, even when the server advertises it', async () => {
+ const { app, lib } = await setup({ stream: { windows: 3, windowMs: 40 } }, null, { musicApi: null, apiKey: null });
+ await request(app).put('/api/settings').send({ musicApi: fake!.url });
+ expect((await request(app).get('/api/health')).body).toMatchObject({ ready: true, capabilities: ['stream'] });
+ const put = await request(app).put('/api/settings').send({ compat: true });
+ expect(put.status).toBe(200);
+ expect(put.body.compat).toBe(true);
+ fake!.requests.length = 0;
+ expect((await request(app).get('/api/health')).body).toMatchObject({ ready: true, capabilities: [] });
+ const res = await request(app).post('/api/generate').send({ prompt: 'x', stream: true });
+ await until(() => lib.get(res.body[0].id)?.status === 'done');
+ expect(fake!.requests.map((r) => r.path)).not.toContain('/health');
+ expect(fake!.requests.find((r) => r.path === '/v1/audio/speech')?.body).toMatchObject({ stream: false });
+ expect((await request(app).get('/api/settings')).body.compat).toBe(true);
+ });
+
it('cancel mid-stream aborts upstream and marks cancelled', async () => {
const { app, lib } = await setup({ stream: { windows: 50, windowMs: 40 } });
const res = await request(app).post('/api/generate').send({ prompt: 'x', stream: true });
diff --git a/web/src/api.ts b/web/src/api.ts
index 76cae41..3123764 100644
--- a/web/src/api.ts
+++ b/web/src/api.ts
@@ -23,7 +23,7 @@ export const api = {
fetch('/api/templates', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(t) }).then((r) => json<Template>(r)),
deleteTemplate: (id: string) => fetch(`/api/templates/${id}`, { method: 'DELETE' }).then((r) => json<{ ok: true }>(r)),
settings: () => fetch('/api/settings').then((r) => json<Settings>(r)),
- saveSettings: (patch: { musicApi?: string; apiKey?: string }) =>
+ saveSettings: (patch: { musicApi?: string; apiKey?: string; compat?: boolean }) =>
fetch('/api/settings', { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(patch) }).then((r) => json<Settings>(r)),
testSettings: (candidate: { musicApi?: string; apiKey?: string }) =>
fetch('/api/settings/test', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(candidate) }).then((r) => json<SettingsTestResult>(r)),
diff --git a/web/src/components/SettingsPanel.tsx b/web/src/components/SettingsPanel.tsx
index 78fe05c..82e98d2 100644
--- a/web/src/components/SettingsPanel.tsx
+++ b/web/src/components/SettingsPanel.tsx
@@ -11,6 +11,7 @@ export function SettingsPanel({ onSaved }: { onSaved: () => void }) {
const [busy, setBusy] = useState<'save' | 'test' | null>(null);
const [test, setTest] = useState<SettingsTestResult | null>(null);
const [msg, setMsg] = useState<{ kind: 'ok' | 'err'; text: string } | null>(null);
+ const [compatMsg, setCompatMsg] = useState<{ kind: 'ok' | 'err'; text: string } | null>(null);
const load = async () => {
const s = await api.settings();
@@ -59,6 +60,20 @@ export function SettingsPanel({ onSaved }: { onSaved: () => void }) {
}
};
+ const toggleCompat = async () => {
+ setBusy('save'); setCompatMsg(null);
+ try {
+ const s = await api.saveSettings({ compat: !settings.compat });
+ setSettings(s); setTest(null);
+ setCompatMsg({ kind: 'ok', text: s.compat ? 'Compatibility mode on — the server is treated as stock sgl-omni.' : 'Compatibility mode off — server extras are used again when advertised.' });
+ onSaved();
+ } catch (e) {
+ setCompatMsg({ kind: 'err', text: (e as Error).message });
+ } finally {
+ setBusy(null);
+ }
+ };
+
const sourceLabel = (s: string) => ({ env: 'from environment', settings: 'saved in settings', default: 'default', none: 'not set' }[s] ?? s);
return (
@@ -134,6 +149,18 @@ export function SettingsPanel({ onSaved }: { onSaved: () => void }) {
{msg && <div className={`text-xs ${msg.kind === 'ok' ? 'text-emerald-300' : 'text-red-400'}`}>{msg.text}</div>}
</section>
+ <section className="space-y-3">
+ <h2 className="text-sm font-semibold">Debugging</h2>
+ <label className="flex items-start gap-3 text-xs text-zinc-400 cursor-pointer">
+ <input type="checkbox" className="mt-0.5 accent-accent" checked={settings.compat} disabled={busy !== null} onChange={() => void toggleCompat()} />
+ <span>
+ <span className="text-zinc-200">Compatibility mode (stock sgl-omni)</span><br />
+ Ignore everything beyond the official <code className="text-zinc-300">POST /v1/audio/speech</code> contract: <code className="text-zinc-300">/health</code> is not probed, so no “Loading model” state, no live progress and no play-while-rendering — even against the bundled inference server. Useful to check that the UI still works with MiniMax's own server.
+ </span>
+ </label>
+ {compatMsg && <div className={`text-xs ${compatMsg.kind === 'ok' ? 'text-emerald-300' : 'text-red-400'}`}>{compatMsg.text}</div>}
+ </section>
+
<section className="space-y-2">
<h2 className="text-sm font-semibold">Precedence</h2>
<ol className="text-xs text-zinc-400 list-decimal list-inside space-y-1">
diff --git a/web/src/types.ts b/web/src/types.ts
index 9cae868..562e41b 100644
--- a/web/src/types.ts
+++ b/web/src/types.ts
@@ -62,6 +62,8 @@ export interface Template {
export interface Settings {
musicApi: string;
apiKeySet: boolean;
+ /** debug/testing: treat the server as stock sgl-omni (no /health, no streaming) */
+ compat: boolean;
source: { musicApi: 'env' | 'settings' | 'default'; apiKey: 'env' | 'settings' | 'none' };
locked: { musicApi: boolean; apiKey: boolean };
}