Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

feat([issue-703]): add video-model picker to the episode-video stage

[._.]/ Adam Eivy2448b251160a
diff --git a/client/src/components/ModelSelect.jsx b/client/src/components/ModelSelect.jsx
index 28b7f30034..2948f7d510 100644
--- a/client/src/components/ModelSelect.jsx
+++ b/client/src/components/ModelSelect.jsx
@@ -1,8 +1,14 @@
// Active + Legacy optgroup `<select>` shared by media-gen pages (VideoGen,
-// CreativeDirector). Splits `models` into active and `m.deprecated === true`
-// groups; the Legacy optgroup only renders when at least one deprecated model
-// exists. `getLabel` picks the option text — defaults to `m.name`; callers
-// whose model shape may omit `name` pass `(m) => m.name || m.id`.
+// CreativeDirector, the Pipeline episode-video stage). Splits `models` into
+// active and `m.deprecated === true` groups; the Legacy optgroup only renders
+// when at least one deprecated model exists. `getLabel` picks the option
+// text — defaults to `m.name`; callers whose model shape may omit `name` pass
+// `(m) => m.name || m.id`.
+//
+// `emptyOption` (optional) prepends a `value=""` option with that label — use
+// it for "optional model / fall back to the server default" pickers (mirrors
+// ProviderModelSelector's `emptyModelOption`). `ariaLabel` / `title` let an
+// inline picker with no visible <label> stay accessible.
const defaultGetLabel = (m) => m.name;
export default function ModelSelect({
models,
@@ -12,6 +18,9 @@ export default function ModelSelect({
id,
className = 'w-full bg-port-bg border border-port-border rounded-lg px-2 py-2 text-sm text-white focus:outline-none focus:border-port-accent disabled:opacity-50',
disabled = false,
+ emptyOption,
+ ariaLabel,
+ title,
}) {
const active = models.filter((m) => !m.deprecated);
const legacy = models.filter((m) => m.deprecated);
@@ -21,8 +30,11 @@ export default function ModelSelect({
value={value}
onChange={onChange}
disabled={disabled}
+ aria-label={ariaLabel}
+ title={title}
className={className}
>
+ {emptyOption != null && <option value="">{emptyOption}</option>}
{active.map((m) => <option key={m.id} value={m.id}>{getLabel(m)}</option>)}
{legacy.length > 0 && (
<optgroup label="Legacy">
diff --git a/client/src/components/ModelSelect.test.jsx b/client/src/components/ModelSelect.test.jsx
new file mode 100644
index 0000000000..058ac869b5
--- /dev/null
+++ b/client/src/components/ModelSelect.test.jsx
@@ -0,0 +1,51 @@
+import { describe, it, expect, vi } from 'vitest';
+import { fireEvent, render, screen } from '@testing-library/react';
+import ModelSelect from './ModelSelect';
+
+const MODELS = [
+ { id: 'a', name: 'Alpha' },
+ { id: 'b', name: 'Beta' },
+ { id: 'old', name: 'Legacy One', deprecated: true },
+];
+
+function renderSelect(props = {}) {
+ return render(
+ <ModelSelect models={MODELS} value="a" onChange={() => {}} {...props} />
+ );
+}
+
+describe('ModelSelect', () => {
+ it('renders active options and a Legacy optgroup for deprecated models', () => {
+ renderSelect();
+ const options = screen.getAllByRole('option').map((o) => o.textContent);
+ expect(options).toEqual(['Alpha', 'Beta', 'Legacy One']);
+ // The deprecated model lives under a labelled <optgroup>.
+ const optgroup = document.querySelector('optgroup');
+ expect(optgroup?.label).toBe('Legacy');
+ });
+
+ it('omits the Legacy optgroup when no model is deprecated', () => {
+ renderSelect({ models: [{ id: 'a', name: 'Alpha' }] });
+ expect(document.querySelector('optgroup')).toBeNull();
+ });
+
+ it('prepends an empty option with value "" when emptyOption is set', () => {
+ renderSelect({ emptyOption: 'Default model', value: '' });
+ const first = screen.getByRole('combobox').querySelector('option');
+ expect(first.value).toBe('');
+ expect(first.textContent).toBe('Default model');
+ });
+
+ it('falls back through getLabel when a model omits name', () => {
+ renderSelect({ models: [{ id: 'no-name' }], value: 'no-name', getLabel: (m) => m.name || m.id });
+ expect(screen.getByRole('option').textContent).toBe('no-name');
+ });
+
+ it('applies ariaLabel and forwards change events', () => {
+ const onChange = vi.fn();
+ renderSelect({ ariaLabel: 'Video model', onChange });
+ const select = screen.getByLabelText('Video model');
+ fireEvent.change(select, { target: { value: 'b' } });
+ expect(onChange).toHaveBeenCalledTimes(1);
+ });
+});
diff --git a/client/src/components/pipeline/stages/EpisodeVideoStage.jsx b/client/src/components/pipeline/stages/EpisodeVideoStage.jsx
index 0bf4735f35..e861e6f8ad 100644
--- a/client/src/components/pipeline/stages/EpisodeVideoStage.jsx
+++ b/client/src/components/pipeline/stages/EpisodeVideoStage.jsx
@@ -3,10 +3,11 @@ import { Link } from 'react-router-dom';
import { Film, ExternalLink, Loader2, Sparkles, AlertCircle, CheckCircle2 } from 'lucide-react';
import toast from '../../ui/Toast';
import Banner from '../../ui/Banner';
-import { generatePipelineVisualImage } from '../../../services/api';
+import { generatePipelineVisualImage, listVideoModels } from '../../../services/api';
import { getCreativeDirectorProject } from '../../../services/apiCreativeDirector';
import { getSceneStatusBadge, PROJECT_STATUS_LABEL } from '../../creative-director/sceneStatus';
import ScenePreview from '../../creative-director/ScenePreview';
+import ModelSelect from '../../ModelSelect';
import { useAsyncAction } from '../../../hooks/useAsyncAction';
import { useAutoRefetch } from '../../../hooks/useAutoRefetch';
@@ -33,6 +34,54 @@ const STATUS_LABEL = {
paused: 'Paused',
};
+// Shared inline render-settings controls — aspect ratio, quality, and (when
+// the video-model list loaded) the video model. Rendered identically in the
+// initial-start and restart-confirm toolbars so the two paths can't drift.
+const SELECT_CLS = 'bg-port-bg border border-port-border rounded px-2 py-1 text-xs text-gray-300';
+function RenderControls({ aspectRatio, setAspectRatio, quality, setQuality, modelId, setModelId, videoModels, disabled }) {
+ return (
+ <>
+ <select
+ value={aspectRatio}
+ onChange={(e) => setAspectRatio(e.target.value)}
+ disabled={disabled}
+ aria-label="Aspect ratio"
+ title="Aspect ratio for the rendered scenes"
+ className={SELECT_CLS}
+ >
+ <option value="16:9">16:9</option>
+ <option value="9:16">9:16</option>
+ <option value="1:1">1:1</option>
+ </select>
+ <select
+ value={quality}
+ onChange={(e) => setQuality(e.target.value)}
+ disabled={disabled}
+ aria-label="Render quality"
+ title="Render quality — higher = slower + more GPU time"
+ className={SELECT_CLS}
+ >
+ <option value="draft">draft</option>
+ <option value="standard">standard</option>
+ <option value="high">high</option>
+ </select>
+ {videoModels.length > 0 && (
+ <ModelSelect
+ models={videoModels}
+ value={modelId}
+ onChange={(e) => setModelId(e.target.value)}
+ getLabel={(m) => m.name || m.id}
+ disabled={disabled}
+ emptyOption="Default model"
+ ariaLabel="Video model"
+ title="Video model used to render each scene (Default follows the server setting)"
+ className={`${SELECT_CLS} max-w-[180px]`}
+ />
+ )}
+ </>
+ );
+}
+
export default function EpisodeVideoStage({ issue, series, onStageUpdate }) {
const stage = issue.stages?.episodeVideo || {};
const cdProjectId = stage.cdProjectId || null;
@@ -45,6 +94,21 @@ export default function EpisodeVideoStage({ issue, series, onStageUpdate }) {
// for an unstarted episodeVideo stage.
const [aspectRatio, setAspectRatio] = useState(stage.aspectRatio || '16:9');
const [quality, setQuality] = useState(stage.quality || 'standard');
+ // '' = use the server/settings default video model. A persisted concrete id
+ // (set after a render starts) restores the user's prior choice on reload.
+ const [modelId, setModelId] = useState(stage.modelId || '');
+
+ // Load the video-model list once for the picker. Secondary control — a fetch
+ // failure just hides the model select (the user still gets the server
+ // default), so swallow the error rather than toasting.
+ const [videoModels, setVideoModels] = useState([]);
+ useEffect(() => {
+ let cancelled = false;
+ listVideoModels({ silent: true })
+ .then((models) => { if (!cancelled) setVideoModels(Array.isArray(models) ? models : []); })
+ .catch(() => { if (!cancelled) setVideoModels([]); });
+ return () => { cancelled = true; };
+ }, []);
// Poll while a project id is bound. Pauses on hidden tab via the hook's
// visibility short-circuit; identical snapshots dedup via the compare option
@@ -88,6 +152,9 @@ export default function EpisodeVideoStage({ issue, series, onStageUpdate }) {
const [runSubmit, submitting] = useAsyncAction(
async ({ force }) => {
const payload = { aspectRatio, quality };
+ // Omit modelId on the "Default model" sentinel so the server resolves
+ // its own default (videoGen.defaultModelId → registry default).
+ if (modelId) payload.modelId = modelId;
if (force) payload.force = true;
return generatePipelineVisualImage(issue.id, 'episodeVideo', payload).catch((err) => {
// Re-throw with a force-aware fallback so useAsyncAction's toaster
@@ -123,9 +190,12 @@ export default function EpisodeVideoStage({ issue, series, onStageUpdate }) {
cdProjectId: result.cdProjectId,
// Mirror the server's persisted render settings on the client-side
// issue model so a same-session navigate-away-and-back doesn't reset
- // the restart pickers to defaults before a full refetch lands.
+ // the restart pickers to defaults before a full refetch lands. modelId
+ // mirrors the request value ('' when the user left it on Default);
+ // a full refetch later replaces it with the server-resolved concrete id.
aspectRatio,
quality,
+ modelId: modelId || null,
});
};
@@ -154,30 +224,12 @@ export default function EpisodeVideoStage({ issue, series, onStageUpdate }) {
</div>
{!cdProjectId ? (
<div className="flex items-center gap-2 flex-wrap">
- <select
- value={aspectRatio}
- onChange={(e) => setAspectRatio(e.target.value)}
- disabled={submitting}
- aria-label="Aspect ratio"
- title="Aspect ratio for the rendered scenes"
- className="bg-port-bg border border-port-border rounded px-2 py-1 text-xs text-gray-300"
- >
- <option value="16:9">16:9</option>
- <option value="9:16">9:16</option>
- <option value="1:1">1:1</option>
- </select>
- <select
- value={quality}
- onChange={(e) => setQuality(e.target.value)}
- disabled={submitting}
- aria-label="Render quality"
- title="Render quality — higher = slower + more GPU time"
- className="bg-port-bg border border-port-border rounded px-2 py-1 text-xs text-gray-300"
- >
- <option value="draft">draft</option>
- <option value="standard">standard</option>
- <option value="high">high</option>
- </select>
+ <RenderControls
+ aspectRatio={aspectRatio} setAspectRatio={setAspectRatio}
+ quality={quality} setQuality={setQuality}
+ modelId={modelId} setModelId={setModelId}
+ videoModels={videoModels} disabled={submitting}
+ />
<button
type="button"
onClick={() => submit({ force: false })}
@@ -192,28 +244,12 @@ export default function EpisodeVideoStage({ issue, series, onStageUpdate }) {
) : confirmRestart ? (
<div className="flex items-center gap-2 flex-wrap">
<span className="text-xs text-port-warning">Start a new CD project?</span>
- <select
- value={aspectRatio}
- onChange={(e) => setAspectRatio(e.target.value)}
- disabled={submitting}
- aria-label="Aspect ratio"
- className="bg-port-bg border border-port-border rounded px-2 py-1 text-xs text-gray-300"
- >
- <option value="16:9">16:9</option>
- <option value="9:16">9:16</option>
- <option value="1:1">1:1</option>
- </select>
- <select
- value={quality}
- onChange={(e) => setQuality(e.target.value)}
- disabled={submitting}
- aria-label="Render quality"
- className="bg-port-bg border border-port-border rounded px-2 py-1 text-xs text-gray-300"
- >
- <option value="draft">draft</option>
- <option value="standard">standard</option>
- <option value="high">high</option>
- </select>
+ <RenderControls
+ aspectRatio={aspectRatio} setAspectRatio={setAspectRatio}
+ quality={quality} setQuality={setQuality}
+ modelId={modelId} setModelId={setModelId}
+ videoModels={videoModels} disabled={submitting}
+ />
<button
type="button"
onClick={() => submit({ force: true })}
diff --git a/client/src/services/apiImageVideo.js b/client/src/services/apiImageVideo.js
index c8b96ff466..8917ece067 100644
--- a/client/src/services/apiImageVideo.js
+++ b/client/src/services/apiImageVideo.js
@@ -38,7 +38,7 @@ export const clearHfToken = () => request('/image-gen/setup/hf-token', { method:
// Video gen
export const getVideoGenStatus = () => request('/video-gen/status');
-export const listVideoModels = () => request('/video-gen/models');
+export const listVideoModels = (options) => request('/video-gen/models', options);
// `{ models: [...], textEncoder: { repo, cached, sizeBytes } }`. Same shape
// contract as the image variant + a text-encoder block since the active
// encoder is a separate multi-GB pull.
diff --git a/server/services/pipeline/episodeVideo.js b/server/services/pipeline/episodeVideo.js
index 8caa806600..6a8a497785 100644
--- a/server/services/pipeline/episodeVideo.js
+++ b/server/services/pipeline/episodeVideo.js
@@ -182,9 +182,12 @@ export async function startEpisodeVideoForIssue(issueId, options = {}) {
cdProjectId: project.id,
// Persist the chosen render settings so a page reload restores the
// pickers — otherwise restart from a fresh tab would silently fall back
- // to defaults that the user can't see or adjust.
+ // to defaults that the user can't see or adjust. modelId is the resolved
+ // concrete id (a user "Default model" pick lands here as the actual id),
+ // mirroring how aspectRatio/quality persist their resolved defaults.
aspectRatio,
quality,
+ modelId,
output: '',
errorMessage: '',
});
diff --git a/server/services/pipeline/episodeVideo.test.js b/server/services/pipeline/episodeVideo.test.js
index 83b4b705d7..614662c98e 100644
--- a/server/services/pipeline/episodeVideo.test.js
+++ b/server/services/pipeline/episodeVideo.test.js
@@ -280,6 +280,27 @@ describe('pipeline episodeVideo helper', () => {
expect(refreshed.stages.episodeVideo.quality).toBe('high');
});
+ it('startEpisodeVideoForIssue forwards an explicit modelId to the CD project + persists it on the stage', async () => {
+ const { issue } = await seedSeriesAndIssue({
+ scenes: [{ description: 'foo' }],
+ });
+ await svc.startEpisodeVideoForIssue(issue.id, { modelId: 'ltx2_unified' });
+ expect(cdCreated[0].modelId).toBe('ltx2_unified');
+ const refreshed = await issuesSvc.getIssue(issue.id);
+ expect(refreshed.stages.episodeVideo.modelId).toBe('ltx2_unified');
+ });
+
+ it('startEpisodeVideoForIssue falls back to the default video model when modelId is omitted', async () => {
+ const { issue } = await seedSeriesAndIssue({
+ scenes: [{ description: 'foo' }],
+ });
+ await svc.startEpisodeVideoForIssue(issue.id);
+ // mediaModels mock resolves the default to 'ltx23_distilled_q4'.
+ expect(cdCreated[0].modelId).toBe('ltx23_distilled_q4');
+ const refreshed = await issuesSvc.getIssue(issue.id);
+ expect(refreshed.stages.episodeVideo.modelId).toBe('ltx23_distilled_q4');
+ });
+
it('startEpisodeVideoForIssue reuses an existing cdProjectId by default', async () => {
const { issue } = await seedSeriesAndIssue({
scenes: [{ description: 'one' }, { description: 'two' }, { description: '' }],
diff --git a/server/services/pipeline/issues.js b/server/services/pipeline/issues.js
index df64b83d77..30a97bde6e 100644
--- a/server/services/pipeline/issues.js
+++ b/server/services/pipeline/issues.js
@@ -361,6 +361,13 @@ const sanitizeVisualStage = (raw, stageId = null) => {
videoPath: isStr(raw?.videoPath) && raw.videoPath ? raw.videoPath : null,
aspectRatio: ASPECT_RATIO_VALUES.has(raw?.aspectRatio) ? raw.aspectRatio : null,
quality: QUALITY_VALUES.has(raw?.quality) ? raw.quality : null,
+ // Video model id — only meaningful on episodeVideo (it picks the per-scene
+ // render engine). Dropped on comicPages/storyboards so the contract is
+ // explicit, but kept when stageId is omitted (legacy load-time sanitize
+ // has no per-stage context). `null` = use the server/settings default.
+ modelId: (stageId === null || stageId === 'episodeVideo') && isStr(raw?.modelId) && raw.modelId
+ ? raw.modelId.slice(0, 64)
+ : null,
// genConfig is read by comicPages/storyboards; pass-through is a no-op on
// episodeVideo, which never looks at it.
genConfig: sanitizeGenConfig(raw?.genConfig),