AI media harness for planning, generating, and editing locally
TypeScript
Media panel grid/list + thumbnails, B-roll track, renameable tracks
Bittia497d2968781
diff --git a/fixtures/project-v1-created.json b/fixtures/project-v1-created.jsonindex a45b9ed..5571943 100644--- a/fixtures/project-v1-created.json+++ b/fixtures/project-v1-created.json@@ -37,6 +37,14 @@"muted": false,"clips": []},+ {+ "id": "track-b-roll",+ "kind": "video",+ "name": "B-roll",+ "locked": false,+ "muted": false,+ "clips": []+ },{"id": "track-voice-over","kind": "audio",diff --git a/src/components/workspace/GeneratorView.tsx b/src/components/workspace/GeneratorView.tsxindex ed2262b..1814c5d 100644--- a/src/components/workspace/GeneratorView.tsx+++ b/src/components/workspace/GeneratorView.tsx@@ -2,7 +2,7 @@ import { listen } from "@tauri-apps/api/event";import { AlertCircle, Ban, Check, ChevronRight, Clock3, Film, Info, LoaderCircle, Play, RefreshCw, Sparkles, Square, WandSparkles, X } from "lucide-react";import { useEffect, useMemo, useRef, useState } from "react";import { isTauri } from "../../lib/persistence";-import { compileMiniMaxH3Prompt, createDraftGenerationJob, isReferenceDescribed, isReferenceUsable, isVisualReference, projectFilePath, usableImageReferences, type GenerationJob, type ProjectAsset, type ProjectConfig, type ProjectReference, type TimelineClip, type TimelineTrack } from "../../lib/project";+import { compileMiniMaxH3Prompt, createDraftGenerationJob, STORY_TRACK_ID, isReferenceDescribed, isReferenceUsable, isVisualReference, projectFilePath, usableImageReferences, type GenerationJob, type ProjectAsset, type ProjectConfig, type ProjectReference, type TimelineClip, type TimelineTrack } from "../../lib/project";import { cancelVidfabGeneration, enqueueVidfabGeneration, resolveVidfabPlan, type VidfabGenerationRequest, type VidfabStatus } from "../../lib/runtime";interface GeneratorViewProps {@@ -146,8 +146,13 @@ export function GeneratorView({ config, folderPath, runtime = null, onChange, onconst now = new Date().toISOString();const existingAsset = config.assets.find((asset) => asset.relativePath === job.outputRelativePath);const asset: ProjectAsset = existingAsset ?? { id: `asset-${crypto.randomUUID()}`, kind: "generated", name: job.title, relativePath: job.outputRelativePath, mimeType: "video/mp4", durationMs: 6_000, createdAt: now };- const existingStory = config.timeline.tracks.find((track) => track.name === "Story");- const story: TimelineTrack = existingStory ?? { id: `track-${crypto.randomUUID()}`, kind: "video", name: "Story", locked: false, muted: false, clips: [] };+ /* By id first: tracks can be renamed, and matching on the name alone made+ a renamed story track invisible here — the next insert built a second+ "Story" track beside it. The name is the fallback for projects made+ before the id was fixed. */+ const existingStory = config.timeline.tracks.find((track) => track.id === STORY_TRACK_ID)+ ?? config.timeline.tracks.find((track) => track.kind === "video" && track.name === "Story");+ const story: TimelineTrack = existingStory ?? { id: STORY_TRACK_ID, kind: "video", name: "Story", locked: false, muted: false, clips: [] };if (story.locked) return;const startMs = story.clips.reduce((end, clip) => Math.max(end, clip.startMs + clip.durationMs), 0);const clip: TimelineClip = { id: `clip-${crypto.randomUUID()}`, assetId: asset.id, trackId: story.id, startMs, durationMs: asset.durationMs ?? 6_000, sourceStartMs: 0, label: job.title, color: "#4f6ba8", status: "generated" };diff --git a/src/components/workspace/MediaThumbnail.tsx b/src/components/workspace/MediaThumbnail.tsxnew file mode 100644index 0000000..6ab9f79--- /dev/null+++ b/src/components/workspace/MediaThumbnail.tsx@@ -0,0 +1,128 @@+import { Image as ImageIcon, Music2, TriangleAlert, Video } from "lucide-react";+import { useEffect, useState } from "react";+import { readProjectFileUrl } from "../../lib/persistence";+import type { ProjectAsset } from "../../lib/project";++/* A real picture of the media, not a striped placeholder.+ *+ * Project files live outside the webview's reach, so the bytes come back+ * through a Tauri command as a blob URL. That blob is the whole file — a+ * 300 MB clip is 300 MB of memory — so it is decoded ONCE, drawn into a small+ * canvas, and revoked immediately. What survives is a ~320px JPEG data URL,+ * which is what the panel actually shows.+ *+ * No FFmpeg and no WebCodecs here on purpose: the <video> element already owns+ * a hardware decoder, and one still frame is all this needs. */++const THUMB_WIDTH = 320;+/* Frame zero of a shot that fades in is a black rectangle, which reads as a+ broken thumbnail. Half a second in is past the fade and still cheap to seek. */+const POSTER_TIME_SECONDS = 0.5;++/* Switching panel tabs unmounts these, and re-decoding a folder of video every+ time would be felt. Bounded, because a data URL is small but not free. */+const POSTER_CACHE = new Map<string, string>();+const CACHE_LIMIT = 64;++function cachePoster(key: string, poster: string) {+ if (POSTER_CACHE.size >= CACHE_LIMIT) {+ const oldest = POSTER_CACHE.keys().next().value;+ if (oldest !== undefined) POSTER_CACHE.delete(oldest);+ }+ POSTER_CACHE.set(key, poster);+}++function drawPoster(source: CanvasImageSource, width: number, height: number): string {+ if (!width || !height) throw new Error("The frame has no size.");+ const canvas = document.createElement("canvas");+ const scale = Math.min(1, THUMB_WIDTH / width);+ canvas.width = Math.max(1, Math.round(width * scale));+ canvas.height = Math.max(1, Math.round(height * scale));+ const context = canvas.getContext("2d");+ if (!context) throw new Error("This computer gave no 2D canvas.");+ context.drawImage(source, 0, 0, canvas.width, canvas.height);+ return canvas.toDataURL("image/jpeg", 0.72);+}++const settled = (element: HTMLVideoElement, event: string) =>+ new Promise<void>((resolve, reject) => {+ element.addEventListener(event, () => resolve(), { once: true });+ element.addEventListener("error", () => reject(new Error("This file could not be decoded.")), { once: true });+ });++async function videoPoster(url: string): Promise<string> {+ const video = document.createElement("video");+ video.muted = true;+ video.preload = "auto";+ video.playsInline = true;+ video.src = url;+ await settled(video, "loadeddata");+ const target = Number.isFinite(video.duration) ? Math.min(video.duration / 2, POSTER_TIME_SECONDS) : 0;+ // A seek that never lands would leave the thumbnail loading forever; frame+ // zero is a perfectly good fallback, so a failure here is not fatal.+ if (target > 0) {+ const seeked = settled(video, "seeked");+ video.currentTime = target;+ await seeked.catch(() => undefined);+ }+ const poster = drawPoster(video, video.videoWidth, video.videoHeight);+ // Detach the source so the decoder and the blob are released now.+ video.removeAttribute("src");+ video.load();+ return poster;+}++async function imagePoster(url: string): Promise<string> {+ const image = new Image();+ image.src = url;+ await image.decode();+ return drawPoster(image, image.naturalWidth, image.naturalHeight);+}++export function MediaThumbnail({ folderPath, asset }: { folderPath: string; asset: ProjectAsset }) {+ const cacheKey = `${folderPath}::${asset.relativePath}`;+ const [poster, setPoster] = useState<string | null>(() => POSTER_CACHE.get(cacheKey) ?? null);+ const [failed, setFailed] = useState(false);++ useEffect(() => {+ // Sound has no picture, and a cached poster is already the answer.+ if (asset.kind === "audio" || POSTER_CACHE.has(cacheKey)) return;+ let live = true;+ setFailed(false);+ void (async () => {+ let url: string | null = null;+ try {+ url = await readProjectFileUrl(folderPath, asset.relativePath, asset.mimeType);+ // Browser preview: there is no project folder, so there is nothing to+ // show and nothing has gone wrong. The kind icon stands in.+ if (!url) return;+ const value = asset.kind === "image" ? await imagePoster(url) : await videoPoster(url);+ cachePoster(cacheKey, value);+ if (live) setPoster(value);+ } catch {+ if (live) setFailed(true);+ } finally {+ if (url) URL.revokeObjectURL(url);+ }+ })();+ return () => { live = false; };+ }, [cacheKey, folderPath, asset.relativePath, asset.mimeType, asset.kind]);++ if (poster) {+ return <span className="media-thumb media-thumb--poster">+ <img src={poster} alt={`First frames of ${asset.name}`} loading="lazy" />+ </span>;+ }+ /* Three states, said plainly: sound never has a picture, a file the project+ points at but cannot read is a problem worth seeing, and everything else+ is the placeholder that was always here. */+ const icon = asset.kind === "audio" ? <Music2 size={22} />+ : failed ? <TriangleAlert size={22} />+ : asset.kind === "image" ? <ImageIcon size={22} /> : <Video size={22} />;+ return <span+ className="media-thumb"+ role="img"+ aria-label={failed ? `${asset.name} — preview unavailable` : asset.name}+ title={failed ? "PolStudio couldn’t read this file to make a preview." : undefined}+ >{icon}</span>;+}diff --git a/src/components/workspace/TimelineView.tsx b/src/components/workspace/TimelineView.tsxindex a9a9ab4..5b479a0 100644--- a/src/components/workspace/TimelineView.tsx+++ b/src/components/workspace/TimelineView.tsx@@ -1,11 +1,13 @@import {- Copy, Film, Image as ImageIcon, Layers3, Lock, LockOpen, Music2,+ Copy, Film, Layers3, LayoutGrid, List, Lock, LockOpen, Music2,Pause, Play, Plus, Scissors, SkipBack, SkipForward, Trash2, Upload, Video,Volume2, VolumeX,} from "lucide-react";import { useEffect, useMemo, useRef, useState } from "react";import { importMediaFiles, isTauri } from "../../lib/persistence";+import { loadMediaLayout, saveMediaLayout, type MediaLayout } from "../../lib/settings";import type { ProjectAsset, ProjectConfig, TimelineClip } from "../../lib/project";+import { MediaThumbnail } from "./MediaThumbnail";const MIN_DURATION = 10_000;const NOT_YET = "Not available yet. This control doesn’t change your project.";@@ -50,6 +52,10 @@ export function TimelineView({ config, folderPath, onChange, onOpenGenerator }:const [playhead, setPlayhead] = useState(firstClip?.startMs ?? 0);const [playing, setPlaying] = useState(false);const [panelTab, setPanelTab] = useState<"scenes" | "media">("scenes");+ /* Grid reads a folder of footage by its pictures, list reads it by its+ names. Which one a cutter wants is a habit, not a per-project choice, so+ it is remembered on this machine rather than written into the project. */+ const [mediaLayout, setMediaLayout] = useState<MediaLayout>(loadMediaLayout);const timelineGrid = useRef<HTMLDivElement>(null);const [importing, setImporting] = useState(false);const [importError, setImportError] = useState<string | null>(null);@@ -106,7 +112,9 @@ export function TimelineView({ config, folderPath, onChange, onOpenGenerator }:return () => grid.removeEventListener("wheel", onWheel);}, [duration, config.settings.frameRate]);+ const chooseMediaLayout = (layout: MediaLayout) => { setMediaLayout(layout); saveMediaLayout(layout); };const updateTracks = (nextTracks: ProjectConfig["timeline"]["tracks"]) => onChange({ ...config, timeline: { tracks: nextTracks } });+ const renameTrack = (trackId: string, name: string) => updateTracks(tracks.map((track) => track.id === trackId ? { ...track, name } : track));const updateClip = (clipId: string, updates: Partial<TimelineClip>) => updateTracks(tracks.map((track) => ({ ...track, clips: track.clips.map((clip) => clip.id === clipId ? { ...clip, ...updates } : clip) })));const toggleTrack = (trackId: string, key: "muted" | "locked") => updateTracks(tracks.map((track) => track.id === trackId ? { ...track, [key]: !track[key] } : track));const removeSelected = () => {@@ -227,7 +235,25 @@ export function TimelineView({ config, folderPath, onChange, onOpenGenerator }:<button className={panelTab === "scenes" ? "active" : ""} onClick={() => setPanelTab("scenes")}><Layers3 size={16} /> Scenes</button><button className={panelTab === "media" ? "active" : ""} onClick={() => setPanelTab("media")}><Film size={16} /> Media</button></div>- <div className="scene-panel__head"><h2>{panelTab === "scenes" ? "Story sequence" : "Project media"}</h2></div>+ <div className="scene-panel__head">+ <h2>{panelTab === "scenes" ? "Story sequence" : "Project media"}</h2>+ {panelTab === "media" && (+ <div className="layout-toggle" role="group" aria-label="Media layout">+ <button+ className={mediaLayout === "grid" ? "active" : ""}+ aria-pressed={mediaLayout === "grid"}+ onClick={() => chooseMediaLayout("grid")}+ title="Show media as a grid of pictures"+ ><LayoutGrid size={16} /><span className="sr-only">Grid</span></button>+ <button+ className={mediaLayout === "list" ? "active" : ""}+ aria-pressed={mediaLayout === "list"}+ onClick={() => chooseMediaLayout("list")}+ title="Show media as a list"+ ><List size={16} /><span className="sr-only">List</span></button>+ </div>+ )}+ </div>{panelTab === "scenes" ? (<div className="scene-list">{sceneClips.map((clip, index) => (@@ -239,7 +265,7 @@ export function TimelineView({ config, folderPath, onChange, onOpenGenerator }:<button className="scene-add" onClick={addScene}><Plus size={18} /> Add or generate a scene</button></div>) : (- <div className="media-grid">+ <div className={`media-grid media-grid--${mediaLayout}`}>{/* Draggable onto the timeline. `draggable` on a <button> is thewhole mechanism — the button still clicks and still takesfocus, so keyboard users are not shut out of selecting it. */}@@ -254,7 +280,7 @@ export function TimelineView({ config, folderPath, onChange, onOpenGenerator }:onDragEnd={() => { setDraggedAsset(undefined); setDropTrackId(null); }}title={`${asset.name} — drag onto a ${asset.kind === "audio" ? "sound" : "video"} track below`}>- <span className="media-thumb">{asset.kind === "audio" ? <Music2 size={22} /> : asset.kind === "image" ? <ImageIcon size={22} /> : <Video size={22} />}</span>+ <MediaThumbnail folderPath={folderPath} asset={asset} /><b>{asset.name}</b>{/* Duration is only claimed when something actually measured it. */}<small>{asset.kind}{asset.durationMs ? ` · ${(asset.durationMs / 1000).toFixed(1)}s` : ""}</small>@@ -361,6 +387,7 @@ export function TimelineView({ config, folderPath, onChange, onOpenGenerator }:dropActive={dropTrackId === track.id}onSelect={setSelectedId}onToggle={toggleTrack}+ onRename={renameTrack}onDragOverLane={(event) => {if (!event.dataTransfer.types.includes(ASSET_DRAG_TYPE)) return;if (!acceptsAsset(track, draggedAsset)) return;@@ -375,7 +402,9 @@ export function TimelineView({ config, folderPath, onChange, onOpenGenerator }:const assetId = event.dataTransfer.getData(ASSET_DRAG_TYPE);if (!assetId) return;const rect = event.currentTarget.getBoundingClientRect();- dropAsset(track.id, assetId, (event.clientX - rect.left) / rect.width);+ // A zero-width lane would make the ratio NaN and the clip's start+ // time with it, which zod then refuses to save.+ dropAsset(track.id, assetId, rect.width > 0 ? (event.clientX - rect.left) / rect.width : 0);}}/>)}<div className="timeline-playhead" style={{ left: `calc(var(--track-column) + (100% - var(--track-column)) * ${playhead / duration})` }}><span /><i /></div>@@ -385,13 +414,14 @@ export function TimelineView({ config, folderPath, onChange, onOpenGenerator }:);}-function TrackRow({ track, duration, selectedId, dropActive, onSelect, onToggle, onDragOverLane, onDragLeaveLane, onDropLane }: {+function TrackRow({ track, duration, selectedId, dropActive, onSelect, onToggle, onRename, onDragOverLane, onDragLeaveLane, onDropLane }: {track: ProjectConfig["timeline"]["tracks"][number];duration: number;selectedId: string;dropActive: boolean;onSelect: (id: string) => void;onToggle: (id: string, key: "muted" | "locked") => void;+ onRename: (id: string, name: string) => void;onDragOverLane: (event: React.DragEvent<HTMLDivElement>) => void;onDragLeaveLane: () => void;onDropLane: (event: React.DragEvent<HTMLDivElement>) => void;@@ -399,7 +429,17 @@ function TrackRow({ track, duration, selectedId, dropActive, onSelect, onToggle,return <><div className="track-head"><span className={`track-kind track-kind--${track.kind}`}>{track.kind === "audio" ? <Music2 size={16} /> : <Video size={16} />}</span>- <div><b>{track.name}</b><small>{track.kind === "audio" ? "Audio" : "Video"}</small></div>+ {/* The name is an editable field, not a label: a project with three video+ layers needs the user's own words on them, and an always-live input+ needs no discovery. Blanking it falls back the way a clip name does,+ because the schema has no room for a nameless track. */}+ <div><input+ className="track-name"+ value={track.name}+ aria-label={`Rename ${track.name}`}+ title="Rename this track"+ onChange={(event) => onRename(track.id, event.target.value || "Untitled track")}+ /><small>{track.kind === "audio" ? "Audio" : "Video"}</small></div><button className={track.muted ? "active" : ""} onClick={() => onToggle(track.id, "muted")} aria-label={`${track.muted ? "Unmute" : "Mute"} ${track.name}`} title={`${track.muted ? "Unmute" : "Mute"} ${track.name}`}>{track.muted ? <VolumeX size={16} /> : <Volume2 size={16} />}</button><button className={track.locked ? "active" : ""} onClick={() => onToggle(track.id, "locked")} aria-label={`${track.locked ? "Unlock" : "Lock"} ${track.name}`} title={`${track.locked ? "Unlock" : "Lock"} ${track.name}`}>{track.locked ? <Lock size={16} /> : <LockOpen size={16} />}</button></div>diff --git a/src/lib/project.test.ts b/src/lib/project.test.tsindex 2bb02ab..e95e56f 100644--- a/src/lib/project.test.ts+++ b/src/lib/project.test.ts@@ -51,9 +51,10 @@ describe("project schema", () => {});expect(parseProjectConfig(project)).toEqual(project);expect(project.schemaVersion).toBe(1);- // Two video layers: an overlay or title card has to be able to sit above- // the story track without displacing the shot underneath it.- expect(project.timeline.tracks.map((track) => track.name)).toEqual(["Overlays", "Story", "Voice-over", "Music"]);+ // Three video layers: an overlay or title card has to be able to sit above+ // the story track, and B-roll below it, without displacing the shot the+ // story is made of.+ expect(project.timeline.tracks.map((track) => track.name)).toEqual(["Overlays", "Story", "B-roll", "Voice-over", "Music"]);expect(project.timeline.tracks.every((track) => track.clips.length === 0)).toBe(true);expect(project.references).toEqual([]);expect(project.generationJobs).toHaveLength(1);@@ -402,7 +403,7 @@ describe("project schema", () => {resolution: "4k",targetDurationSeconds: 34,}));- expect(project.timeline.tracks).toHaveLength(4);+ expect(project.timeline.tracks).toHaveLength(5);expect(project.generationJobs.some((job) => job.status === "generating")).toBe(true);expect(project.references.some((reference) => reference.kind === "image")).toBe(true);expect(project.assets.every((asset) => !asset.relativePath.match(/^([a-z]:|[/\\])/i))).toBe(true);diff --git a/src/lib/project.ts b/src/lib/project.tsindex c136048..c8900b7 100644--- a/src/lib/project.ts+++ b/src/lib/project.ts@@ -433,6 +433,12 @@ export function createDraftGenerationJob(});}+/* The track a generated shot lands on. Tracks are renameable, so the generator+ can no longer find this one by its name — an id survives a rename, and a+ project whose owner called it "Act one" must not grow a second Story track+ the next time a shot is inserted. */+export const STORY_TRACK_ID = "track-story";+export function createProjectConfig(input: CreateProjectInput): ProjectConfig {const now = new Date().toISOString();const brief = input.prompt.trim();@@ -449,12 +455,14 @@ export function createProjectConfig(input: CreateProjectInput): ProjectConfig {aspectRatio: input.aspectRatio, resolution: input.resolution,},assets: [],- /* Two video layers, not one: an overlay, a title card, or a cutaway has- to sit ABOVE the story track, and with a single layer the only way to- get one there was to displace the shot underneath it. */+ /* Three video layers, not one: an overlay, a title card, or a cutaway has+ to sit ABOVE the story track, and B-roll below it, and with a single+ layer the only way to get either there was to displace the shot the+ story is actually made of. */timeline: { tracks: [{ id: "track-overlay", kind: "video", name: "Overlays", locked: false, muted: false, clips: [] },- { id: "track-story", kind: "video", name: "Story", locked: false, muted: false, clips: [] },+ { id: STORY_TRACK_ID, kind: "video", name: "Story", locked: false, muted: false, clips: [] },+ { id: "track-b-roll", kind: "video", name: "B-roll", locked: false, muted: false, clips: [] },{ id: "track-voice-over", kind: "audio", name: "Voice-over", locked: false, muted: false, clips: [] },{ id: "track-music", kind: "audio", name: "Music", locked: false, muted: false, clips: [] },] },@@ -480,10 +488,10 @@ export function seedProjectWorkspace(config: ProjectConfig, seed = 0): ProjectCo{ id: "asset-voice", kind: "audio", name: "Mara voice-over", relativePath: "media/generated/voice-over.wav", mimeType: "audio/wav", durationMs: 32000, createdAt },];const videoClips: TimelineClip[] = [- { id: "clip-01", assetId: "asset-establishing", trackId: "track-v1", startMs: 0, durationMs: 7200, sourceStartMs: 0, label: "01 · A city still becoming", color: hues[0], status: "approved" },- { id: "clip-02", assetId: "asset-studio", trackId: "track-v1", startMs: 7200, durationMs: 8600, sourceStartMs: 0, label: "02 · From line to light", color: hues[1], status: "approved" },- { id: "clip-03", assetId: "asset-portrait", trackId: "track-v1", startMs: 15800, durationMs: 7600, sourceStartMs: 0, label: "03 · Designed for people", color: hues[2], status: "generated" },- { id: "clip-04", assetId: "asset-rooftop", trackId: "track-v1", startMs: 23400, durationMs: 8400, sourceStartMs: 0, label: "04 · Northern light", color: hues[0], status: "approved" },+ { id: "clip-01", assetId: "asset-establishing", trackId: STORY_TRACK_ID, startMs: 0, durationMs: 7200, sourceStartMs: 0, label: "01 · A city still becoming", color: hues[0], status: "approved" },+ { id: "clip-02", assetId: "asset-studio", trackId: STORY_TRACK_ID, startMs: 7200, durationMs: 8600, sourceStartMs: 0, label: "02 · From line to light", color: hues[1], status: "approved" },+ { id: "clip-03", assetId: "asset-portrait", trackId: STORY_TRACK_ID, startMs: 15800, durationMs: 7600, sourceStartMs: 0, label: "03 · Designed for people", color: hues[2], status: "generated" },+ { id: "clip-04", assetId: "asset-rooftop", trackId: STORY_TRACK_ID, startMs: 23400, durationMs: 8400, sourceStartMs: 0, label: "04 · Northern light", color: hues[0], status: "approved" },];const references: ProjectReference[] = [{ id: "ref-mara", kind: "text", name: "Mara · lead architect", description: "Calm, observant woman in her late 30s. Charcoal wool, precise gestures, quiet confidence. Keep facial features and wardrobe consistent.", content: "Calm, observant woman in her late 30s. Charcoal wool, precise gestures, quiet confidence.", intendedUse: ["character"], createdAt },@@ -506,7 +514,8 @@ export function seedProjectWorkspace(config: ProjectConfig, seed = 0): ProjectCoassets,timeline: { tracks: [{ id: "track-v2", kind: "video", name: "Overlays", locked: false, muted: false, clips: [] },- { id: "track-v1", kind: "video", name: "Story", locked: false, muted: false, clips: videoClips },+ { id: STORY_TRACK_ID, kind: "video", name: "Story", locked: false, muted: false, clips: videoClips },+ { id: "track-b-roll", kind: "video", name: "B-roll", locked: false, muted: false, clips: [] },{ id: "track-a1", kind: "audio", name: "Voice-over", locked: false, muted: false, clips: [{ id: "clip-voice", assetId: "asset-voice", trackId: "track-a1", startMs: 1800, durationMs: 28000, sourceStartMs: 0, label: "Mara · narration", color: "#3d817c", status: "approved" }] },{ id: "track-a2", kind: "audio", name: "Music", locked: false, muted: false, clips: [{ id: "clip-score", assetId: "asset-score", trackId: "track-a2", startMs: 0, durationMs: 34000, sourceStartMs: 0, label: "Glass & concrete", color: "#6b5790", status: "approved" }] },] },diff --git a/src/lib/settings.ts b/src/lib/settings.tsindex 225734a..a4f15ef 100644--- a/src/lib/settings.ts+++ b/src/lib/settings.ts@@ -127,3 +127,30 @@ export function saveAgentProvider(provider: ProviderId): void {/* Losing the preference costs a dropdown click next launch, nothing more. */}}++/* --- Panel layout ----------------------------------------------------------+ How the media panel lays its footage out. A working habit, not a property of+ any one project, so it lives beside the engine paths rather than in+ pols.json — a project file the user may copy to another machine should not+ carry one editor's panel preference with it. */++export type MediaLayout = "grid" | "list";++const MEDIA_LAYOUT_KEY = "polstudio.media-layout.v1";++export function loadMediaLayout(): MediaLayout {+ try {+ return localStorage.getItem(MEDIA_LAYOUT_KEY) === "list" ? "list" : "grid";+ } catch {+ return "grid";+ }+}++export function saveMediaLayout(layout: MediaLayout): void {+ try {+ localStorage.setItem(MEDIA_LAYOUT_KEY, layout);+ } catch {+ /* A full or disabled localStorage costs the preference, not the session:+ the panel still shows whatever was just chosen. */+ }+}diff --git a/src/styles/timeline.css b/src/styles/timeline.cssindex 4b9375b..fa7faae 100644--- a/src/styles/timeline.css+++ b/src/styles/timeline.css@@ -243,6 +243,40 @@background: rgba(60, 105, 239, 0.24);}+/* --- Panel layout toggle ---------------------------------------------------+ Grid or list for the media panel. Icon-only, so each button carries its name+ for screen readers in an .sr-only span. */++.layout-toggle {+ display: flex;+ gap: 2px;+ padding: 2px;+ border: 1px solid var(--line);+ border-radius: var(--radius-sm);+ background: var(--panel-2);+}++.layout-toggle button {+ width: var(--space-6);+ height: var(--space-6);+ display: grid;+ place-items: center;+ padding: 0;+ border: 0;+ border-radius: calc(var(--radius-sm) - 1px);+ color: var(--text-muted);+ background: none;+}++.layout-toggle button:hover {+ color: var(--text-secondary);+}++.layout-toggle button.active {+ color: var(--text-primary);+ background: var(--panel-3);+}+/* --- Media panel ----------------------------------------------------------- */.media-grid {@@ -321,10 +355,71 @@);}+/* A real frame from the file, drawn to fill the plate the placeholder used. */+.media-thumb--poster {+ padding: 0;+ background-image: none;+}++.media-thumb--poster img {+ width: 100%;+ height: 100%;+ display: block;+ object-fit: cover;+}+.media-grid button[draggable="true"] {cursor: grab;}+/* --- Media panel, list layout ---------------------------------------------+ One row per file: a small still on the left, name and kind beside it. Same+ buttons, same drag behaviour — only the shape changes. */++.media-grid--list {+ grid-template-columns: minmax(0, 1fr);+}++.media-grid--list button {+ display: grid;+ grid-template-columns: 72px minmax(0, 1fr);+ grid-template-rows: auto auto;+ align-content: center;+ column-gap: var(--space-2);+ padding: 0;+}++.media-grid--list .media-thumb {+ grid-row: 1 / 3;+ width: 72px;+ height: var(--space-7);+ border-right: 1px solid var(--line);+ border-bottom: 0;+}++.media-grid--list button b {+ align-self: end;+ margin-top: 0;+ padding-left: 0;+}++.media-grid--list button small {+ align-self: start;+ padding-left: 0;+}++.media-grid--list .media-import {+ min-height: var(--space-7);+ flex-direction: row;+ gap: var(--space-2);+ padding: 0 var(--space-2);+}++.media-grid--list .media-import b,+.media-grid--list .media-import small {+ width: auto;+}+.media-grid button[draggable="true"]:active {cursor: grabbing;}@@ -854,7 +949,7 @@background: #1c3939;}-.track-head b,+.track-head .track-name,.track-head small {display: block;overflow: hidden;@@ -862,11 +957,32 @@text-overflow: ellipsis;}-.track-head b {+/* An editable field that reads as the label it replaced until it is focused —+ a border around every track name would turn the head into a form. */+.track-head .track-name {+ width: 100%;+ min-width: 0;+ padding: 2px var(--space-1);+ margin-left: calc(var(--space-1) * -1);+ border: 1px solid transparent;+ border-radius: var(--radius-sm);color: var(--text-primary);+ background: none;+ font-family: inherit;font-size: var(--text-sm);font-weight: var(--weight-semibold);line-height: var(--leading-snug);+ text-overflow: ellipsis;+}++.track-head .track-name:hover {+ border-color: var(--line-strong);+}++.track-head .track-name:focus {+ outline: none;+ border-color: var(--accent-bright);+ background: var(--panel-2);}.track-head small {