AI media harness for planning, generating, and editing locally
TypeScript
Move reference video trimming into popup
Bitti0bd198ed3d64
diff --git a/docs/video-references.md b/docs/video-references.mdindex 1fe3f2a..fbae85f 100644--- a/docs/video-references.md+++ b/docs/video-references.md@@ -65,15 +65,13 @@ Source videos may be longer than 15 seconds. Import initially selects the firstuses the actual video frame timestamps so fragmented MP4s with missing orplaceholder header durations can still be selected correctly.-Use **Position in full video** to move the reference segment anywhere in the-source. Drag the highlighted selection to move it without changing its length,-or drag either edge to trim it. The closer ruler displays up to 30 seconds at a-time so the edges remain usable on long videos. The start and duration fields-provide precise edits; all controls stay within the source and the 2–15 second+Choose **Edit video clip** to open the preview and trim controls in a wide+popup. Drag the highlighted selection to move it without changing its length,+or drag either edge to trim it. Scroll the timeline horizontally to reach later+parts of long videos. The range stays within the source and the 2–15 secondselection limit. The handles also support arrow keys (0.1 seconds), Shift+arrow(1 second), Home, and End.-You can also seek in the video player and choose **Start at playhead**.**Play selection** previews only the chosen segment and stops at its end.**Include sound** controls the selected interval's soundtrack. Changing theselection seeks the existing player without reloading the source. Trimming thediff --git a/src/components/workspace/ReferenceVideo.test.tsx b/src/components/workspace/ReferenceVideo.test.tsxindex 8354df7..cf9f7fa 100644--- a/src/components/workspace/ReferenceVideo.test.tsx+++ b/src/components/workspace/ReferenceVideo.test.tsx@@ -23,6 +23,7 @@ function Harness({ initial = original }: { initial?: ProjectReference }) {return <><ReferenceVideo folderPath="C:/project" reference={reference} onChange={(video) => setReference((current) => projectReferenceSchema.parse({ ...current, video }))} /><output data-testid="saved">{JSON.stringify(reference.video)}</output></>;}async function ready(duration = 120) {+ fireEvent.click(screen.getByRole("button", { name: "Edit video clip" }));const video = await screen.findByLabelText("Long video video preview") as HTMLVideoElement;Object.defineProperty(video, "duration", { value: duration, configurable: true });fireEvent.loadedMetadata(video);@@ -34,7 +35,7 @@ it("starts at 0–15 seconds and moves and resizes the selection without reloadirender(<Harness />);const video = await ready();expect(screen.getByText("0:00.0 – 0:15.0")).toBeInTheDocument();- fireEvent.change(screen.getByLabelText("Clip position"), { target: { value: "60" } });+ for (let i = 0; i < 60; i++) fireEvent.keyDown(screen.getByRole("slider", { name: "Move selection" }), { key: "ArrowRight", shiftKey: true });expect(saved()).toMatchObject({ startSeconds: 60, durationSeconds: 15 });expect(video.currentTime).toBe(60);fireEvent.keyDown(screen.getByRole("slider", { name: "Selection end" }), { key: "ArrowLeft", shiftKey: true });@@ -52,8 +53,7 @@ it("keeps the selection in bounds at the end of a long video", async () => {await ready(3600);fireEvent.keyDown(screen.getByRole("slider", { name: "Move selection" }), { key: "End" });expect(saved()).toMatchObject({ startSeconds: 3585, durationSeconds: 15 });- fireEvent.change(screen.getByLabelText("Clip duration (seconds)"), { target: { value: "100" } });- fireEvent.blur(screen.getByLabelText("Clip duration (seconds)"));+ fireEvent.keyDown(screen.getByRole("slider", { name: "Selection end" }), { key: "End" });expect(saved().durationSeconds).toBe(15);fireEvent.keyDown(screen.getByRole("slider", { name: "Selection start" }), { key: "End" });expect(saved()).toMatchObject({ startSeconds: 3598, durationSeconds: 2 });@@ -70,7 +70,7 @@ it("drags the selected interval and its edges", async () => {const video = await ready();const bar = screen.getByLabelText("Drag the selection or its edges");Object.defineProperty(bar, "setPointerCapture", { value: vi.fn() });- vi.spyOn(bar, "getBoundingClientRect").mockReturnValue({ width: 300, left: 0 } as DOMRect);+ vi.spyOn(bar, "getBoundingClientRect").mockReturnValue({ width: 1200, left: 0 } as DOMRect);fireEvent.pointerDown(screen.getByRole("slider", { name: "Move selection" }), { button: 0, pointerId: 1, clientX: 75 });fireEvent.pointerMove(bar, { pointerId: 1, clientX: 125 });fireEvent.pointerUp(bar, { pointerId: 1 });@@ -92,12 +92,25 @@ it("drags the selected interval and its edges", async () => {expect(video.currentTime).toBe(7);});-it("starts the segment at the frame chosen in the video player", async () => {+it("opens clip settings in a dialog and preserves edits after closing", async () => {render(<Harness />);- const video = await ready();- video.currentTime = 42;- fireEvent.click(screen.getByRole("button", { name: "Start at playhead" }));- expect(saved()).toMatchObject({ startSeconds: 42, durationSeconds: 15 });+ const opener = screen.getByRole("button", { name: "Edit video clip" });+ opener.focus();+ expect(screen.queryByLabelText("Long video video preview")).not.toBeInTheDocument();+ await ready();+ const dialog = screen.getByRole("dialog", { name: /Long video.*Video clip/ });+ expect(screen.queryByRole("spinbutton")).not.toBeInTheDocument();+ expect(screen.queryByLabelText("Clip position")).not.toBeInTheDocument();+ fireEvent.keyDown(screen.getByRole("slider", { name: "Move selection" }), { key: "End" });+ fireEvent.keyDown(dialog, { key: "Escape" });+ expect(screen.queryByRole("dialog")).not.toBeInTheDocument();+ expect(opener).toHaveFocus();+ expect(URL.revokeObjectURL).toHaveBeenCalledWith("blob:video");+ const reopened = await ready();+ expect(reopened.currentTime).toBe(105);+ expect(saved()).toMatchObject({ startSeconds: 105, durationSeconds: 15 });+ fireEvent.click(screen.getByRole("button", { name: "Close video clip settings" }));+ expect(screen.queryByRole("dialog")).not.toBeInTheDocument();});it("plays only the selected interval and keeps soundtrack settings", async () => {diff --git a/src/components/workspace/ReferenceVideo.tsx b/src/components/workspace/ReferenceVideo.tsxindex fc368db..8b894a5 100644--- a/src/components/workspace/ReferenceVideo.tsx+++ b/src/components/workspace/ReferenceVideo.tsx@@ -1,28 +1,54 @@-import { Pause, Play } from "lucide-react";+import { Pause, Play, Scissors, X } from "lucide-react";import { useEffect, useRef, useState, type KeyboardEvent, type PointerEvent } from "react";+import { createPortal } from "react-dom";import { readMediaFileUrl } from "../../lib/persistence";import type { ProjectReference } from "../../lib/project";import { editReferenceVideoTrim, initialReferenceVideoTrim, normalizeReferenceVideoTrim, referenceTime, type ReferenceVideoTrim, type TrimAction } from "../../lib/referenceVideoTrim";type VideoOptions = NonNullable<ProjectReference["video"]>;-function SecondsInput({ label, value, min, max, onChange }: {- label: string; value: number; min: number; max: number; onChange: (value: number) => void;-}) {- const [draft, setDraft] = useState(String(value));- useEffect(() => setDraft(String(Math.round(value * 1000) / 1000)), [value]);- return <label>{label}<input type="number" min={min} max={max} step="0.1" value={draft}- onChange={(event) => setDraft(event.target.value)} onKeyDown={(event) => { if (event.key === "Enter") event.currentTarget.blur(); }}- onBlur={() => {- const parsed = Number(draft);- const next = draft.trim() && Number.isFinite(parsed) ? Math.max(min, Math.min(max, parsed)) : value;- setDraft(String(next)); onChange(next);- }} /></label>;+type ReferenceVideoProps = { folderPath: string; reference: ProjectReference; onChange: (video: VideoOptions) => void };++export function ReferenceVideo(props: ReferenceVideoProps) {+ const [open, setOpen] = useState(false);+ const start = props.reference.video?.startSeconds ?? 0;+ const length = props.reference.video?.durationSeconds ?? 15;+ return <>+ {!open && <div className="reference-trim__summary"><strong>{referenceTime(start)} – {referenceTime(start + length)}</strong><span>{Number(length.toFixed(2))} s selected</span></div>}+ <button type="button" className="secondary-button" onClick={() => setOpen(true)}><Scissors size={16} /> Edit video clip</button>+ {open && createPortal(<ReferenceVideoDialog {...props} onClose={() => setOpen(false)} />, document.body)}+ </>;+}++function ReferenceVideoDialog({ onClose, ...props }: ReferenceVideoProps & { onClose: () => void }) {+ const dialog = useRef<HTMLDivElement>(null);+ useEffect(() => {+ const opener = document.activeElement as HTMLElement | null;+ const workspace = document.querySelector<HTMLElement>(".references-view");+ const wasInert = workspace?.inert ?? false;+ if (workspace) workspace.inert = true;+ dialog.current?.querySelector<HTMLButtonElement>("button")?.focus();+ return () => {+ if (workspace) workspace.inert = wasInert;+ if (opener?.isConnected) opener.focus();+ };+ }, []);+ return <div className="reference-video-dialog-overlay" onKeyDown={(event) => {+ event.stopPropagation();+ if (event.key === "Escape") { event.preventDefault(); onClose(); }+ if (event.key !== "Tab") return;+ const controls = Array.from(dialog.current?.querySelectorAll<HTMLElement>('button:not(:disabled), input:not(:disabled), video[controls]') ?? []);+ if (event.shiftKey && document.activeElement === controls[0]) { event.preventDefault(); controls.at(-1)?.focus(); }+ else if (!event.shiftKey && document.activeElement === controls.at(-1)) { event.preventDefault(); controls[0]?.focus(); }+ }}>+ <div ref={dialog} className="reference-video-dialog" role="dialog" aria-modal="true" aria-labelledby="reference-video-heading">+ <header><h2 id="reference-video-heading">{props.reference.name} — Video clip</h2><button type="button" className="icon-button" aria-label="Close video clip settings" onClick={onClose}><X size={18} /></button></header>+ <div className="reference-video"><ReferenceVideoEditor {...props} /></div>+ </div>+ </div>;}-export function ReferenceVideo({ folderPath, reference, onChange }: {- folderPath: string; reference: ProjectReference; onChange: (video: VideoOptions) => void;-}) {+function ReferenceVideoEditor({ folderPath, reference, onChange }: ReferenceVideoProps) {const [url, setUrl] = useState<string | null>(null);const [error, setError] = useState<string | null>(null);const [sourceDuration, setSourceDuration] = useState<number | null>(null);@@ -31,8 +57,8 @@ export function ReferenceVideo({ folderPath, reference, onChange }: {const latest = useRef({ reference, onChange });latest.current = { reference, onChange };const bar = useRef<HTMLDivElement>(null);- const gesture = useRef<{ pointerId: number; action: TrimAction; x: number; width: number; trim: ReferenceVideoTrim; windowStart: number; windowDuration: number } | null>(null);- const [dragging, setDragging] = useState(false);+ const scroller = useRef<HTMLDivElement>(null);+ const gesture = useRef<{ pointerId: number; action: TrimAction; x: number; width: number; trim: ReferenceVideoTrim; scrollLeft: number } | null>(null);const selectionPlayback = useRef(false);const frameCallback = useRef<number | null>(null);const previewEdge = useRef<"start" | "end">("start");@@ -42,7 +68,7 @@ export function ReferenceVideo({ folderPath, reference, onChange }: {setUrl(null); setError(null); setSourceDuration(null); setPreviewing(false);selectionPlayback.current = false;previewEdge.current = "start";- gesture.current = null; setDragging(false);+ gesture.current = null;void readMediaFileUrl(folderPath, reference, "video/mp4").then((value) => {if (disposed) { if (value) URL.revokeObjectURL(value); return; }owned = value; setUrl(value);@@ -55,10 +81,14 @@ export function ReferenceVideo({ folderPath, reference, onChange }: {const start = trim?.startSeconds ?? 0;const length = trim?.durationSeconds ?? 15;const end = start + length;- // A local ruler keeps handles usable even for hour-long sources; the- // overview slider moves this window anywhere in the source.- const windowDuration = dragging && gesture.current ? gesture.current.windowDuration : Math.min(sourceDuration ?? 30, 30);- const windowStart = dragging && gesture.current ? gesture.current.windowStart : Math.max(0, Math.min((sourceDuration ?? 30) - windowDuration, start - (windowDuration - length) / 2));+ useEffect(() => {+ const viewport = scroller.current, timeline = bar.current;+ if (!viewport || !timeline || !sourceDuration || gesture.current || !viewport.clientWidth) return;+ const scale = timeline.getBoundingClientRect().width / sourceDuration;+ const left = start * scale, right = end * scale;+ if (left < viewport.scrollLeft) viewport.scrollLeft = Math.max(0, left - 16);+ else if (right > viewport.scrollLeft + viewport.clientWidth) viewport.scrollLeft = right - viewport.clientWidth + 16;+ }, [start, end, sourceDuration]);const stop = () => {selectionPlayback.current = false;@@ -112,9 +142,8 @@ export function ReferenceVideo({ folderPath, reference, onChange }: {const box = bar.current.getBoundingClientRect();if (!box.width) return;previewTrim(action, trim);- gesture.current = { pointerId: event.pointerId, action, x: event.clientX, width: box.width, trim, windowStart, windowDuration };+ gesture.current = { pointerId: event.pointerId, action, x: event.clientX, width: box.width, trim, scrollLeft: scroller.current?.scrollLeft ?? 0 };bar.current.setPointerCapture(event.pointerId);- setDragging(true);};const keyboard = (event: KeyboardEvent, action: TrimAction, value: number, min: number, max: number) => {const step = event.shiftKey ? 1 : .1;@@ -148,47 +177,46 @@ export function ReferenceVideo({ folderPath, reference, onChange }: {onError={() => setError("This computer cannot preview this video codec.")} />}{trim && sourceDuration !== null && <div className="reference-trim" aria-label="Reference segment editor"><div className="reference-trim__summary"><strong>{referenceTime(start)} – {referenceTime(end)}</strong><span>{Number(length.toFixed(2))} s selected · 15 s max</span></div>- <label className="reference-trim__overview">Position in full video- <input aria-label="Clip position" type="range" min="0" max={sourceDuration - length} step="any" value={start}- disabled={sourceDuration === length} onChange={(event) => change("move", Number(event.target.value))} />- </label>- <div className="reference-trim__ticks"><span>0:00</span><span>Source {referenceTime(sourceDuration)}</span></div>- <div ref={bar} className="reference-trim__bar" aria-label="Drag the selection or its edges"- onPointerDown={(event) => {- if (event.target !== event.currentTarget || event.button !== 0) return;- const box = event.currentTarget.getBoundingClientRect();- if (box.width) change("move", windowStart + (event.clientX - box.left) / box.width * windowDuration - length / 2);- }}- onPointerMove={(event) => {- const drag = gesture.current;- if (!drag || event.pointerId !== drag.pointerId) return;- const delta = (event.clientX - drag.x) / drag.width * drag.windowDuration;- const original = drag.action === "end" ? drag.trim.startSeconds + drag.trim.durationSeconds : drag.trim.startSeconds;- const maximum = drag.windowStart + drag.windowDuration - (drag.action === "move" ? drag.trim.durationSeconds : 0);- const value = Math.max(drag.windowStart, Math.min(maximum, original + delta));- change(drag.action, Math.round(value * 1000) / 1000, drag.trim);- }}- onPointerUp={() => { gesture.current = null; setDragging(false); }}- onPointerCancel={() => { gesture.current = null; setDragging(false); }}- onLostPointerCapture={() => { gesture.current = null; setDragging(false); }}>- <div className="reference-trim__selection" style={{ left: `${(start - windowStart) / windowDuration * 100}%`, width: `${length / windowDuration * 100}%` }}>- <button type="button" className="reference-trim__handle" role="slider" aria-label="Selection start" aria-valuemin={Math.max(0, end - 15)} aria-valuemax={end - 2} aria-valuenow={start} aria-valuetext={referenceTime(start)}- onPointerDown={(event) => beginDrag(event, "start")} onKeyDown={(event) => keyboard(event, "start", start, Math.max(0, end - 15), end - 2)} />- <button type="button" className="reference-trim__move" role="slider" aria-label="Move selection" aria-valuemin={0} aria-valuemax={sourceDuration - length} aria-valuenow={start} aria-valuetext={referenceTime(start)}- onPointerDown={(event) => beginDrag(event, "move")} onKeyDown={(event) => keyboard(event, "move", start, 0, sourceDuration - length)}>Drag</button>- <button type="button" className="reference-trim__handle" role="slider" aria-label="Selection end" aria-valuemin={start + 2} aria-valuemax={Math.min(sourceDuration, start + 15)} aria-valuenow={end} aria-valuetext={referenceTime(end)}- onPointerDown={(event) => beginDrag(event, "end")} onKeyDown={(event) => keyboard(event, "end", end, start + 2, Math.min(sourceDuration, start + 15))} />+ <div ref={scroller} className="reference-trim__scroll" role="region" aria-label="Video trim timeline">+ <div className="reference-trim__track" style={{ minWidth: `${sourceDuration * 24}px` }}>+ <div ref={bar} className="reference-trim__bar" aria-label="Drag the selection or its edges"+ onPointerDown={(event) => {+ if (event.target !== event.currentTarget || event.button !== 0) return;+ const box = event.currentTarget.getBoundingClientRect();+ if (box.width) change("move", (event.clientX - box.left) / box.width * sourceDuration - length / 2);+ }}+ onPointerMove={(event) => {+ const drag = gesture.current;+ if (!drag || event.pointerId !== drag.pointerId) return;+ const viewport = scroller.current;+ if (viewport && viewport.clientWidth) {+ const bounds = viewport.getBoundingClientRect();+ if (event.clientX > bounds.right - 24) viewport.scrollLeft += 16;+ else if (event.clientX < bounds.left + 24) viewport.scrollLeft -= 16;+ }+ const delta = (event.clientX - drag.x + (viewport?.scrollLeft ?? 0) - drag.scrollLeft) / drag.width * sourceDuration;+ const original = drag.action === "end" ? drag.trim.startSeconds + drag.trim.durationSeconds : drag.trim.startSeconds;+ const maximum = sourceDuration - (drag.action === "move" ? drag.trim.durationSeconds : 0);+ const value = Math.max(0, Math.min(maximum, original + delta));+ change(drag.action, Math.round(value * 1000) / 1000, drag.trim);+ }}+ onPointerUp={() => { gesture.current = null; }}+ onPointerCancel={() => { gesture.current = null; }}+ onLostPointerCapture={() => { gesture.current = null; }}>+ <div className="reference-trim__selection" style={{ left: `${start / sourceDuration * 100}%`, width: `${length / sourceDuration * 100}%` }}>+ <button type="button" className="reference-trim__handle" role="slider" aria-label="Selection start" aria-valuemin={Math.max(0, end - 15)} aria-valuemax={end - 2} aria-valuenow={start} aria-valuetext={referenceTime(start)}+ onPointerDown={(event) => beginDrag(event, "start")} onKeyDown={(event) => keyboard(event, "start", start, Math.max(0, end - 15), end - 2)} />+ <button type="button" className="reference-trim__move" role="slider" aria-label="Move selection" aria-valuemin={0} aria-valuemax={sourceDuration - length} aria-valuenow={start} aria-valuetext={referenceTime(start)}+ onPointerDown={(event) => beginDrag(event, "move")} onKeyDown={(event) => keyboard(event, "move", start, 0, sourceDuration - length)}>Drag</button>+ <button type="button" className="reference-trim__handle" role="slider" aria-label="Selection end" aria-valuemin={start + 2} aria-valuemax={Math.min(sourceDuration, start + 15)} aria-valuenow={end} aria-valuetext={referenceTime(end)}+ onPointerDown={(event) => beginDrag(event, "end")} onKeyDown={(event) => keyboard(event, "end", end, start + 2, Math.min(sourceDuration, start + 15))} />+ </div>+ </div>+ <div className="reference-trim__ticks"><span>0:00</span><span>{referenceTime(sourceDuration)}</span></div></div></div>- <div className="reference-trim__ticks"><span>{referenceTime(windowStart)}</span><span>{referenceTime(windowStart + windowDuration)}</span></div>- <p>Move the selection or drag its edges. Use the position slider to find a part anywhere in the video.</p>- <div className="reference-trim__numbers">- <SecondsInput label="Clip start (seconds)" value={start} min={0} max={sourceDuration - length} onChange={(value) => change("move", value)} />- <SecondsInput label="Clip duration (seconds)" value={length} min={2} max={Math.min(15, sourceDuration - start)} onChange={(value) => change("duration", value)} />- </div><div className="reference-trim__actions"><button type="button" className="secondary-button" onClick={() => void playSelection()}>{previewing ? <Pause size={14} /> : <Play size={14} />}{previewing ? "Pause selection" : "Play selection"}</button>- <button type="button" className="secondary-button" onClick={() => change("move", video.current?.currentTime ?? start)}>Start at playhead</button></div><label><input type="checkbox" checked={reference.video?.includeAudio ?? true}onChange={(event) => onChange({ ...trim, includeAudio: event.target.checked })} /> Include sound</label>diff --git a/src/components/workspace/ReferencesView.tsx b/src/components/workspace/ReferencesView.tsxindex 7b218ee..01bd147 100644--- a/src/components/workspace/ReferencesView.tsx+++ b/src/components/workspace/ReferencesView.tsx@@ -238,7 +238,6 @@ export function ReferencesView({ config, folderPath, onChange, onRegenerateIcon,{selected.kind === "video" && <section className="reference-video" aria-label="Video reference"><ReferenceVideo key={`${selected.id}:${selected.sourcePath ?? selected.relativePath}`} folderPath={folderPath} reference={selected}onChange={(video) => update(selected.id, { video })} />- <p>Long videos are welcome. Only the selected 2–15 seconds are used. Up to 3 references can total 15 seconds per generation.</p><button className="secondary-button" onClick={() => update(selected.id, { kind: "text", sourcePath: null, relativePath: null, video: undefined })}><Trash2 size={16} /> Remove video</button></section>}{(selected.kind !== "video" || showImages || hasRefmods) && <div className={`reference-detail-art${showImages || selected.iconRelativePath || (!hasRefmods && selectedPresetIcon) ? " reference-detail-art--photo" : " reference-detail-art--text"}${(!hasRefmods && selectedPresetIcon) || selected.iconRelativePath ? " reference-detail-art--preset" : ""}`}>diff --git a/src/components/workspace/ReferencesView.video.test.tsx b/src/components/workspace/ReferencesView.video.test.tsxindex 07c4cba..d696b59 100644--- a/src/components/workspace/ReferencesView.video.test.tsx+++ b/src/components/workspace/ReferencesView.video.test.tsx@@ -103,20 +103,22 @@ it("imports a video, edits its saved trim and soundtrack, then removes its attacfireEvent.click(within(picker).getByRole("button", { name: "New" }));expect(latest.references[0]).toMatchObject({ name: "Uncategorized", kind: "text", intendedUse: [] });fireEvent.click(screen.getByRole("button", { name: "Add file" }));+ fireEvent.click(await screen.findByRole("button", { name: "Edit video clip" }));const preview = await screen.findByLabelText("Uncategorized video preview");Object.defineProperty(preview, "duration", { value: 10, configurable: true });fireEvent.loadedMetadata(preview);expect(invoke).toHaveBeenCalledWith("choose_reference_files", { folderPath: "C:/project" });expect(screen.getByRole("img", { name: "Frame from Uncategorized" })).toHaveAttribute("src", "test:C:/motion.mp4:0");- fireEvent.change(screen.getByLabelText("Clip duration (seconds)"), { target: { value: "4" } });- fireEvent.blur(screen.getByLabelText("Clip duration (seconds)"));- fireEvent.change(screen.getByLabelText("Clip start (seconds)"), { target: { value: "2" } });- fireEvent.blur(screen.getByLabelText("Clip start (seconds)"));+ for (let i = 0; i < 2; i++) fireEvent.keyDown(screen.getByRole("slider", { name: "Selection start" }), { key: "ArrowRight", shiftKey: true });+ for (let i = 0; i < 4; i++) fireEvent.keyDown(screen.getByRole("slider", { name: "Selection end" }), { key: "ArrowLeft", shiftKey: true });fireEvent.click(screen.getByLabelText("Include sound"));expect(parseProjectConfig(JSON.parse(JSON.stringify(latest))).references[0]).toMatchObject({name: "Uncategorized", intendedUse: [], kind: "video", sourcePath: "C:/motion.mp4", video: { startSeconds: 2, durationSeconds: 4, includeAudio: false },});expect(screen.getByRole("img", { name: "Frame from Uncategorized" })).toHaveAttribute("src", "test:C:/motion.mp4:0");+ fireEvent.click(screen.getByRole("button", { name: "Close video clip settings" }));+ expect(screen.getByLabelText("Prompt")).toBeEnabled();+ expect(screen.queryByText(/Long videos are welcome/)).not.toBeInTheDocument();vi.mocked(invoke).mockResolvedValueOnce([{ kind: "video", name: "replacement.mp4", sourcePath: "C:/replacement.mp4" }]);fireEvent.click(screen.getByRole("button", { name: "Add file" }));await waitFor(() => expect(screen.getByRole("img", { name: "Frame from Uncategorized" })).toHaveAttribute("src", "test:C:/replacement.mp4:0"));diff --git a/src/styles/references.css b/src/styles/references.cssindex a10afff..7dd1e30 100644--- a/src/styles/references.css+++ b/src/styles/references.css@@ -599,10 +599,52 @@padding: var(--space-4);}+.reference-video-dialog-overlay {+ position: fixed;+ z-index: 100;+ inset: 0;+ display: grid;+ place-items: center;+ padding: var(--space-5);+ background: var(--scrim);+ backdrop-filter: blur(5px);+}++.reference-video-dialog {+ display: flex;+ flex-direction: column;+ width: min(1100px, 100%);+ min-width: 0;+ max-height: calc(100dvh - var(--space-5) * 2);+ overflow: hidden;+ border: 1px solid var(--line-strong);+ border-radius: var(--radius-lg);+ background: var(--panel-2);+ box-shadow: var(--shadow);+}++.reference-video-dialog > header {+ display: flex;+ flex-shrink: 0;+ align-items: center;+ justify-content: space-between;+ gap: var(--space-3);+ padding: var(--space-4);+ border-bottom: 1px solid var(--line);+}++.reference-video-dialog h2 {+ margin: 0;+ overflow-wrap: anywhere;+ font-size: var(--text-lg);+}++.reference-video-dialog > .reference-video { min-height: 0; overflow-y: auto; }+.reference-video-preview {display: block;width: 100%;- max-height: 280px;+ max-height: min(50vh, 460px);background: var(--field-bg);border-radius: var(--radius-sm);}@@ -610,8 +652,8 @@.reference-trim { display: grid; gap: var(--space-2); min-width: 0; }.reference-trim__summary { display: flex; flex-direction: column; gap: 4px; font-variant-numeric: tabular-nums; }.reference-trim__summary span, .reference-trim__ticks { color: var(--text-muted); font-size: var(--text-xs); }-.reference-video .reference-trim__overview { display: grid; gap: 4px; }-.reference-trim__overview input { width: 100%; accent-color: var(--accent); }+.reference-trim__scroll { min-width: 0; overflow-x: auto; padding-bottom: var(--space-2); }+.reference-trim__track { width: 100%; padding: 2px 4px; }.reference-trim__ticks { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }.reference-trim__bar { position: relative; height: 40px; margin: 8px 7px 0; border-radius: var(--radius-sm); background: var(--panel-3); touch-action: none; user-select: none; cursor: pointer; }.reference-trim__selection { position: absolute; top: 0; bottom: 0; display: flex; border: 2px solid var(--accent); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--accent) 20%, var(--panel-2)); }@@ -623,10 +665,7 @@.reference-trim__move { width: 100%; min-width: 0; overflow: hidden; font-size: var(--text-xs); color: var(--text-primary); background: transparent; cursor: grab; }.reference-trim__move:active { cursor: grabbing; }.reference-trim__selection button:focus-visible { outline: 2px solid var(--text-primary); outline-offset: 3px; }-.reference-trim__numbers { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }.reference-trim__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }-.reference-video .reference-trim__numbers label { display: grid; gap: 4px; min-width: 0; }-.reference-video .reference-trim__numbers input { width: 100%; min-width: 0; }.reference-video p {color: var(--text-muted);@@ -639,12 +678,6 @@gap: var(--space-2);}-.reference-video input[type="number"] {- min-width: 0;- width: 80px;- margin-left: auto;-}-.reference-fields__actions {display: flex;flex-wrap: wrap;