AI media harness for planning, generating, and editing locally
TypeScript
Honest generation preview and no dead-end render
Bitticfd3a16eccee
diff --git a/src/components/workspace/GeneratorView.tsx b/src/components/workspace/GeneratorView.tsxindex 22c5ad1..1aa951b 100644--- a/src/components/workspace/GeneratorView.tsx+++ b/src/components/workspace/GeneratorView.tsx@@ -1,5 +1,5 @@import { listen } from "@tauri-apps/api/event";-import { AlertCircle, Ban, Check, ChevronRight, Clock3, Film, LoaderCircle, Play, RefreshCw, Sparkles, Square, WandSparkles, X } from "lucide-react";+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 { createDraftGenerationJob, type GenerationJob, type ProjectAsset, type ProjectConfig, type TimelineClip, type TimelineTrack } from "../../lib/project";@@ -19,6 +19,7 @@ export function GeneratorView({ config, runtime = null, onChange, onOpenTimelineconst [selectedId, setSelectedId] = useState(selectedJobId ?? config.generationJobs.find((job) => job.status === "generating")?.id ?? config.generationJobs[0]?.id);const [prompt, setPrompt] = useState("");const [planNotes, setPlanNotes] = useState<Record<string, string>>({});+ const composerRef = useRef<HTMLTextAreaElement | null>(null);const configRef = useRef(config);configRef.current = config;const jobs = config.generationJobs;@@ -117,13 +118,22 @@ export function GeneratorView({ config, runtime = null, onChange, onOpenTimelineonOpenTimeline();};+ // "Keep drafting other shots" has to be a real control, not advice, so the+ // ready state always has somewhere to go.+ const focusComposer = () => {+ const node = composerRef.current;+ if (!node) return;+ if (typeof node.scrollIntoView === "function") node.scrollIntoView({ block: "center" });+ node.focus();+ };+const cancelJob = (job: GenerationJob) => {if (job.status === "generating" || job.status === "queued") void cancelVidfabGeneration(job.id);updateJob(job.id, { status: "cancelled", stage: "failed", updatedAt: new Date().toISOString() });};return <div className="generator-view">- <aside className="queue-panel">+ <aside className="queue-panel" aria-label="Your shots"><div className="queue-panel__title"><span>Your shots</span><b>{queueSummary(active.length, queued.length, jobs.length)}</b>@@ -135,10 +145,12 @@ export function GeneratorView({ config, runtime = null, onChange, onOpenTimeline<QueueGroup title="Already run" jobs={completed} selectedId={selectedId} onSelect={setSelectedId} />{jobs.length === 0 && <p className="queue-empty">No shots yet. Describe one in the box on the right and it will appear here.</p>}</div>+ {/* The pill is the last thing a user reads before committing to a render,+ so the "frames, not a video file" limit is disclosed here too. */}<div className={`queue-runtime queue-runtime--${runtime?.state ?? "checking"}`}><span className="queue-runtime__state"><i /> {runtimeHeadline(runtime)}</span><p>{runtimeExplainer(runtime)}</p>- {!runtimeReady && <small>You can still write and save shot drafts.</small>}+ <small>{runtimeReady ? "A finished shot stays as frames — saving a video file isn’t built yet." : "You can still write and save shot drafts."}</small></div></aside>@@ -156,6 +168,7 @@ export function GeneratorView({ config, runtime = null, onChange, onOpenTimeline<label className="generation-composer__field"><span className="generation-composer__label"><Sparkles size={17} /> Describe the shot you want</span><textarea+ ref={composerRef}value={prompt}onChange={(event) => setPrompt(event.target.value)}placeholder="Example: a close shot of hands shaping wet clay on a spinning wheel, warm window light, the camera pushes in slowly, quiet room tone."@@ -173,6 +186,11 @@ export function GeneratorView({ config, runtime = null, onChange, onOpenTimeline<WandSparkles size={17} /> {submitLabel}</button></div>+ {/* Disclosed at the point of commitment, not after an expensive run. */}+ {runtimeReady && <p className="generation-composer__limit">+ <Info size={16} />+ <span>A finished shot renders frames into memory. Pol Studio can’t save them as a video file yet, so nothing lands in your project folder and there is nothing to add to the timeline.</span>+ </p>}<p className="generation-composer__hint">{runtimeReady? "Shots render one at a time, so a new shot joins the queue behind anything already running."@@ -185,11 +203,13 @@ export function GeneratorView({ config, runtime = null, onChange, onOpenTimeline{selected ? <section className="job-detail"><div className="job-detail__visual">+ {/* A labelled placeholder, never invented art — the same rule the scene+ thumb, media thumb and reference cards follow. Pol Studio cannot+ display real frames yet, so it shows none. */}<div className={`generation-preview generation-preview--${selected.status}`}>- <span className="generation-preview__flare" />- <div className="generation-preview__model"><i /><i /><i /><i /></div>- {selected.status === "generating" && <div className="generation-scanner" />}+ {selected.status === "generating" && <span className="generation-scanner" aria-hidden="true" />}<span className="preview-status">{previewStatus(selected)}</span>+ <p className="generation-preview__caption">{previewCaption(selected)}</p></div><div className="job-progress-block"><div className="job-progress-block__head">@@ -270,11 +290,20 @@ export function GeneratorView({ config, runtime = null, onChange, onOpenTimeline{!runtimeReady && <p className="job-actions__note">Pol Studio needs a working video engine before it can run this shot again.</p>}</>}- {selected.status === "ready" && <div className="job-actions__blocked">- <b>There is nothing to open yet</b>- <p>The frames and sound were rendered and are held in memory, but Pol Studio can’t package them into a video file yet — that step isn’t built. Nothing was written to your project folder.</p>- <small>Keep drafting other shots in the meantime.</small>- </div>}+ {selected.status === "ready" && <>+ <div className="job-actions__blocked">+ <b>There is nothing to open yet</b>+ <p>The frames and sound were rendered and are held in memory, but Pol Studio can’t package them into a video file yet — that step isn’t built. Nothing was written to your project folder.</p>+ </div>+ <div className="job-actions__choices">+ <button className="primary-button" disabled={!runtimeReady} onClick={() => void prepareOrRetry(selected)}>+ <RefreshCw size={15} /> {runtimeReady ? "Run this shot again" : "Can’t run it again yet"}+ </button>+ <button className="secondary-button" onClick={focusComposer}>+ <Sparkles size={15} /> Write another shot+ </button>+ </div>+ </>}{selected.status === "completed" && selected.outputRelativePath && !selected.clipId && <button className="primary-button" onClick={() => insertIntoStory(selected)}><Play size={15} /> Insert into Story</button>}@@ -302,10 +331,14 @@ export function GeneratorView({ config, runtime = null, onChange, onOpenTimeline</div>;}+/* The rail sits before the <h1> in the DOM, so its group titles are labelled+ groups rather than headings — otherwise the document outline would start+ mid-tree with an <h3>. */function QueueGroup({ title, jobs, selectedId, onSelect }: { title: string; jobs: GenerationJob[]; selectedId?: string; onSelect: (id: string) => void }) {if (jobs.length === 0) return null;- return <section className="queue-group">- <h3>{title}<span>{jobs.length}</span></h3>+ const labelId = `queue-group-${title.toLowerCase().replace(/[^a-z0-9]+/g, "-")}`;+ return <section className="queue-group" role="group" aria-labelledby={labelId}>+ <p className="queue-group__label" id={labelId}>{title}<span>{jobs.length}</span></p>{jobs.map((job) => <button key={job.id} className={selectedId === job.id ? "selected" : ""} onClick={() => onSelect(job.id)}><span className={`queue-thumb queue-thumb--${job.status}`}>{statusIcon(job.status)}</span><span className="queue-row__text">@@ -401,6 +434,20 @@ const previewStatus = (job: GenerationJob) => {}};+/* Says out loud why the placeholder is empty, so the blank surface is never+ read as "the picture failed to load". */+const previewCaption = (job: GenerationJob): string => {+ switch (job.status) {+ case "generating": return "Frames are being built now. Pol Studio can’t show them while they are still in memory.";+ case "queued": return "This shot hasn’t started, so there is no picture to show.";+ case "draft": return "Nothing has been rendered, so there is no picture to show.";+ case "ready": return "The frames exist in memory only. Pol Studio can’t display or save them yet.";+ case "completed": return job.outputRelativePath ? "A video file was saved. Open it in the timeline to watch it." : "This run ended without a video file, so there is no picture to show.";+ case "failed": return "The run stopped before any frames were kept.";+ case "cancelled": return "You stopped this run, so no frames were kept.";+ }+};+const runtimeHeadline = (runtime: VidfabStatus | null) => {if (!runtime) return "Checking for the video engine…";switch (runtime.state) {diff --git a/src/styles/generator.css b/src/styles/generator.cssindex c203277..c1ed12b 100644--- a/src/styles/generator.css+++ b/src/styles/generator.css@@ -17,6 +17,7 @@/* --- Queue rail ------------------------------------------------------------ */.queue-panel {+ min-width: 0;min-height: 0;display: flex;flex-direction: column;@@ -68,7 +69,9 @@padding: var(--space-4) var(--space-3) 0;}-.queue-group h3 {+/* Not a heading: the rail precedes the page <h1> in the DOM, so these are+ labelled groups. See QueueGroup in GeneratorView.tsx. */+.queue-group__label {display: flex;align-items: center;justify-content: space-between;@@ -83,7 +86,7 @@text-transform: none;}-.queue-group h3 span {+.queue-group__label span {min-width: var(--space-5);padding: 0 var(--space-2);border-radius: var(--radius-pill);@@ -287,6 +290,7 @@/* --- Main column ----------------------------------------------------------- */.generator-main {+ min-width: 0;min-height: 0;overflow-y: auto;padding: var(--space-6) var(--space-7) var(--space-8);@@ -394,6 +398,30 @@font-size: var(--text-base);}+/* Expectation-setting, not an alarm: sits directly under the generate button+ so the limit is known before an expensive render, never after it. */++.generation-composer__limit {+ display: flex;+ align-items: flex-start;+ gap: var(--space-2);+ max-width: 78ch;+ margin: var(--space-4) 0 0;+ padding: var(--space-3) var(--space-4);+ border: 1px solid var(--line);+ border-radius: var(--radius-md);+ color: var(--text-secondary);+ background: var(--panel);+ font-size: var(--text-sm);+ line-height: var(--leading-normal);+}++.generation-composer__limit svg {+ flex: 0 0 auto;+ margin-top: 2px;+ color: var(--text-muted);+}+.generation-composer__hint {max-width: 78ch;margin: var(--space-4) 0 0;@@ -462,57 +490,45 @@border-right: 1px solid var(--line);}+/* Same rule as the scene thumb, the media thumb and the reference card: a+ labelled placeholder, never invented art. Pol Studio cannot display a+ rendered frame yet, so this surface must never imply one exists. The state+ chip and the caption below it are the only content. */+.generation-preview {position: relative;- height: 340px;+ min-height: 200px;+ display: flex;+ flex-direction: column;+ align-items: center;+ justify-content: center;+ gap: var(--space-3);+ padding: var(--space-5);overflow: hidden;+ text-align: center;border: 1px solid var(--line-strong);border-radius: var(--radius-lg);- background: linear-gradient(150deg, #26374f 0 48%, #ca8b60 49% 51%, #171c24 52%);-}--.generation-preview__flare {- position: absolute;- width: 250px;- height: 250px;- right: -80px;- top: -110px;- border-radius: 50%;- background: rgba(239, 177, 117, 0.27);- filter: blur(25px);+ background-color: var(--panel-3);+ background-image: repeating-linear-gradient(+ 135deg,+ rgba(255, 255, 255, 0.03) 0 6px,+ transparent 6px 12px+ );}-.generation-preview__model {- position: absolute;- inset: 18% 12% 0 30%;- display: flex;- align-items: flex-end;- gap: 5px;- transform: perspective(500px) rotateY(-12deg);-}--.generation-preview__model i {- flex: 1;- height: 70%;- background: linear-gradient(90deg, #101722, #747c87 20%, #b77d5d 23%, #1d2530 27%);-}--.generation-preview__model i:nth-child(2) { height: 100%; }-.generation-preview__model i:nth-child(3) { height: 84%; }-.generation-preview__model i:nth-child(4) { height: 55%; }+/* Activity indicator only, and only while rendering — a soft band travelling+ over the hatch, never anything that could be mistaken for picture. */.generation-scanner {position: absolute;inset: -40% 0 auto;- height: 50%;- background: linear-gradient(transparent, rgba(145, 168, 255, 0.15), transparent);+ height: 40%;+ background: linear-gradient(transparent, color-mix(in srgb, var(--accent-bright) 14%, transparent), transparent);animation: scan 2.5s ease-in-out infinite;}.preview-status {- position: absolute;- left: var(--space-3);- bottom: var(--space-3);+ position: relative;min-height: var(--control-sm);display: inline-flex;align-items: center;@@ -521,8 +537,7 @@border: 1px solid var(--line-strong);border-radius: var(--radius-md);color: var(--text-primary);- background: rgba(9, 12, 18, 0.82);- backdrop-filter: blur(6px);+ background: var(--panel);font-size: var(--text-sm);font-weight: var(--weight-medium);line-height: var(--leading-snug);@@ -533,6 +548,15 @@color: var(--accent-bright);}+.generation-preview__caption {+ position: relative;+ max-width: 48ch;+ margin: 0;+ color: var(--text-muted);+ font-size: var(--text-sm);+ line-height: var(--leading-normal);+}+.generation-preview--generating .preview-status svg {animation: spin 1.4s linear infinite;}@@ -552,6 +576,12 @@color: var(--text-muted);}+@media (prefers-reduced-motion: reduce) {+ .generation-scanner {+ display: none;+ }+}+/* --- Progress block -------------------------------------------------------- */.job-progress-block {@@ -844,6 +874,21 @@font-size: var(--text-base);}+.job-actions .secondary-button {+ width: 100%;+ min-height: var(--control-md);+ font-size: var(--text-base);+}++/* The states that cannot produce a file still get real controls, so the user+ is never left with prose and no way forward. */++.job-actions__choices {+ display: grid;+ gap: var(--space-3);+ margin-top: var(--space-4);+}+.job-actions .primary-button:disabled {cursor: not-allowed;color: var(--text-muted);@@ -884,14 +929,6 @@line-height: var(--leading-normal);}-.job-actions__blocked small {- display: block;- margin-top: var(--space-3);- color: var(--text-muted);- font-size: var(--text-xs);- line-height: var(--leading-normal);-}-/* --- Empty state ----------------------------------------------------------- */.job-empty {@@ -963,7 +1000,11 @@background: var(--accent-bright);}-/* --- Responsive ------------------------------------------------------------ */+/* --- Responsive -------------------------------------------------------------+ The window can be resized down to 900px (tauri.conf.json minWidth), so the+ 320px rail + main column has to keep working the whole way down without a+ horizontal scrollbar. The rail narrows in two steps and the job detail is+ already single-column well before 1180px. */@media (max-width: 1280px) {.job-detail {@@ -999,3 +1040,65 @@width: 100%;}}++@media (max-width: 1040px) {+ .generator-view {+ grid-template-columns: 256px minmax(0, 1fr);+ }++ .generator-main {+ padding: var(--space-5) var(--space-4) var(--space-7);+ }++ .generation-composer {+ padding: var(--space-4);+ }++ .job-detail__visual,+ .job-detail__info {+ padding: var(--space-4);+ }++ .stage-rail {+ gap: var(--space-2) var(--space-4);+ }++ .stage-rail__blocked {+ margin-left: 0;+ }+}++@media (max-width: 960px) {+ .generator-view {+ grid-template-columns: 228px minmax(0, 1fr);+ }++ .queue-panel__title,+ .queue-runtime {+ padding: var(--space-3);+ }++ .queue-group {+ padding-inline: var(--space-2);+ }++ .queue-group > button {+ grid-template-columns: 40px minmax(0, 1fr) 16px;+ gap: var(--space-2);+ padding-inline: var(--space-2);+ }++ .queue-thumb {+ width: 40px;+ height: 40px;+ }++ .job-meta {+ grid-template-columns: minmax(0, 1fr);+ gap: var(--space-3);+ }++ .generation-preview {+ padding: var(--space-4);+ }+}