Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Tick references on and off a shot

Bitti96e50d241182
diff --git a/src/components/ProjectWorkspace.test.ts b/src/components/ProjectWorkspace.test.ts
index 66d1898..2e46804 100644
--- a/src/components/ProjectWorkspace.test.ts
+++ b/src/components/ProjectWorkspace.test.ts
@@ -198,6 +198,38 @@ describe("project workspace timecode", () => {
expect(screen.getByText(/sound note/)).not.toBeNull();
});
+ it("links and unlinks a reference to the selected shot", () => {
+ const fresh = createProjectConfig({ name: "Ceramic lamp", prompt: "A quiet product film", aspectRatio: "16:9", resolution: "1080p", targetDurationSeconds: 30 });
+ const createdAt = fresh.createdAt;
+ const references = [
+ { id: "ref-lamp", kind: "text", name: "Lamp silhouette", description: "Matte cream ceramic, tapered neck.", content: "Matte cream ceramic, tapered neck.", intendedUse: ["product"], createdAt },
+ { id: "ref-light", kind: "text", name: "Window light", description: "Soft north light, long shadows.", content: "Soft north light, long shadows.", intendedUse: ["style"], createdAt },
+ ];
+ const config = parseProjectConfig({ ...fresh, references, generationJobs: [{ ...fresh.generationJobs[0], referenceIds: ["ref-lamp"] }] });
+ const onChange = vi.fn();
+ render(createElement(GeneratorView, { config, folderPath: "C:\Ceramic Lamp", onChange, onOpenTimeline: () => undefined, selectedJobId: config.generationJobs[0].id }));
+
+ // Every reference in the project is offered, bound or not.
+ const lamp = screen.getByRole("checkbox", { name: /Lamp silhouette/ }) as HTMLInputElement;
+ const light = screen.getByRole("checkbox", { name: /Window light/ }) as HTMLInputElement;
+ expect(lamp.checked).toBe(true);
+ expect(light.checked).toBe(false);
+
+ fireEvent.click(light);
+ expect(onChange.mock.calls[0][0].generationJobs[0].referenceIds).toEqual(["ref-lamp", "ref-light"]);
+
+ fireEvent.click(lamp);
+ expect(onChange.mock.calls[1][0].generationJobs[0].referenceIds).toEqual([]);
+ });
+
+ it("locks a running shot’s references, because the engine already has them", () => {
+ const fresh = createProjectConfig({ name: "Ceramic lamp", prompt: "A quiet product film", aspectRatio: "16:9", resolution: "1080p", targetDurationSeconds: 30 });
+ const references = [{ id: "ref-lamp", kind: "text", name: "Lamp silhouette", description: "Matte cream ceramic.", content: "Matte cream ceramic.", intendedUse: ["product"], createdAt: fresh.createdAt }];
+ const config = parseProjectConfig({ ...fresh, references, generationJobs: [{ ...fresh.generationJobs[0], status: "generating", stage: "generating", progress: 0.4, referenceIds: ["ref-lamp"] }] });
+ render(createElement(GeneratorView, { config, folderPath: "C:\Ceramic Lamp", onChange: () => undefined, onOpenTimeline: () => undefined, selectedJobId: config.generationJobs[0].id }));
+ expect((screen.getByRole("checkbox", { name: /Lamp silhouette/ }) as HTMLInputElement).disabled).toBe(true);
+ });
+
it("tells the user the engine only follows the words when every bound reference is skipped", () => {
const fresh = createProjectConfig({ name: "Ceramic lamp", prompt: "A quiet product film", aspectRatio: "16:9", resolution: "1080p", targetDurationSeconds: 30 });
const references = [{ id: "ref-blank", kind: "text", name: "Lead character", description: "", content: null, intendedUse: ["character"], createdAt: fresh.createdAt }];
diff --git a/src/components/workspace/GeneratorView.tsx b/src/components/workspace/GeneratorView.tsx
index 647b258..53af9a3 100644
--- a/src/components/workspace/GeneratorView.tsx
+++ b/src/components/workspace/GeneratorView.tsx
@@ -37,6 +37,10 @@ export function GeneratorView({ config, folderPath, runtime = null, onChange, on
const queued = jobs.filter((job) => job.status === "queued");
const drafts = jobs.filter((job) => job.status === "draft");
const completed = jobs.filter((job) => ["ready", "completed", "failed", "cancelled"].includes(job.status));
+ // Queued and generating shots have already been handed to the engine with
+ // their references attached; re-binding now would change nothing about that
+ // run while claiming otherwise.
+ const refsLocked = selected?.status === "generating" || selected?.status === "queued";
const boundRefs = useMemo(() => config.references.filter((ref) => selected?.referenceIds.includes(ref.id)), [config.references, selected]);
// Bound is not the same as used. compileMiniMaxH3Prompt drops a reference that
// isn't described yet, and isVisualReference drops an audio-only one, so a
@@ -170,6 +174,16 @@ export function GeneratorView({ config, folderPath, runtime = null, onChange, on
node.focus();
};
+ /* Binding order does not matter: requestFor and the compiler both read
+ config.references in list order and keep whatever this job names, so the
+ <Picture N> numbering stays in lockstep however the boxes are ticked. */
+ const toggleReference = (job: GenerationJob, referenceId: string) => {
+ const referenceIds = job.referenceIds.includes(referenceId)
+ ? job.referenceIds.filter((id) => id !== referenceId)
+ : [...job.referenceIds, referenceId];
+ updateJob(job.id, { referenceIds, updatedAt: new Date().toISOString() });
+ };
+
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() });
@@ -277,23 +291,37 @@ export function GeneratorView({ config, folderPath, runtime = null, onChange, on
<div className="job-refs">
<span>{promptRefs.length === 0 ? "No references used by this shot" : promptRefs.length === 1 ? "1 reference guides this shot" : `${promptRefs.length} references guide this shot`}</span>
- {/* A bound reference the prompt skips is still listed — hiding it
- would leave the user wondering where their reference went. */}
- {boundRefs.map((ref, index) => {
+ {/* Every reference in the project, each a checkbox: which ones steer
+ a shot is the user's decision, and until now the two that were
+ bound when the draft was written were the two it kept forever.
+ A bound reference the prompt skips stays listed with its reason —
+ hiding it would leave the user wondering where it went. */}
+ {config.references.map((ref, index) => {
+ const bound = selected.referenceIds.includes(ref.id);
const skipped = skipReason(ref);
- return <div key={ref.id}>
+ return <label key={ref.id} className={`job-ref ${bound ? "job-ref--bound" : ""}`}>
+ <input
+ type="checkbox"
+ checked={bound}
+ disabled={refsLocked}
+ onChange={() => toggleReference(selected, ref.id)}
+ />
<i className={`ref-mini ref-mini--${index}`} />
<b>{ref.name}</b>
{skipped
? <p className="job-refs__reason">{skipped}</p>
- : !isReferenceDescribed(ref)
+ : bound && !isReferenceDescribed(ref)
// Used, but incomplete: the picture goes to the engine while
// nothing tells it what to keep. Silence here let a
// boilerplate-filled card look finished.
? <p className="job-refs__reason">Not described yet — the picture is sent, but nothing tells the engine what to keep.</p>
: ref.intendedUse.length > 0 && <small>Your tags: {ref.intendedUse.join(", ")}</small>}
- </div>;
+ </label>;
})}
+ {config.references.length === 0 && <p className="job-refs__empty">This project has no references yet. Add one under References and it can steer this shot.</p>}
+ {/* The request was already handed to the engine, so a change here
+ would say it steered a render it never touched. */}
+ {refsLocked && <p className="job-refs__empty">This shot is already with the engine. Its references can be changed once it finishes, and the next run will use them.</p>}
{promptRefs.length === 0
? <p className="job-refs__empty">The video engine only follows the words above.</p>
: <p className="job-refs__empty">{referenceRouting(promptRefs)} The tags are your own notes and don’t change what is sent.</p>}
diff --git a/src/styles/generator.css b/src/styles/generator.css
index f4f4504..9f49224 100644
--- a/src/styles/generator.css
+++ b/src/styles/generator.css
@@ -845,12 +845,37 @@
line-height: var(--leading-normal);
}
-.job-refs > div {
+/* One row per project reference: its tick box, its swatch, its name and
+ whatever the compiler will or won't do with it. */
+.job-ref {
display: grid;
- grid-template-columns: 44px minmax(0, 1fr);
- column-gap: var(--space-3);
+ grid-template-columns: auto 44px minmax(0, 1fr);
+ column-gap: var(--space-2);
align-items: center;
- margin-top: var(--space-3);
+ margin: var(--space-2) calc(var(--space-2) * -1) 0;
+ padding: var(--space-1) var(--space-2);
+ border-radius: var(--radius-sm);
+ cursor: pointer;
+}
+
+.job-ref:hover {
+ background: var(--panel-2);
+}
+
+.job-ref--bound {
+ background: var(--accent-soft);
+}
+
+.job-ref input {
+ grid-row: 1 / 3;
+ width: 15px;
+ height: 15px;
+ margin: 0 var(--space-1) 0 0;
+ accent-color: var(--accent-bright);
+}
+
+.job-ref:has(input:disabled) {
+ cursor: default;
}
.job-refs .ref-mini {