ReDiverse-MiniMax-H3 / studio.html
akhaliq's picture
akhaliq HF Staff
Full studio UI in the P-H3-Image layout: topbar with Generate/Workflow tabs, video stage with history strip, control panels, status bar, dark/light theme; same @gradio/client@2.7.1 ZeroGPU handshake
ab9662b verified
Raw History Blame Contribute Delete
26.4 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>ReDiverse × MiniMax-H3 Studio</title>
<style>
:root {
--bg: #0b0d12; --panel: #14171f; --panel2: #191d27; --raised: #1f2430;
--border: rgba(60,68,88,0.8); --hairline: rgba(255,255,255,0.08);
--text: #e7eaf0; --muted: #9aa3b2; --dim: #71717a;
--accent: #e0512f; --accent2: #7c5cff; --accent-soft: rgba(224,81,47,0.14);
--lavender: #b9a7ff; --link: #c08bff;
--glow: radial-gradient(ellipse 60% 35% at 50% -5%, rgba(224,81,47,0.14), transparent 55%);
--stage: #080a0e; --thumb-bg: #10131a;
--radius: 10px;
}
body.light {
--bg: #f7f5f8; --panel: #ffffff; --panel2: #f7f5f8; --raised: #f1eef4;
--border: rgba(124,92,255,0.18); --hairline: rgba(24,24,27,0.08);
--text: #18181b; --muted: #71717a; --dim: #a1a1aa;
--accent: #d64a28; --accent2: #6a3fe0; --accent-soft: rgba(224,81,47,0.10);
--lavender: #6a3fe0; --link: #5b21b6;
--glow: radial-gradient(ellipse 60% 35% at 50% -5%, rgba(224,81,47,0.08), transparent 55%);
--stage: #ece9f1; --thumb-bg: #f3eef8;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
body {
font-family: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
background: var(--bg); background-image: var(--glow); background-repeat: no-repeat;
background-attachment: fixed;
color: var(--text); height: 100vh;
display: flex; flex-direction: column; overflow: hidden;
font-size: 13px; -webkit-font-smoothing: antialiased;
}
.topbar {
display: flex; align-items: center; gap: 14px; padding: 8px 16px;
background: var(--panel); border-bottom: 1px solid var(--hairline); flex-shrink: 0;
}
.brand { font-weight: 700; font-size: 0.95rem; white-space: nowrap; letter-spacing: -0.02em; }
.brand .x { color: var(--accent); }
.studio-badge {
font-size: 0.6rem; font-weight: 650; letter-spacing: 0.12em; text-transform: uppercase;
color: var(--lavender); border: 1px solid var(--border); border-radius: 999px;
padding: 2px 8px; margin-left: 10px; background: var(--accent-soft);
}
.mode-tabs { display: flex; gap: 2px; background: var(--panel2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; }
.mode-tabs button {
border: none; border-radius: 7px; padding: 6px 16px; font-weight: 550; font-size: 0.82rem;
background: transparent; color: var(--muted); cursor: pointer; transition: color 0.15s, background 0.15s;
font-family: inherit;
}
.mode-tabs button:hover { color: var(--text); }
.mode-tabs button.active { background: var(--raised); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.45); }
body.light .mode-tabs button.active { box-shadow: 0 1px 3px rgba(88,28,135,0.15); }
.spacer { flex: 1; }
.toplink { color: var(--muted); text-decoration: none; font-size: 0.8rem; font-weight: 500; transition: color 0.15s; white-space: nowrap; }
.toplink:hover { color: var(--text); }
.theme-toggle {
width: 34px; height: 34px; border: 1px solid var(--border); border-radius: 9px;
background: transparent; color: var(--muted); cursor: pointer; flex-shrink: 0;
display: inline-flex; align-items: center; justify-content: center;
transition: color 0.15s, background 0.15s;
}
.theme-toggle:hover { color: var(--text); background: var(--panel2); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .theme-icon-moon { display: none; }
.theme-toggle[data-mode="light"] .theme-icon-sun { display: none; }
.theme-toggle[data-mode="light"] .theme-icon-moon { display: block; }
.main { display: flex; flex: 1; min-height: 0; }
.rail {
width: 52px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center;
gap: 6px; padding: 10px 0; background: var(--panel); border-right: 1px solid var(--hairline);
}
.rail button {
width: 38px; height: 38px; border: 1px solid transparent; border-radius: 8px;
background: transparent; color: var(--muted); cursor: pointer;
display: flex; align-items: center; justify-content: center;
transition: color 0.15s, background 0.15s;
}
.rail button:hover { background: var(--panel2); color: var(--text); }
.viewport { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: auto; position: relative; }
.workflow-view { position: absolute; inset: 0; padding: 12px; }
.workflow-view iframe { width: 100%; height: 100%; border: none; border-radius: 10px; background: var(--stage); }
.doc-grid { flex: 1; min-height: 0; display: flex; gap: 16px; width: 100%; align-items: stretch; justify-content: center; padding: 20px 20px 10px; }
.doc {
flex: 1; min-width: 0; max-width: 900px; display: flex; flex-direction: column;
background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
.doc figcaption {
padding: 8px 12px; font-size: 0.62rem; font-weight: 650; letter-spacing: 0.12em;
color: var(--dim); border-bottom: 1px solid var(--hairline); text-transform: uppercase;
display: flex; align-items: center;
}
.doc .stage {
position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center;
overflow: hidden; background-color: var(--stage);
background-image:
linear-gradient(45deg, var(--panel2) 25%, transparent 25%),
linear-gradient(-45deg, var(--panel2) 25%, transparent 25%),
linear-gradient(45deg, transparent 75%, var(--panel2) 75%),
linear-gradient(-45deg, transparent 75%, var(--panel2) 75%);
background-size: 20px 20px;
background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}
.doc video { max-width: 100%; max-height: 100%; display: block; }
.drop-hint { color: var(--dim); font-size: 0.85rem; text-align: center; padding: 20px; }
.drop-hint b { color: var(--muted); display: block; margin-bottom: 6px; }
.doc-bar {
display: flex; align-items: center; gap: 10px; padding: 6px 12px;
border-top: 1px solid var(--hairline); background: var(--panel);
font-size: 0.72rem; color: var(--muted); flex-shrink: 0;
}
.doc-bar .meta-dim { color: var(--dim); }
.history-strip {
display: flex; gap: 8px; padding: 8px 12px; overflow-x: auto; flex-shrink: 0;
background: var(--panel); border-top: 1px solid var(--hairline); align-items: center;
}
.history-strip .hlabel { font-size: 0.62rem; font-weight: 650; letter-spacing: 0.14em; color: var(--dim); text-transform: uppercase; white-space: nowrap; }
.history-chip {
width: 76px; height: 46px; border-radius: 6px; border: 1px solid var(--border);
overflow: hidden; cursor: pointer; flex-shrink: 0; position: relative; background: var(--thumb-bg);
}
.history-chip:hover { border-color: var(--accent); }
.history-chip video { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.history-chip .hseed {
position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,0.65);
color: #ddd; font-size: 0.52rem; padding: 1px 3px; text-align: center;
}
body.light .history-chip .hseed { background: rgba(255,255,255,0.78); color: #3f3f46; }
.panels {
width: 320px; flex-shrink: 0; display: flex; flex-direction: column; gap: 10px;
padding: 12px; overflow-y: auto; background: var(--panel); border-left: 1px solid var(--hairline);
}
.panel { background: var(--panel2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.panel-title { font-size: 0.62rem; font-weight: 650; letter-spacing: 0.12em; color: var(--dim); text-transform: uppercase; margin-bottom: 10px; cursor: pointer; user-select: none; display: flex; align-items: center; justify-content: space-between; }
.panel .panel-title::after { content: "▾"; font-size: 0.7rem; color: var(--dim); }
.panel.collapsed .panel-title::after { content: "▸"; }
.panel.collapsed .panel-body { display: none; }
.panel label { display: block; font-size: 0.72rem; font-weight: 550; color: var(--muted); margin: 10px 0 4px; }
.panel label:first-of-type { margin-top: 0; }
textarea, input[type="text"], input[type="number"], select {
width: 100%; background: var(--raised); color: var(--text); border: 1px solid var(--border);
border-radius: 7px; padding: 8px 10px; font-family: inherit; font-size: 0.83rem; resize: vertical;
transition: border-color 0.15s, box-shadow 0.15s;
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--accent2); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.code { font-family: ui-monospace, monospace; font-size: 0.72rem; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { display: none; }
.switch .sw {
display: inline-block;
width: 34px; height: 20px; border-radius: 999px; background: var(--raised);
border: 1px solid var(--border); position: relative; flex-shrink: 0; transition: background 0.18s, border-color 0.18s;
}
.switch .sw::after {
content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px;
border-radius: 50%; background: var(--muted); transition: transform 0.18s, background 0.18s;
}
.switch input:checked + .sw { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .sw::after { transform: translateX(14px); background: #fff; }
.switch .sw-label { font-size: 0.75rem; color: var(--muted); }
.range-row { display: flex; align-items: center; gap: 10px; }
input[type="range"] { flex: 1; accent-color: var(--accent2); }
.range-val { min-width: 36px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.75rem; }
.hint { font-size: 0.68rem; color: var(--dim); margin-top: 8px; line-height: 1.4; }
#examples { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.ex-chip {
border: 1px solid var(--border); border-radius: 8px; cursor: pointer; flex-shrink: 0;
background: var(--raised); padding: 7px 10px; text-align: left;
display: flex; align-items: center; justify-content: space-between; gap: 8px;
transition: border-color 0.15s; font-family: inherit; width: 100%;
}
.ex-chip:hover { border-color: var(--accent); }
.ex-chip .ex-label { font-size: 0.75rem; color: var(--text); font-weight: 550; }
.ex-chip .ex-canvas { font-size: 0.62rem; color: var(--lavender); font-family: ui-monospace, monospace; white-space: nowrap; }
#run-btn {
padding: 12px; border: 1px solid rgba(224,81,47,0.7); border-radius: 8px; cursor: pointer;
background: var(--accent); color: white; box-shadow: inset 0 1px rgba(255,255,255,0.2);
font-weight: 600; font-size: 0.9rem; letter-spacing: 0.01em; font-family: inherit;
transition: filter 0.15s, transform 0.05s;
}
#run-btn:hover { filter: brightness(1.12); }
#run-btn:active { transform: translateY(1px); }
#run-btn:disabled { opacity: 0.5; cursor: wait; }
.statusbar {
display: flex; align-items: center; gap: 16px; padding: 7px 16px; flex-shrink: 0;
background: var(--panel); border-top: 1px solid var(--hairline);
font-size: 0.75rem; color: var(--muted);
}
.statusbar .pulse { width: 8px; height: 8px; border-radius: 50%; background: #4fd1a5; }
.statusbar.busy .pulse { background: var(--accent2); animation: pulse 1s infinite alternate; }
@keyframes pulse { from { opacity: 0.4; } to { opacity: 1; } }
.foot-links { display: flex; gap: 12px; align-items: center; }
.foot-links a { color: var(--dim); text-decoration: none; font-size: 0.72rem; font-weight: 500; }
.foot-links a:hover { color: var(--lavender); }
@media (max-width: 860px) {
html, body { height: auto !important; overflow: visible !important; }
body { display: block; }
.topbar { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
.main { display: block; height: auto; min-height: 0; }
.rail { display: none; }
.viewport { display: block; padding: 10px; overflow: visible; }
.workflow-view { position: static; height: 78vh; padding: 0 0 10px; }
.doc-grid { flex-direction: column; align-items: stretch; height: auto; }
.doc { max-width: 100%; width: 100%; }
.doc .stage { min-height: 220px; }
.panels { width: 100%; border-left: none; border-top: 1px solid var(--hairline); padding: 10px 12px; overflow-y: visible; }
.foot-links { display: none; }
.statusbar { position: sticky; bottom: 0; }
}
</style>
</head>
<body>
<header class="topbar">
<div class="brand">ReDiverse <span class="x">×</span> MiniMax-H3<span class="studio-badge">Studio</span></div>
<div class="mode-tabs">
<button id="mode-generate" class="active">Generate</button>
<button id="mode-workflow">Workflow</button>
</div>
<div class="spacer"></div>
<a class="toplink" href="https://huggingface.co/ReDiverse/ReDiverse-MiniMax-H3" target="_blank" rel="noopener">adapter</a>
<a class="toplink" href="https://huggingface.co/MiniMaxAI/MiniMax-H3" target="_blank" rel="noopener">base model</a>
<a class="toplink" href="https://arxiv.org/abs/2611.18550" target="_blank" rel="noopener">paper</a>
<button type="button" class="theme-toggle" id="theme-toggle" data-mode="dark" aria-label="Switch to light mode" title="Switch to light mode">
<svg class="theme-icon-sun" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<circle cx="12" cy="12" r="4"></circle>
<path d="M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"></path>
</svg>
<svg class="theme-icon-moon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="M21 14.5A8.5 8.5 0 1 1 9.5 3 7 7 0 0 0 21 14.5z"></path>
</svg>
</button>
</header>
<div class="main">
<div class="rail">
<button id="tool-clear" title="Clear the stage"><svg width="19" height="19" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg></button>
</div>
<div class="viewport">
<div class="workflow-view" id="workflow-view" hidden>
<iframe src="/workflow/?ui=canvas" title="Workflow canvas"></iframe>
</div>
<div class="doc-grid">
<figure class="doc">
<figcaption>Result <span style="margin-left:auto;text-transform:none;letter-spacing:0;font-weight:500">video + audio — unmute 🔊</span></figcaption>
<div class="stage" id="stage">
<div class="drop-hint" id="result-hint"><b>Nothing yet</b>Write a prompt and hit Generate — your clip lands here</div>
<video id="result-video" controls playsinline loop muted hidden></video>
</div>
<div class="doc-bar">
<span id="result-meta" class="meta-dim">—</span>
<div class="spacer"></div>
<span id="seed-out"></span>
</div>
</figure>
</div>
<div class="history-strip" id="history-strip"><span class="hlabel">History</span></div>
</div>
<aside class="panels">
<section class="panel">
<div class="panel-title">Examples</div>
<div class="panel-body" id="examples"></div>
</section>
<section class="panel">
<div class="panel-title">Prompt</div>
<div class="panel-body">
<textarea id="prompt" rows="6" placeholder="Describe the video…">A hot air balloon drifting over snow-capped mountains at sunrise, cinematic, soft volumetric light, gentle camera push-in.</textarea>
</div>
</section>
<section class="panel">
<div class="panel-title">Canvas &amp; length</div>
<div class="panel-body">
<label for="canvas">Canvas</label>
<select id="canvas"></select>
<div class="row" style="margin-top:10px">
<div><label for="duration">Seconds</label><input type="number" id="duration" value="5" min="3" max="10" step="0.5" /></div>
<div><label for="steps">Steps</label><input type="number" id="steps" value="4" min="4" max="9" step="1" /></div>
<div><label for="seed">Seed</label><input type="number" id="seed" value="42" min="0" /></div>
</div>
<label class="switch" style="margin-top:10px"><input type="checkbox" id="randomize" checked /><span class="sw"></span><span class="sw-label">Randomize seed</span></label>
</div>
</section>
<section class="panel">
<div class="panel-title">ReDiverse-FT</div>
<div class="panel-body">
<label class="switch"><input type="checkbox" id="use-rediverse" checked /><span class="sw"></span><span class="sw-label">Adapter on (first denoising forward)</span></label>
<label for="scale">Scale</label>
<div class="range-row"><input type="range" id="scale" min="0" max="2" step="0.05" value="1" /><span class="range-val" id="scale-val">1.00</span></div>
<div class="hint">The diversity arm lifts VBench DINO diversity from 36.5 (student) to 44.1. Turn it off to run the plain 4-step Turbo student.</div>
</div>
</section>
<button id="run-btn">Generate</button>
</aside>
</div>
<footer class="statusbar" id="statusbar">
<div class="pulse"></div>
<span id="status">Idle</span>
<div class="spacer"></div>
<span class="foot-links">
<a href="/workflow" target="_blank" rel="noopener">Workflow canvas</a>
<a href="https://huggingface.co/spaces/multimodalart/qwen3vl-conditioner" target="_blank" rel="noopener">conditioner Space</a>
</span>
</footer>
<!-- @gradio/client >= 2.2.0 runs the ZeroGPU supports-zerogpu-headers handshake in its Client
constructor and attaches the visitor's x-ip-token (their account tier) to queue requests.
v1 does not — a custom studio page with client v1 sends every GPU call anonymously, which
caps requests at the 2-minute unauthenticated tier. Same pin as PrunaAI/P-H3-Image. -->
<script type="module">
import { client } from "https://cdn.jsdelivr.net/npm/@gradio/client@2.7.1/dist/index.min.js";
const $ = (id) => document.getElementById(id);
const state = { mode: "generate", app: null, history: [] };
const CANVASES = [
"960x544 · 16:9 fast", "1024x576 · 16:9 fast", "1152x640 · 16:9", "1280x704 · 16:9",
"1344x768 · 16:9 full", "544x960 · 9:16 fast", "640x1152 · 9:16", "768x1344 · 9:16 full",
"544x544 · 1:1 fast", "768x768 · 1:1 full", "768x576 · 4:3 fast", "1024x768 · 4:3 full",
"576x768 · 3:4 fast", "768x1024 · 3:4 full", "1152x512 · 21:9 fast", "1536x672 · 21:9 full",
];
const DEFAULT_CANVAS = "1152x640 · 16:9";
const EXAMPLES = [
{ label: "Balloon over mountains", canvas: "1152x640 · 16:9",
prompt: "A hot air balloon drifting over snow-capped mountains at sunrise, cinematic, soft volumetric light, gentle camera push-in." },
{ label: "Neon city walk", canvas: "544x960 · 9:16 fast",
prompt: "Handheld follow shot behind a woman in a long coat walking through a rain-soaked neon city street at night, reflections on wet asphalt, steam rising from vents, shallow depth of field." },
{ label: "Kitten vs yarn", canvas: "960x544 · 16:9 fast",
prompt: "A fluffy orange kitten pounces on a ball of red yarn on a sunlit wooden floor, yarn unraveling as it rolls, warm afternoon light through a window, charming home-video feel." },
{ label: "Claymation chef", canvas: "1024x576 · 16:9 fast",
prompt: "Stop-motion claymation of a tiny chef in a tall white hat stirring a bubbling pot in a cozy clay kitchen, ingredients hopping into the pot on their own, warm practical lighting." },
{ label: "Drone over reef", canvas: "1536x672 · 21:9 full",
prompt: "Aerial drone shot pushing forward over a turquoise coral reef, a sea turtle gliding below the surface, sunlight caustics dancing on the sand, ultra-clear tropical water." },
{ label: "Train at dusk", canvas: "1152x512 · 21:9 fast",
prompt: "A vintage steam train crossing a stone viaduct over a misty valley at dusk, long exposure light trails from the carriages, mountains fading into layered blue haze." },
];
// ---------- theme ----------
const themeBtn = $("theme-toggle");
function applyTheme(mode) {
document.body.classList.toggle("light", mode === "light");
themeBtn.dataset.mode = mode;
const label = mode === "dark" ? "Switch to light mode" : "Switch to dark mode";
themeBtn.setAttribute("aria-label", label);
themeBtn.setAttribute("title", label);
try { localStorage.setItem("rediverse-theme", mode); } catch (e) {}
}
themeBtn.onclick = () => applyTheme(document.body.classList.contains("light") ? "dark" : "light");
(function initTheme() {
let mode = "dark";
try { if (localStorage.getItem("rediverse-theme") === "light") mode = "light"; } catch (e) {}
applyTheme(mode);
})();
// ---------- controls ----------
const canvasSel = $("canvas");
for (const c of CANVASES) {
const o = document.createElement("option");
o.value = o.textContent = c;
if (c === DEFAULT_CANVAS) o.selected = true;
canvasSel.appendChild(o);
}
$("scale").addEventListener("input", () => { $("scale-val").textContent = Number($("scale").value).toFixed(2); });
function setStatus(text, busy = false) {
$("status").textContent = text;
$("statusbar").classList.toggle("busy", busy);
$("run-btn").disabled = busy;
}
function setMode(mode) {
state.mode = mode;
for (const m of ["generate", "workflow"]) $(`mode-${m}`).classList.toggle("active", mode === m);
const workflow = mode === "workflow";
$("workflow-view").hidden = !workflow;
document.querySelector(".doc-grid").style.display = workflow ? "none" : "";
document.querySelector(".rail").style.display = workflow ? "none" : "";
document.querySelector(".panels").style.display = workflow ? "none" : "";
$("history-strip").style.display = workflow ? "none" : "";
}
$("mode-generate").onclick = () => setMode("generate");
$("mode-workflow").onclick = () => setMode("workflow");
$("tool-clear").onclick = () => {
const video = $("result-video");
video.pause();
video.hidden = true;
$("result-hint").hidden = false;
$("result-meta").textContent = "—";
$("seed-out").textContent = "";
state.history = [];
renderHistory();
setStatus("Idle");
};
// ---------- examples ----------
const exRow = $("examples");
EXAMPLES.forEach((ex) => {
const chip = document.createElement("button");
chip.className = "ex-chip";
const label = document.createElement("span");
label.className = "ex-label";
label.textContent = ex.label;
const canvas = document.createElement("span");
canvas.className = "ex-canvas";
canvas.textContent = ex.canvas.split(" · ")[0];
chip.appendChild(label);
chip.appendChild(canvas);
chip.onclick = () => {
$("prompt").value = ex.prompt;
canvasSel.value = ex.canvas;
setStatus("Example loaded — hit Generate");
};
exRow.appendChild(chip);
});
// ---------- history ----------
function renderHistory() {
const strip = $("history-strip");
strip.innerHTML = '<span class="hlabel">History</span>';
state.history.forEach((h) => {
const chipEl = document.createElement("div");
chipEl.className = "history-chip";
chipEl.title = h.prompt || "";
const thumb = document.createElement("video");
thumb.src = h.url;
thumb.muted = true;
thumb.playsInline = true;
thumb.preload = "metadata";
const tag = document.createElement("div");
tag.className = "hseed";
tag.textContent = `seed ${h.seed}`;
chipEl.appendChild(thumb);
chipEl.appendChild(tag);
chipEl.onclick = () => showVideo(h.url, h.meta, h.seed);
strip.appendChild(chipEl);
});
}
function showVideo(url, meta, seed) {
const video = $("result-video");
video.src = url;
video.muted = false;
video.hidden = false;
$("result-hint").hidden = true;
$("result-meta").textContent = meta || "";
$("seed-out").textContent = seed != null ? `seed ${seed}` : "";
}
// ---------- generate ----------
function unwrap(result) {
const data = Array.isArray(result?.data) ? result.data[0] : result?.data;
return data ?? {};
}
$("run-btn").onclick = async () => {
const prompt = $("prompt").value.trim();
if (!prompt) { setStatus("Write a prompt first."); return; }
if (!state.app) state.app = await client(location.origin);
setStatus("Queued — conditioning, then denoising on ZeroGPU…", true);
try {
const result = await state.app.predict("/generate", {
prompt,
canvas: canvasSel.value,
duration: Number($("duration").value),
steps: Number($("steps").value),
seed: Number($("seed").value),
randomize: $("randomize").checked,
rediverse_scale: Number($("scale").value),
use_rediverse: $("use-rediverse").checked,
});
const out = unwrap(result);
if (!out.video || !out.video.url) throw new Error("The API returned no video.");
showVideo(out.video.url, `${out.info || ""} · ${out.wall_seconds}s wall`, out.seed);
state.history.unshift({ url: out.video.url, meta: `${out.info || ""} · ${out.wall_seconds}s wall`, seed: out.seed, prompt });
if (state.history.length > 8) state.history.pop();
renderHistory();
setStatus("Done");
} catch (err) {
setStatus(err?.message || String(err));
}
};
setMode("generate");
</script>
</body>
</html>