From 1ce2c2a535ee8e9b6a95f122307affa1b3d4cbe1 Mon Sep 17 00:00:00 2001 From: Benjiyaya Date: Sat, 29 Aug 2026 21:43:05 +0800 Subject: [PATCH] feat: modal-based video source picker with project clip grid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The native select was too cramped for a project with many clips. Replace it with a wide modal (Auto / Upload file / clip grid with thumbnails). Clip options now cover any scene in the timeline, not just earlier ones, and uploads wire through a hidden input. Also fix the Choose-Video modal rendering blank under Clips/Uploads tabs: duplicate asset paths crashed Svelte's keyed each mid-render — dedupe by path and clamp the active tab when a tile's kind changes. --- .../src/lib/components/QueueStage.svelte | 46 ++- .../components/omni/AssetPickerModal.svelte | 10 + .../src/lib/components/omni/MediaTile.svelte | 18 +- .../src/lib/components/ui/Modal.svelte | 5 +- .../components/video/ClipSourceModal.svelte | 302 ++++++++++++++++++ .../video/VideoEditWorkspace.svelte | 93 ++++-- 6 files changed, 440 insertions(+), 34 deletions(-) create mode 100644 calliope-web/src/lib/components/video/ClipSourceModal.svelte diff --git a/calliope-web/src/lib/components/QueueStage.svelte b/calliope-web/src/lib/components/QueueStage.svelte index f7593e9a..ec536937 100644 --- a/calliope-web/src/lib/components/QueueStage.svelte +++ b/calliope-web/src/lib/components/QueueStage.svelte @@ -13,6 +13,7 @@ type Workflow, } from '$lib/api'; import { compactInputValues } from '$lib/comfy/promptInput'; + import { createUploadManager } from '$lib/comfy/useUpload.svelte'; import { normalizeInputRole } from '$lib/comfy/parser'; import type { ComfyDynamicInput } from '$lib/comfy/types'; import type { AssetOption } from '$lib/assetPicker'; @@ -40,6 +41,21 @@ let lastFormScene = $state(null); // Clip source for continue scenes, keyed per scene: 'auto' | 'upload' | scene id. let clipSource = $state>({}); + // Hidden file input backing "Upload file" in the video source modal. + let videoFileInput = $state(null); + const videoUploadMgr = createUploadManager(); + + async function onVideoFileChosen(e: Event) { + const el = e.currentTarget as HTMLInputElement; + const file = el.files?.[0]; + el.value = ''; + const node = videoInputNodeFor(selected ? workflowFor(selected) : undefined); + if (!file || !selected || !node) return; + const path = await videoUploadMgr.uploadSafe(node.nodeId, file); + if (path) { + formValues = { ...formValues, [node.nodeId]: path }; + } + } // Per-scene input cache — switching scenes no longer wipes the form. const formCache = new Map>(); @@ -183,12 +199,12 @@ return wf?.input_schema?.find((inp) => normalizeInputRole(inp.role ?? null) === 'video'); } - // Timeline source options for a continue scene: earlier scenes that already + // Timeline source options for a continue scene: any other scene that has // rendered a clip, ordered by timeline position. function timelineClipOptions(current: Scene | null): Scene[] { if (!current) return []; return scenes - .filter((s) => s.id !== current.id && s.order_index < current.order_index && s.video_path) + .filter((s) => s.id !== current.id && s.video_path) .sort((a, b) => a.order_index - b.order_index); } @@ -546,6 +562,13 @@ {@const selSource = clipSource[selected.id] ?? 'auto'} {@const selSourceValid = selSource === 'auto' || selSource === 'upload' || selClips.some((s) => String(s.id) === selSource)} {@const selBlocked = selChain && !selHasVideoInput} + ({ id: String(s.id), label: `#${s.order_index} ${s.heading || 'Scene'}` })), + options: selClips.map((s) => ({ + id: String(s.id), + label: `#${s.order_index} ${s.heading || 'Scene'}`, + path: s.video_path ?? undefined, + })), }} onClipSourceChange={(val) => { if (val === 'auto') { @@ -591,6 +618,7 @@ } } }} + onClipSourceUpload={() => videoFileInput?.click()} onSelect={selectScene} onStep={step} onWorkflowChange={(id) => { @@ -739,6 +767,18 @@ diff --git a/calliope-web/src/lib/components/video/VideoEditWorkspace.svelte b/calliope-web/src/lib/components/video/VideoEditWorkspace.svelte index c646df6c..12e47a8b 100644 --- a/calliope-web/src/lib/components/video/VideoEditWorkspace.svelte +++ b/calliope-web/src/lib/components/video/VideoEditWorkspace.svelte @@ -9,6 +9,7 @@ import type { AssetOption } from '$lib/assetPicker'; import Icon from '$lib/components/ui/Icon.svelte'; import ClipMonitor from './ClipMonitor.svelte'; + import ClipSourceModal from './ClipSourceModal.svelte'; import SceneFilmstrip from './SceneFilmstrip.svelte'; import SceneScriptDrawer from './SceneScriptDrawer.svelte'; @@ -20,9 +21,11 @@ } interface ClipSourceOption { - /** Scene id as string, for a native select. */ + /** Scene id as string, or the 'auto' / 'upload' sentinels. */ id: string; label: string; + /** Clip path — the source modal renders video thumbnails when present. */ + path?: string; } interface ClipSourceConfig { @@ -52,6 +55,8 @@ /** Where this continue scene's video input comes from (auto / upload / a timeline clip). */ clipSource?: ClipSourceConfig; onClipSourceChange?: (value: string) => void; + /** Upload file picked in the source modal — caller opens the file dialog. */ + onClipSourceUpload?: () => void; chained?: (scene: Scene) => boolean; submitting?: boolean; statusOf: (scene: Scene) => string; @@ -82,6 +87,7 @@ generateDisabledReason = '', clipSource, onClipSourceChange, + onClipSourceUpload, chained = () => false, submitting = false, statusOf, @@ -93,6 +99,17 @@ onFormChange, onGenerate, }: Props = $props(); + + let clipSourceOpen = $state(false); + + /** The label shown on the Video source trigger. */ + const clipSourceLabel = $derived.by(() => { + if (!clipSource?.enabled) return ''; + const val = clipSource.value; + if (val === 'auto') return 'Auto (previous clip)'; + if (val === 'upload') return 'Upload file'; + return clipSource.options.find((o) => o.id === val)?.label ?? 'Auto (previous clip)'; + });
@@ -136,26 +153,29 @@
{:else if clipSource?.enabled} -
- - -
- {/if} +
+ Video source + +
+ onClipSourceChange?.(source)} + onupload={() => onClipSourceUpload?.()} + /> + {/if} {#if assetOptions.length === 0}

No refs yet. Generate character sheets or environments in Assets, or upload a video/audio @@ -260,15 +280,38 @@ white-space: nowrap; } - .clip-source-select { - max-width: 320px; - padding: 6px 10px; + .clip-source-trigger { + display: inline-flex; + align-items: center; + gap: 8px; + max-width: 360px; + padding: 6px 12px; + font: inherit; font-size: 13px; color: var(--text-primary); background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm); - font-family: var(--font-body); + cursor: pointer; + } + + .clip-source-trigger:hover { + border-color: var(--text-muted); + } + + .clip-source-trigger:focus-visible { + outline: 2px solid var(--accent); + outline-offset: 2px; + } + + .clip-source-trigger :global(svg:last-child) { + color: var(--text-muted); + } + + .clip-source-value { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } .asset-hint {