Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Simplify project settings forms

Bittic92b7fd3bcec
diff --git a/docs/project-settings.md b/docs/project-settings.md
index 6fb4cec..45fe2dd 100644
--- a/docs/project-settings.md
+++ b/docs/project-settings.md
@@ -1,7 +1,7 @@
# Project settings
-New projects ask for a name, resolution, aspect ratio, and **Default Look**.
-There is no length to define up front: the timeline grows as clips are added.
+New projects ask for a name, resolution, aspect ratio, and **Look**.
+New projects start at 60 seconds, and the timeline grows as clips are added.
The default Look includes the same presets as the scene Look selector and a
**None** option. Scenes whose Look is **None** inherit the project Look; an
explicit scene Look takes priority. Project **None** leaves the existing prompt
@@ -9,12 +9,13 @@ style inference unchanged. The inherited Look is resolved for both prompt
preview and generation, so changing it also marks affected renders out of date.
Click the project name in the open workspace to change its name, resolution,
-aspect ratio, default Look, or target length. The popup opens with the current
+aspect ratio, or Look. Neither popup has a length control; saving project settings
+preserves the existing timeline length. The popup opens with the current
values. **Save changes** saves the project; closing
the popup or pressing Escape before saving discards the pending form edits.
Resolution and aspect ratio update both the project settings and its brief.
-Target length updates the brief. Dropping media or Generator scenes, moving
+Dropping media or Generator scenes, moving
clips, and extending clip trims automatically grow it to cover the latest clip
end, rounded up to whole seconds. Drops retain their chosen position even when
the clip is longer than the project. Moving clips left or removing them does
@@ -32,10 +33,7 @@ The AI agent can apply these settings with `project.set`:
Aspect ratios: `16:9`, `9:16`, `1:1`, `4:5`.
Resolution keys: `416p`, `544p`, `640p`, `768p`, `1088p`, `1344p`.
-Target length is a nonnegative whole number. The settings controls initially
-offer up to 600 seconds and expand to accommodate longer timelines. The slider
-uses one-second intervals through 60 seconds and ten-second intervals above
-that, with extra slider space for the first minute.
+The agent's target length is a nonnegative whole number.
Omit fields that should
stay unchanged. Changing scene lengths or timeline clips uses the separate
`scene.set` and `clip.set` commands.
diff --git a/src/App.test.tsx b/src/App.test.tsx
index 5fe234f..ea758d8 100644
--- a/src/App.test.tsx
+++ b/src/App.test.tsx
@@ -66,7 +66,7 @@ describe("project library controls", () => {
expect(screen.queryByLabelText("Length in seconds")).toBeNull();
expect(screen.queryByLabelText("Length slider")).toBeNull();
- const look = screen.getByRole("combobox", { name: "Default Look" });
+ const look = screen.getByRole("combobox", { name: "Look" });
expect(look).toHaveValue("");
fireEvent.change(look, { target: { value: "watercolor" } });
expect(look).toHaveValue("watercolor");
@@ -144,10 +144,9 @@ describe("project library controls", () => {
"416 × 736", "544 × 960", "640 × 1152", "768 × 1376 (default)", "1088 × 1920", "1344 × 2432",
]);
- // The settings header says the same numbers as the always-visible fields.
+ // The header stays short; the fields already show the selected format.
fireEvent.change(size, { target: { value: "544p" } });
- expect(document.querySelector(".composer__options-value")!.textContent)
- .toBe("Vertical 9:16 · 544 × 960");
+ expect(document.querySelector(".composer__options-head")).toHaveTextContent(/^Video settings$/);
});
it("opens a newly named empty project on its Agent starting page", async () => {
diff --git a/src/components/ProjectSettings.test.tsx b/src/components/ProjectSettings.test.tsx
index 463de33..f7e64dc 100644
--- a/src/components/ProjectSettings.test.tsx
+++ b/src/components/ProjectSettings.test.tsx
@@ -24,17 +24,16 @@ it("opens settings from the project name, saves both settings mirrors, and resto
expect(dialog.getByLabelText("Project name")).toHaveValue("Original");
expect(dialog.getByLabelText("Aspect Ratio")).toHaveValue("16:9");
expect(dialog.getByLabelText("Resolution")).toHaveValue("768p");
- expect(dialog.getByLabelText("Length in seconds")).toHaveValue(30);
+ expect(dialog.queryByLabelText("Length in seconds")).not.toBeInTheDocument();
fireEvent.change(dialog.getByLabelText("Project name"), { target: { value: "Updated" } });
fireEvent.change(dialog.getByLabelText("Aspect Ratio"), { target: { value: "9:16" } });
fireEvent.change(dialog.getByLabelText("Resolution"), { target: { value: "544p" } });
- fireEvent.change(dialog.getByLabelText("Length in seconds"), { target: { value: "90" } });
- fireEvent.change(dialog.getByLabelText("Default Look"), { target: { value: "watercolor" } });
+ fireEvent.change(dialog.getByLabelText("Look"), { target: { value: "watercolor" } });
fireEvent.click(dialog.getByRole("button", { name: "Save changes" }));
await waitFor(() => expect(screen.queryByRole("dialog", { name: "Project settings" })).not.toBeInTheDocument());
const saved = onSave.mock.calls[0][0].config;
expect(saved).toMatchObject({ name: "Updated", id: record.config.id,
- brief: { prompt: "Keep this brief", aspectRatio: "9:16", resolution: "544p", targetDurationSeconds: 90 },
+ brief: { prompt: "Keep this brief", aspectRatio: "9:16", resolution: "544p", targetDurationSeconds: 30 },
settings: { aspectRatio: "9:16", resolution: "544p", defaultLook: "watercolor" },
});
expect(saved.timeline).toEqual(record.config.timeline);
@@ -42,8 +41,8 @@ it("opens settings from the project name, saves both settings mirrors, and resto
expect(opener).toHaveFocus();
fireEvent.click(screen.getByRole("button", { name: "Edit project settings for Updated" }));
expect(screen.getByLabelText("Resolution")).toHaveValue("544p");
- expect(screen.getByLabelText("Length in seconds")).toHaveValue(90);
- expect(screen.getByLabelText("Default Look")).toHaveValue("watercolor");
+ expect(screen.queryByLabelText("Length in seconds")).not.toBeInTheDocument();
+ expect(screen.getByLabelText("Look")).toHaveValue("watercolor");
});
it("cancels pending edits with Escape without saving", () => {
@@ -62,11 +61,11 @@ it("keeps failed saves open for retry", async () => {
const onSave = vi.fn().mockRejectedValueOnce(new Error("Disk unavailable")).mockResolvedValue(undefined);
render(<ProjectWorkspace project={project()} initialView="references" onBack={vi.fn()} onSave={onSave} />);
fireEvent.click(screen.getByRole("button", { name: "Edit project settings for Original" }));
- fireEvent.change(screen.getByLabelText("Length in seconds"), { target: { value: "120" } });
+ fireEvent.change(screen.getByLabelText("Look"), { target: { value: "watercolor" } });
const dialog = within(screen.getByRole("dialog", { name: "Project settings" }));
fireEvent.click(dialog.getByRole("button", { name: "Save changes" }));
await waitFor(() => expect(dialog.getByRole("alert")).toHaveTextContent("Disk unavailable"));
- expect(dialog.getByLabelText("Length in seconds")).toHaveValue(120);
+ expect(dialog.getByLabelText("Look")).toHaveValue("watercolor");
fireEvent.click(dialog.getByRole("button", { name: "Save changes" }));
await waitFor(() => expect(screen.queryByRole("dialog", { name: "Project settings" })).not.toBeInTheDocument());
expect(onSave).toHaveBeenCalledTimes(2);
@@ -83,33 +82,15 @@ it("preserves legacy resolution and short project length when opening settings",
expect(onSubmit).toHaveBeenCalledWith(expect.objectContaining({ resolution: "1080p", targetDurationSeconds: 5 }));
});
-it("supports exact numeric lengths and the two slider intervals in project settings", () => {
- const onSubmit = vi.fn(async () => undefined);
- render(<PromptComposer project={project().config} busy={false} onClose={vi.fn()} onCreate={onSubmit} />);
- const slider = screen.getByRole("slider", { name: "Length slider" });
- const number = screen.getByRole("spinbutton", { name: "Length in seconds" });
- const save = screen.getByRole("button", { name: "Save changes" });
- for (const [position, seconds] of [[0, 0], [1, 1], [59, 59], [60, 60], [61, 70], [62, 80], [114, 600]]) {
- fireEvent.change(slider, { target: { value: String(position) } });
- expect(number).toHaveValue(seconds);
- expect(save).toBeEnabled();
- }
- fireEvent.change(number, { target: { value: "73" } });
- fireEvent.click(save);
- expect(onSubmit).toHaveBeenCalledWith(expect.objectContaining({ targetDurationSeconds: 73 }));
- for (const value of ["", "-1", "601", "3.5"]) {
- fireEvent.change(number, { target: { value } });
- expect(save).toBeDisabled();
- }
-});
-
-it.each(["", "claymation"])("creates a project with Look %s and an automatically sized timeline", (look) => {
+it.each(["", "claymation"])("creates a project with Look %s and a 60-second timeline", (look) => {
const onCreate = vi.fn(async (_input: CreateProjectInput) => {});
render(<PromptComposer busy={false} onClose={vi.fn()} onCreate={onCreate} />);
expect(screen.queryByLabelText("Length in seconds")).not.toBeInTheDocument();
- fireEvent.change(screen.getByLabelText("Default Look"), { target: { value: look } });
+ expect(screen.queryByRole("slider")).not.toBeInTheDocument();
+ expect(screen.queryByText("Used by scenes whose Look is set to None.")).not.toBeInTheDocument();
+ fireEvent.change(screen.getByLabelText("Look"), { target: { value: look } });
fireEvent.click(screen.getByRole("button", { name: "Create project" }));
- expect(onCreate).toHaveBeenCalledWith(expect.objectContaining({ defaultLook: look || null, targetDurationSeconds: 0 }));
+ expect(onCreate).toHaveBeenCalledWith(expect.objectContaining({ defaultLook: look || null, targetDurationSeconds: 60 }));
expect(createProjectConfig(onCreate.mock.calls[0][0]).settings.defaultLook ?? null).toBe(look || null);
});
@@ -119,7 +100,9 @@ it("preserves an automatically extended project and allows clearing its default
config.settings.defaultLook = "watercolor";
const onSubmit = vi.fn(async (_input: CreateProjectInput) => {});
render(<PromptComposer project={config} busy={false} onClose={vi.fn()} onCreate={onSubmit} />);
- fireEvent.change(screen.getByLabelText("Default Look"), { target: { value: "" } });
+ expect(screen.queryByRole("slider")).not.toBeInTheDocument();
+ expect(screen.queryByLabelText("Length in seconds")).not.toBeInTheDocument();
+ fireEvent.change(screen.getByLabelText("Look"), { target: { value: "" } });
fireEvent.click(screen.getByRole("button", { name: "Save changes" }));
expect(onSubmit).toHaveBeenCalledWith(expect.objectContaining({ targetDurationSeconds: 730, defaultLook: null }));
});
diff --git a/src/components/ProjectWorkspace.tsx b/src/components/ProjectWorkspace.tsx
index 9ba47ab..04fa257 100644
--- a/src/components/ProjectWorkspace.tsx
+++ b/src/components/ProjectWorkspace.tsx
@@ -87,7 +87,7 @@ export function ProjectWorkspace({ project, initialView = "timeline", runtime =
try {
session.update((current) => ({
...current, name: input.name,
- brief: { ...current.brief, aspectRatio: input.aspectRatio, resolution: input.resolution, targetDurationSeconds: input.targetDurationSeconds },
+ brief: { ...current.brief, aspectRatio: input.aspectRatio, resolution: input.resolution },
settings: { ...current.settings, aspectRatio: input.aspectRatio, resolution: input.resolution, defaultLook: input.defaultLook },
}));
await session.save();
diff --git a/src/components/PromptComposer.tsx b/src/components/PromptComposer.tsx
index e2db71f..562fbf5 100644
--- a/src/components/PromptComposer.tsx
+++ b/src/components/PromptComposer.tsx
@@ -1,6 +1,6 @@
-import { Clapperboard, Clock3, Monitor, Save, WandSparkles, X } from "lucide-react";
+import { Clapperboard, Monitor, Save, WandSparkles, X } from "lucide-react";
import { useEffect, useRef, useState } from "react";
-import { outputDimensions, resolutionLabel } from "../lib/export";
+import { outputDimensions } from "../lib/export";
import type { AspectRatio, CreateProjectInput, ProjectConfig, Resolution } from "../lib/project";
import { PROJECT_RESOLUTIONS } from "../lib/project";
import { SHOT_TAG_GROUPS } from "../lib/shot-tags";
@@ -13,39 +13,19 @@ interface PromptComposerProps {
error?: string | null;
}
-const aspectRatioLabels: Record<AspectRatio, string> = {
- "16:9": "Widescreen 16:9",
- "9:16": "Vertical 9:16",
- "1:1": "Square 1:1",
- "4:5": "Portrait 4:5",
-};
-
/* Chosen because it is the closest rung to the canvas slopfab actually plans a
16:9 scene onto (1344×768), so a project made without opening this panel is
not one that has to be rescaled the moment a scene is generated. */
const DEFAULT_RESOLUTION: Resolution = "768p";
const LOOKS = SHOT_TAG_GROUPS.find((group) => group.id === "visualStyle")!.options;
-const durationLabel = (seconds: number) => {
- if (seconds < 60) return `${seconds} seconds`;
- const minutes = Math.floor(seconds / 60);
- const remainder = seconds % 60;
- return `${minutes} ${minutes === 1 ? "minute" : "minutes"}${remainder ? ` ${remainder} seconds` : ""}`;
-};
-
export function PromptComposer({ busy, onCreate: onSubmit, onClose, project, error }: PromptComposerProps) {
const [name, setName] = useState(project?.name ?? "Untitled video");
const [aspectRatio, setAspectRatio] = useState<AspectRatio>(project?.settings.aspectRatio ?? "16:9");
const [resolution, setResolution] = useState<Resolution>(project?.settings.resolution ?? DEFAULT_RESOLUTION);
const [defaultLook, setDefaultLook] = useState(project?.settings.defaultLook ?? "");
- const [durationInput, setDurationInput] = useState(String(project?.brief.targetDurationSeconds ?? 0));
- const duration = Number(durationInput);
const dialog = useRef<HTMLDivElement>(null);
const nameInput = useRef<HTMLInputElement>(null);
- const maxDuration = Math.max(600, Math.ceil((project?.brief.targetDurationSeconds ?? 0) / 10) * 10);
- const validDuration = durationInput.trim() !== "" && Number.isInteger(duration) && duration >= 0 && duration <= maxDuration;
- const sliderMax = 60 + (maxDuration - 60) / 10;
- const sliderPosition = Math.max(0, Math.min(sliderMax, duration <= 60 ? duration : 60 + (duration - 60) / 10));
const resolutions: readonly Resolution[] = project && !PROJECT_RESOLUTIONS.some((value) => value === project.settings.resolution)
? [...PROJECT_RESOLUTIONS, project.settings.resolution] : PROJECT_RESOLUTIONS;
@@ -72,13 +52,13 @@ export function PromptComposer({ busy, onCreate: onSubmit, onClose, project, err
}, [busy, onClose]);
const submit = async () => {
- if (busy || !name.trim() || !validDuration) return;
+ if (busy || !name.trim()) return;
await onSubmit({
name: name.trim(),
prompt: project?.brief.prompt ?? "",
aspectRatio,
resolution,
- targetDurationSeconds: duration,
+ targetDurationSeconds: project?.brief.targetDurationSeconds ?? 60,
defaultLook: defaultLook || null,
});
};
@@ -99,7 +79,6 @@ export function PromptComposer({ busy, onCreate: onSubmit, onClose, project, err
<section className="composer__options">
<div className="composer__options-head">
<span className="composer__options-title">Video settings</span>
- <span className="composer__options-value">{aspectRatioLabels[aspectRatio]} · {resolutionLabel(resolution, aspectRatio)}</span>
</div>
<div className="composer__options-body">
<div className="composer__options-grid">
@@ -126,45 +105,19 @@ export function PromptComposer({ busy, onCreate: onSubmit, onClose, project, err
</select>
</label>
<label>
- <span>Default Look</span>
- <select aria-label="Default Look" disabled={busy} value={defaultLook} onChange={(event) => setDefaultLook(event.target.value)}>
+ <span>Look</span>
+ <select aria-label="Look" disabled={busy} value={defaultLook} onChange={(event) => setDefaultLook(event.target.value)}>
<option value="">None</option>
{LOOKS.map((look) => <option key={look.id} value={look.id}>{look.label}</option>)}
</select>
- <small>Used by scenes whose Look is set to None.</small>
</label>
- {project && <div className="composer__duration">
- <span>
- <Clock3 size={15} /> Length
- <output htmlFor="project-duration">{validDuration ? durationLabel(duration) : `Enter 0–${maxDuration} seconds`}</output>
- </span>
- <input id="project-duration" aria-label="Length in seconds" type="number" min={0} max={maxDuration} step={1} disabled={busy} value={durationInput} onChange={(event) => setDurationInput(event.target.value)} />
- <input
- aria-label="Length slider"
- aria-valuetext={durationLabel(duration)}
- aria-valuemin={0}
- aria-valuemax={maxDuration}
- aria-valuenow={validDuration ? duration : 0}
- type="range"
- min={0}
- disabled={busy}
- max={sliderMax}
- step={1}
- value={Number.isFinite(sliderPosition) ? sliderPosition : 0}
- onChange={(event) => {
- const position = Number(event.target.value);
- setDurationInput(String(position <= 60 ? position : 60 + (position - 60) * 10));
- }}
- />
- <small className="composer__duration-scale"><span>0 seconds</span><span>{durationLabel(maxDuration)}</span></small>
- </div>}
</div>
</div>
</section>
{error && <p role="alert">{error}</p>}
<div className="composer__actions">
- <button className="primary-button composer__submit" disabled={busy || !name.trim() || !validDuration} aria-busy={busy} onClick={() => void submit()}>
+ <button className="primary-button composer__submit" disabled={busy || !name.trim()} aria-busy={busy} onClick={() => void submit()}>
{busy ? <span className="spinner" /> : project ? <Save size={18} /> : <WandSparkles size={18} />}
{project ? "Save changes" : "Create project"}
</button>
diff --git a/src/styles/library.css b/src/styles/library.css
index f2b434a..ba07fea 100644
--- a/src/styles/library.css
+++ b/src/styles/library.css
@@ -210,13 +210,6 @@
color: var(--text-secondary);
}
-.composer__options-value {
- min-width: 0;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
.composer__options-body {
padding: var(--space-2) var(--space-5) var(--space-5);
}
@@ -227,15 +220,13 @@
gap: var(--space-4);
}
-.composer__options-grid label,
-.composer__duration {
+.composer__options-grid label {
display: grid;
gap: var(--space-2);
min-width: 0;
}
-.composer__options-grid label > span,
-.composer__duration > span {
+.composer__options-grid label > span {
display: flex;
align-items: center;
gap: var(--space-2);
@@ -267,30 +258,6 @@
font-size: var(--text-2xs);
}
-.composer__duration > span output {
- margin-left: auto;
- color: var(--text-secondary);
- font-weight: var(--weight-semibold);
-}
-
-.composer__options-grid .composer__duration input[type="range"] {
- height: var(--field-height);
- padding: 0;
- border: 0;
- background: transparent;
- accent-color: var(--accent-bright);
- cursor: pointer;
-}
-
-.composer__options-grid .composer__duration input[type="range"]:hover {
- border: 0;
-}
-
-.composer__duration-scale {
- display: flex;
- justify-content: space-between;
-}
-
/* --- Composer action bar --------------------------------------------------- */
.composer__actions {