feat(video): show the selected clip's shot brief in the composer

1.5 moved rendering to clips but the Video stage only surfaced the scene
script, so the workflow prompt field gave no hint of what an individual
clip performs. Each clip now carries its description, shot size, and
covered dialog lines into a brief panel above the composer, with a copy
button feeding the prompt. The stage splits into player + a scrollable
input inspector so the input stack can no longer squeeze the player out.
This commit is contained in:
Benjiyaya
2026-09-13 02:57:17 +08:00
parent 047048eee5
commit 4c71cc497e
10 changed files with 479 additions and 119 deletions
@@ -37,6 +37,8 @@ export const icons = {
'<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="m17 8-5-5-5 5"/><path d="M12 3v12"/>',
paperclip:
'<path d="m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"/>',
copy:
'<rect x="8" y="8" width="14" height="14" rx="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/>',
search: '<circle cx="11" cy="11" r="8"/><path d="m21 21-4.35-4.35"/>',
'external-link':
'<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><path d="M15 3h6v6"/><path d="M10 14 21 3"/>',
@@ -1,13 +1,10 @@
<script module lang="ts">
import type { Clip, Scene } from '$lib/api';
/** One entry in the strip: a renderable clip pinned to its parent scene. */
export interface FilmstripClip {
clip: {
id: number;
clip_path: string | null;
duration_sec: number | null;
chain_from_prev?: number | boolean | null;
};
scene: import('$lib/api').Scene;
clip: Clip;
scene: Scene;
index: number;
label: string;
}
@@ -19,7 +16,6 @@
* Renders CLIPS (playback order, `#3.2` labels) with scene-divider grouping.
* Never sticky; fixed height; keyboard Left/Right/Home/End.
*/
import type { Scene } from '$lib/api';
import Button from '$lib/components/ui/Button.svelte';
import Icon from '$lib/components/ui/Icon.svelte';
@@ -92,7 +88,7 @@
class:selected={selectedClipId === entry.clip.id}
class:chained={entry.index > 0}
onclick={() => onSelectClip(entry.clip.id)}
title={`#${entry.scene.order_index} · ${entry.scene.heading || 'Scene'} · shot ${entry.index + 1} · ${formatClock(entry.clip.duration_sec || 5)}`}
title={`${entry.label} · ${entry.scene.heading || 'Scene'} · ${formatClock(entry.clip.duration_sec || 5)}${entry.clip.description ? `\n${entry.clip.description}` : ''}`}
>
<span class="bar" aria-hidden="true"></span>
<span class="thumb" aria-hidden="true">
@@ -41,10 +41,6 @@
{#if open}
<div class="drawer" role="region" aria-label="Scene script">
<div class="block">
<span class="k">Heading</span>
<p>{scene.heading || 'Untitled scene'}</p>
</div>
<div class="block">
<span class="k">Action / script</span>
{#if scene.action?.trim()}
@@ -0,0 +1,288 @@
<script lang="ts">
/**
* ShotBrief — the selected clip's production brief in the Video composer.
*
* Clips are render units: each performs one beat of a scene. Without this
* panel the per-clip content (what the camera sees, the shot size, the
* dialog lines it carries) was only visible in the monitor's empty state —
* truncated, and gone as soon as a render existed. Surfacing it here is
* what tells a user what to write into the workflow's prompt field.
*/
import type { Clip, Scene } from '$lib/api';
import Icon from '$lib/components/ui/Icon.svelte';
interface Props {
clip: Clip;
scene: Scene;
/** Display label, e.g. '#3.2'. */
label: string;
formatClock: (sec: number) => string;
}
let { clip, scene, label, formatClock }: Props = $props();
let open = $state(false);
let copied = $state(false);
let copyTimer: ReturnType<typeof setTimeout> | null = null;
const description = $derived((clip.description ?? '').trim());
/** Un-expanded (legacy) clips carry no per-shot description — fall back to the scene action. */
const sceneLevel = $derived(!description && Boolean((scene.action ?? '').trim()));
const body = $derived(description || (scene.action ?? '').trim());
/** Same contract as the backend's `_clip_dialog`: 1-based indexes into the non-empty dialog lines. */
const coveredLines = $derived.by(() => {
const covered = clip.dialog_lines_covered;
if (!covered || covered.length === 0) return [];
const lines = (scene.dialog ?? '').split(/\r?\n/).filter((l) => l.trim());
return covered
.filter((i) => Number.isInteger(i) && i >= 1 && i <= lines.length)
.map((i) => lines[i - 1]);
});
const shotSizeLabel = $derived(
clip.shot_size ? clip.shot_size.replace(/([A-Z])/g, ' $1').trim() : '',
);
async function copyBody() {
if (!body) return;
try {
await navigator.clipboard.writeText(body);
copied = true;
if (copyTimer) clearTimeout(copyTimer);
copyTimer = setTimeout(() => (copied = false), 1500);
} catch {
/* clipboard blocked (insecure context) — leave the button as-is */
}
}
</script>
<div class="brief">
<div class="head">
<span class="label mono">{label}</span>
{#if shotSizeLabel}
<span class="pill">{shotSizeLabel}</span>
{/if}
<span class="dur mono">{formatClock(clip.duration_sec || 5)}</span>
<span class="grow"></span>
<button
type="button"
class="icon-btn"
disabled={!body}
title={copied ? 'Copied' : 'Copy shot description'}
aria-label="Copy shot description"
onclick={copyBody}
>
<Icon name={copied ? 'check' : 'copy'} size={13} />
<span class="icon-btn-text">{copied ? 'Copied' : 'Copy'}</span>
</button>
<button
type="button"
class="icon-btn"
class:open
aria-expanded={open}
title={open ? 'Collapse shot brief' : 'Expand shot brief'}
onclick={() => (open = !open)}
>
<Icon name={open ? 'chevron-up' : 'chevron-down'} size={13} />
</button>
</div>
<p class="desc" class:clamped={!open}>
{#if body}
{body}
{:else}
<span class="muted">No shot description — this clip inherited the scene's defaults.</span>
{/if}
</p>
{#if open}
{#if sceneLevel}
<p class="note">
This clip has no per-shot description yet — the text above is the full scene action. Use
<span class="mono">Break into shots</span> in the Script stage to split it into coverage.
</p>
{/if}
{#if coveredLines.length}
<div class="block">
<span class="k">Dialog in this shot</span>
<pre class="dialog">{coveredLines.join('\n')}</pre>
</div>
{/if}
{#if (scene.characters ?? []).length}
<div class="block">
<span class="k">Characters</span>
<div class="chips">
{#each scene.characters as c (c.id)}
<span class="chip">{c.name}</span>
{/each}
</div>
</div>
{/if}
{/if}
</div>
<style>
.brief {
flex-shrink: 0;
border: 1px solid var(--border);
border-radius: var(--radius-md);
background: var(--bg-surface);
padding: 8px 10px;
margin: 0;
}
.head {
display: flex;
align-items: center;
gap: 8px;
min-height: 20px;
}
.label {
font-size: 12px;
font-weight: 700;
color: var(--accent);
flex-shrink: 0;
}
.pill {
padding: 1px 8px;
border-radius: 999px;
border: 1px solid var(--border);
background: var(--bg-elevated);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.04em;
text-transform: uppercase;
color: var(--text-secondary);
flex-shrink: 0;
}
.dur {
font-size: 11px;
font-weight: 600;
color: var(--text-muted);
flex-shrink: 0;
}
.grow {
flex: 1;
min-width: 0;
}
.icon-btn {
display: inline-flex;
align-items: center;
gap: 4px;
height: 24px;
padding: 0 8px;
font: inherit;
font-size: 11px;
font-weight: 600;
color: var(--text-secondary);
background: var(--bg-elevated);
border: 1px solid var(--border);
border-radius: var(--radius-sm);
cursor: pointer;
flex-shrink: 0;
}
.icon-btn:hover:not(:disabled),
.icon-btn.open {
color: var(--text-primary);
border-color: var(--text-muted);
}
.icon-btn:disabled {
opacity: 0.5;
cursor: default;
}
.icon-btn:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
.icon-btn-text {
line-height: 1;
}
.desc {
margin: 6px 0 0;
font-size: 12.5px;
line-height: 1.45;
color: var(--text-secondary);
white-space: pre-wrap;
word-break: break-word;
}
.desc.clamped {
display: -webkit-box;
-webkit-line-clamp: 2;
line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.muted {
color: var(--text-muted);
}
.note {
margin: 8px 0 0;
font-size: 11.5px;
line-height: 1.45;
color: var(--text-muted);
}
.block {
margin-top: 8px;
}
.block .k {
display: block;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.06em;
text-transform: uppercase;
color: var(--text-muted);
margin-bottom: 4px;
}
.dialog {
margin: 0;
padding: 6px 8px;
background: var(--bg-elevated);
border: 1px solid var(--border);
border-radius: var(--radius-sm);
font-family: var(--font-mono);
font-size: 11.5px;
line-height: 1.45;
white-space: pre-wrap;
color: var(--text-primary);
max-height: 90px;
overflow-y: auto;
}
.chips {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.chip {
background: var(--bg-elevated);
border: 1px solid var(--border);
border-radius: 999px;
padding: 1px 9px;
font-size: 11px;
color: var(--text-secondary);
}
.mono {
font-family: var(--font-mono);
}
</style>
@@ -14,6 +14,7 @@
import PromptPreviewModal from './PromptPreviewModal.svelte';
import SceneFilmstrip, { type FilmstripClip } from './SceneFilmstrip.svelte';
import SceneScriptDrawer from './SceneScriptDrawer.svelte';
import ShotBrief from './ShotBrief.svelte';
type Thumb = { kind: 'image' | 'video'; src: string } | null;
@@ -144,34 +145,36 @@
</script>
<div class="workspace">
<div class="hero">
<ClipMonitor
{previewPath}
{status}
heading={(selectedClip?.clip.description || selected.heading || 'Untitled').slice(0, 80)}
orderIndex={selected.order_index}
label={selectedClip?.label}
idLabel={selectedClip ? `clip ${selectedClip.clip.id}` : selected ? `scene id ${selected.id}` : undefined}
sceneId={selectedClip?.scene.id ?? selected?.id}
{progress}
{error}
{errorLong}
<div class="preview-col">
<div class="hero">
<ClipMonitor
{previewPath}
{status}
heading={(selectedClip?.clip.description || selected.heading || 'Untitled').slice(0, 80)}
orderIndex={selected.order_index}
label={selectedClip?.label}
idLabel={selectedClip ? `clip ${selectedClip.clip.id}` : selected ? `scene id ${selected.id}` : undefined}
sceneId={selectedClip?.scene.id ?? selected?.id}
{progress}
{error}
{errorLong}
/>
</div>
<SceneFilmstrip
clips={filmClips}
{selectedClipId}
{statusOfClip}
{thumbForClip}
{formatClock}
{onSelectClip}
{onStep}
/>
<SceneScriptDrawer scene={selected} {status} {formatClock} />
</div>
<SceneFilmstrip
clips={filmClips}
{selectedClipId}
{statusOfClip}
{thumbForClip}
{formatClock}
{onSelectClip}
{onStep}
/>
<SceneScriptDrawer scene={selected} {status} {formatClock} />
<div class="composer-dock">
<aside class="dock-col" aria-label="Clip generation inputs">
{#if workflow}
{#if generateDisabled}
<div class="continue-warning" role="alert">
@@ -185,77 +188,85 @@
</div>
</div>
{:else if clipSource?.enabled}
<div class="clip-source-row">
<span class="clip-source-label" id="clip-source-label">Video source</span>
<button
type="button"
class="clip-source-trigger"
aria-haspopup="dialog"
aria-expanded={clipSourceOpen}
aria-labelledby="clip-source-label clip-source-value"
onclick={() => (clipSourceOpen = true)}
>
<Icon name="film" size={14} />
<span id="clip-source-value" class="clip-source-value">{clipSourceLabel}</span>
<Icon name="chevron-down" size={12} />
</button>
</div>
<ClipSourceModal
bind:open={clipSourceOpen}
value={clipSource.value}
options={clipSource.options}
onselect={(source) => onClipSourceChange?.(source)}
onupload={() => onClipSourceUpload?.()}
/>
{/if}
{#if assetOptions.length === 0}
<p class="asset-hint">
No refs yet. Generate character sheets or environments in Assets, or upload a video/audio
file here.
</p>
{/if}
{#if hasJobPayload}
<div class="job-inputs-row">
<button
type="button"
class="job-inputs-trigger"
aria-haspopup="dialog"
aria-expanded={inputsOpen}
onclick={() => (inputsOpen = true)}
>
<Icon name="info" size={14} />
<span>View prompt &amp; inputs</span>
</button>
</div>
<JobInputsDrawer
bind:open={inputsOpen}
{job}
jobs={clipJobs}
{workflow}
sceneVideoPath={selectedClip?.clip.clip_path ?? selected.video_path}
onCopySettings={(values) => {
formValues = { ...formValues, ...values };
onFormChange?.({ ...formValues });
}}
onApplyToScene={(j, path) => onApplyToClip?.(j, path)}
applying={applying}
/>
{/if}
<div class="clip-source-row">
<span class="clip-source-label" id="clip-source-label">Video source</span>
<button
type="button"
class="clip-source-trigger"
aria-haspopup="dialog"
aria-expanded={clipSourceOpen}
aria-labelledby="clip-source-label clip-source-value"
onclick={() => (clipSourceOpen = true)}
>
<Icon name="film" size={14} />
<span id="clip-source-value" class="clip-source-value">{clipSourceLabel}</span>
<Icon name="chevron-down" size={12} />
</button>
</div>
<ClipSourceModal
bind:open={clipSourceOpen}
value={clipSource.value}
options={clipSource.options}
onselect={(source) => onClipSourceChange?.(source)}
onupload={() => onClipSourceUpload?.()}
/>
{/if}
{#if assetOptions.length === 0}
<p class="asset-hint">
No refs yet. Generate character sheets or environments in Assets, or upload a video/audio
file here.
</p>
{/if}
{#if hasJobPayload}
<div class="job-inputs-row">
<button
type="button"
class="job-inputs-trigger"
aria-haspopup="dialog"
aria-expanded={inputsOpen}
onclick={() => (inputsOpen = true)}
>
<Icon name="info" size={14} />
<span>View prompt &amp; inputs</span>
</button>
</div>
<JobInputsDrawer
bind:open={inputsOpen}
{job}
jobs={clipJobs}
{workflow}
sceneVideoPath={selectedClip?.clip.clip_path ?? selected.video_path}
onCopySettings={(values) => {
formValues = { ...formValues, ...values };
onFormChange?.({ ...formValues });
}}
onApplyToScene={(j, path) => onApplyToClip?.(j, path)}
applying={applying}
/>
{/if}
{#if selectedClip}
<ShotBrief
clip={selectedClip.clip}
scene={selectedClip.scene}
label={selectedClip.label}
{formatClock}
/>
{/if}
<OmniComposer
inputs={workflow.input_schema}
bind:values={formValues}
{workflow}
{workflows}
onWorkflowChange={onWorkflowChange}
{assetOptions}
{allowUpload}
{generateLabel}
{submitting}
disabled={generateDisabled}
generateDisabledHint={generateDisabledReason}
onChange={onFormChange}
onSubmit={onPreviewPrompt ?? onGenerate}
/>
{assetOptions}
{allowUpload}
{generateLabel}
{submitting}
disabled={generateDisabled}
generateDisabledHint={generateDisabledReason}
onChange={onFormChange}
onSubmit={onPreviewPrompt ?? onGenerate}
/>
{:else}
<div class="no-wf">
<p class="empty-title">No video workflow enabled</p>
@@ -264,22 +275,33 @@
</p>
</div>
{/if}
</div>
</aside>
</div>
<style>
/* Two columns: the player + strip own the left, every generation input
lives in the right inspector so it can't push the player out of view. */
.workspace {
flex: 1;
min-height: 0;
display: flex;
flex-direction: row;
gap: 12px;
overflow: hidden;
}
.preview-col {
flex: 1 1 auto;
min-width: 0;
display: flex;
flex-direction: column;
gap: 10px;
overflow: hidden;
}
.hero {
flex: 1;
min-height: 140px;
flex: 1 1 auto;
min-height: 200px;
display: flex;
align-items: stretch;
justify-content: stretch;
@@ -287,21 +309,45 @@
width: 100%;
}
.composer-dock {
flex-shrink: 0;
min-height: 0;
/* Inspector — scrolls on its own so the player keeps the height. */
.dock-col {
flex: 0 0 clamp(300px, 34%, 400px);
min-width: 280px;
display: flex;
flex-direction: column;
gap: 8px;
overflow-y: auto;
overscroll-behavior: contain;
padding-right: 2px;
}
.composer-dock :global(.omni-shell) {
.dock-col :global(.omni-shell) {
flex-shrink: 0;
}
/* Very narrow: stack, player first. */
@media (max-width: 900px) {
.workspace {
flex-direction: column;
overflow-y: auto;
}
.preview-col {
overflow: visible;
}
.dock-col {
flex: 0 0 auto;
overflow: visible;
}
}
.continue-warning {
display: flex;
align-items: flex-start;
gap: 10px;
padding: 10px 12px;
margin: 0 0 8px;
margin: 0;
border-radius: var(--radius-md);
border: 1px solid color-mix(in srgb, var(--warning) 40%, var(--border));
background: color-mix(in srgb, var(--warning) 10%, var(--bg-surface));
@@ -330,7 +376,7 @@
display: flex;
align-items: center;
gap: 8px;
margin: 0 0 8px;
margin: 0;
}
.clip-source-label {
@@ -343,7 +389,8 @@
display: inline-flex;
align-items: center;
gap: 8px;
max-width: 360px;
max-width: 100%;
min-width: 0;
padding: 6px 12px;
font: inherit;
font-size: 13px;
@@ -374,7 +421,7 @@
}
.asset-hint {
margin: 0 0 8px;
margin: 0;
font-size: 12px;
color: var(--text-muted);
line-height: 1.4;
@@ -383,7 +430,7 @@
.job-inputs-row {
display: flex;
justify-content: flex-end;
margin: 0 0 6px;
margin: 0;
}
.job-inputs-trigger {