Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Key timeline edits for undo coalescing and tighten monitor copy

Bitti29accda79c91
diff --git a/src/components/workspace/ClipEffects.tsx b/src/components/workspace/ClipEffects.tsx
index 607f36b..32ee054 100644
--- a/src/components/workspace/ClipEffects.tsx
+++ b/src/components/workspace/ClipEffects.tsx
@@ -8,7 +8,10 @@ import { ComboBox, Flyout, PropRow, Slider, tooltipProps, useContextMenu } from
import { ColorSwatch } from "./ColorPicker";
type EffectId = "look" | "transition" | "chromaKey" | "sharpen" | "blur" | "colorCorrection" | "vignette" | "lut";
-type EditorProps = { clip: TimelineClip; update: (patch: Partial<TimelineClip>) => void; disabled: boolean };
+/** `key` names a run of edits to one parameter (a slider drag), so the
+ * project's undo stack folds it into one step. */
+type Update = (patch: Partial<TimelineClip>, key?: string) => void;
+type EditorProps = { clip: TimelineClip; update: Update; disabled: boolean };
type EffectDefinition = {
id: EffectId;
name: string;
@@ -177,10 +180,13 @@ const EFFECTS: readonly EffectDefinition[] = [
settings carry no "enabled" flag in the project schema yet. */
function EffectBlock({ effect, clip, disabled, update, onRemove }: {
effect: EffectDefinition; clip: TimelineClip; disabled: boolean;
- update: (patch: Partial<TimelineClip>) => void; onRemove: () => void;
+ update: Update; onRemove: () => void;
}) {
const [open, setOpen] = useState(true);
const more = useRef<HTMLButtonElement>(null);
+ /* Every parameter edit of this effect shares one undo key, so a slider drag
+ is one step rather than sixty. */
+ const keyed: Update = (patch, key) => update(patch, key ?? effect.id);
const menu = useContextMenu();
const reset = () => update(effect.reset?.(clip) ?? effect.defaults);
return <section className={`clip-effect${open ? " clip-effect--open" : ""}`} aria-label={`${effect.name} effect`}>
@@ -207,7 +213,7 @@ function EffectBlock({ effect, clip, disabled, update, onRemove }: {
], { "aria-label": `${effect.name} options`, placement: "bottom-end", focusFirst: true })}
><Ellipsis size={14} aria-hidden="true" /></button>
</header>
- {open && <fieldset className="clip-effect__body" disabled={disabled}>{effect.editor({ clip, update, disabled })}</fieldset>}
+ {open && <fieldset className="clip-effect__body" disabled={disabled}>{effect.editor({ clip, update: keyed, disabled })}</fieldset>}
{menu.element}
</section>;
}
@@ -215,13 +221,13 @@ function EffectBlock({ effect, clip, disabled, update, onRemove }: {
export function ClipEffects({ clip, disabled, onChange }: {
clip: TimelineClip;
disabled: boolean;
- onChange: (patch: Partial<TimelineClip>) => void;
+ onChange: (patch: Partial<TimelineClip>, key?: string) => void;
}) {
const [open, setOpen] = useState(false);
const trigger = useRef<HTMLButtonElement>(null);
const list = useRef<HTMLDivElement>(null);
const available = EFFECTS.filter((effect) => !clip[effect.id]);
- const update = (patch: Partial<TimelineClip>) => { if (!disabled) onChange(patch); };
+ const update: Update = (patch, key) => { if (!disabled) onChange(patch, key); };
useEffect(() => setOpen(false), [clip.id, disabled]);
const moveFocus = (event: KeyboardEvent<HTMLDivElement>) => {
if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) return;
diff --git a/src/components/workspace/MediaThumbnail.tsx b/src/components/workspace/MediaThumbnail.tsx
index 0d56800..7297ab7 100644
--- a/src/components/workspace/MediaThumbnail.tsx
+++ b/src/components/workspace/MediaThumbnail.tsx
@@ -284,6 +284,6 @@ export function MediaThumbnail({ folderPath, asset, onMeasured, posterTimeSecond
className="media-thumb"
role="img"
aria-label={failed ? `${asset.name} — preview unavailable` : asset.name}
- title={failed ? "Slopus couldn’t read this file to make a preview." : undefined}
+ data-tooltip={failed ? "Couldn’t read this file" : undefined}
>{icon}</span>;
}
diff --git a/src/components/workspace/ProgramMonitor.tsx b/src/components/workspace/ProgramMonitor.tsx
index c8fbb89..ebf67fe 100644
--- a/src/components/workspace/ProgramMonitor.tsx
+++ b/src/components/workspace/ProgramMonitor.tsx
@@ -299,10 +299,10 @@ export function ProgramMonitor({ config, folderPath, playheadMs, playing, rate =
let overlay: React.ReactNode = null;
if (!hasClips || !clip) overlay = null;
else if (asset?.kind === "generated" && !asset.relativePath && !asset.sourcePath) {
- overlay = <div className="program-note"><Film size={22} /><span>Generate {clip.label} to preview it. Its place on the timeline is already saved.</span></div>;
+ overlay = <div className="program-note"><Film size={16} /><span>{clip.label} isn’t generated yet</span></div>;
}
else if (!isTauri()) {
- overlay = <div className="program-note"><Film size={22} /><span>Playback needs the desktop app — the browser preview has no project folder to read the footage from.</span></div>;
+ overlay = <div className="program-note"><Film size={16} /><span>Playback needs the desktop app</span></div>;
}
/* The frame is fitted inside the panel and the rest is the project's own
@@ -352,8 +352,8 @@ export function ProgramMonitor({ config, folderPath, playheadMs, playing, rate =
onPointerUp={endTransform}
onPointerCancel={endTransform}
>
- <button className="program-transform__rotate" type="button" aria-label="Rotate clip" title="Drag to rotate" onPointerDown={(event) => beginTransform("rotate", event)} />
- <button className="program-transform__scale" type="button" aria-label="Scale clip" title="Drag to scale" onPointerDown={(event) => beginTransform("scale", event)} />
+ <button className="program-transform__rotate" type="button" aria-label="Rotate clip" data-tooltip="Drag to rotate" onPointerDown={(event) => beginTransform("rotate", event)} />
+ <button className="program-transform__scale" type="button" aria-label="Scale clip" data-tooltip="Drag to scale" onPointerDown={(event) => beginTransform("scale", event)} />
<span className="sr-only">Drag inside the frame to move the clip.</span>
</div>}
{audioClips.map((audioClip) => {
diff --git a/src/components/workspace/TimelineView.tsx b/src/components/workspace/TimelineView.tsx
index f70fe11..00c7237 100644
--- a/src/components/workspace/TimelineView.tsx
+++ b/src/components/workspace/TimelineView.tsx
@@ -168,7 +168,9 @@ export function TimelineView({ config, folderPath, generationCompletionTimes = {
config: ProjectConfig;
folderPath: string;
generationCompletionTimes?: Readonly<Record<string, number>>;
- onChange: (next: ConfigUpdate) => void;
+ /** `key` names a run of edits (a scrub, a typed value, a gesture) so the
+ * project's undo stack folds it into one step. */
+ onChange: (next: ConfigUpdate, key?: string) => void;
/** What a decode learned about a file the project already had — a length, a
* size. Worth keeping, but the user did not edit anything by looking at the
* Media panel, so the holder records it WITHOUT marking the project unsaved.
@@ -441,15 +443,15 @@ export function TimelineView({ config, folderPath, generationCompletionTimes = {
and so through the project's own onChange, which is what the project-level
undo stack (Ctrl+Z / Ctrl+Y, in ProjectWorkspace) records. The timeline
keeps no undo of its own. */
- const updateTracks = (nextTracks: ProjectConfig["timeline"]["tracks"]) =>
- onChange((current) => withTimelineTracks(current, 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 updateTracks = (nextTracks: ProjectConfig["timeline"]["tracks"], key?: string) =>
+ onChange((current) => withTimelineTracks(current, nextTracks), key);
+ const renameTrack = (trackId: string, name: string) => updateTracks(tracks.map((track) => track.id === trackId ? { ...track, name } : track), `track-name:${trackId}`);
+ const updateClip = (clipId: string, updates: Partial<TimelineClip>, key?: string) => updateTracks(tracks.map((track) => ({ ...track, clips: track.clips.map((clip) => clip.id === clipId ? { ...clip, ...updates } : clip) })), key);
const TRANSFORM_LIMITS = { scale: [10, 400], rotation: [-180, 180], positionX: [-100, 100], positionY: [-100, 100] } as const;
const updateTransform = (key: keyof NonNullable<TimelineClip["transform"]>, value: number) => {
if (!selected || !selectedTransform || !Number.isFinite(value)) return;
const [minimum, maximum] = TRANSFORM_LIMITS[key];
- updateClip(selected.id, { transform: roundClipTransform({ ...selectedTransform, [key]: Math.max(minimum, Math.min(maximum, value)) }) });
+ updateClip(selected.id, { transform: roundClipTransform({ ...selectedTransform, [key]: Math.max(minimum, Math.min(maximum, value)) }) }, `transform:${selected.id}:${key}`);
};
const toggleTrack = (trackId: string, key: "muted" | "locked") => updateTracks(tracks.map((track) => track.id === trackId ? { ...track, [key]: !track[key] } : track));
/* Every removal — the toolbar, the key, the context menu — goes through one
@@ -749,7 +751,7 @@ export function TimelineView({ config, folderPath, generationCompletionTimes = {
const parsed = selected ? parseTimecode(value, fps) : null;
if (parsed === null || !selected) return;
const next = trimClip(tracks, selected.id, "end", selected.startMs + parsed, { minClipMs, room: roomFor(selected) });
- if (next) updateTracks(next);
+ if (next) updateTracks(next, `duration:${selected.id}`);
};
/* Snapping, measured against a lane that is `widthPx` wide. A lane nothing
has laid out yet — jsdom, a panel that has never been painted — gives a
@@ -1206,7 +1208,7 @@ export function TimelineView({ config, folderPath, generationCompletionTimes = {
selectedClipId={selectedId}
transformEditingDisabled={selectedTrack?.locked ?? false}
onSelectClip={setSelectedId}
- onTransformChange={(clipId, transform) => updateClip(clipId, { transform: roundClipTransform(transform) })}
+ onTransformChange={(clipId, transform) => updateClip(clipId, { transform: roundClipTransform(transform) }, `transform:${clipId}:gesture`)}
/>
: <div className="program-empty"><span>Drop media on a track, or generate a scene.</span></div>}
{safeArea && <div className="program-safe" aria-hidden="true"><i className="program-safe__frame"><b className="program-safe__action" /><b className="program-safe__title" /></i></div>}
@@ -1244,7 +1246,7 @@ export function TimelineView({ config, folderPath, generationCompletionTimes = {
value={selected.label}
aria-label="Clip name"
{...tooltipProps("Rename", "F2")}
- onChange={(event) => updateClip(selected.id, { label: event.target.value || "Untitled clip" })}
+ onChange={(event) => updateClip(selected.id, { label: event.target.value || "Untitled clip" }, `label:${selected.id}`)}
/></h3>
</div>
<PropSection title="Timing" persistKey="timeline.clip.timing">
@@ -1285,7 +1287,7 @@ export function TimelineView({ config, folderPath, generationCompletionTimes = {
})}
</PropSection>
<PropSection title="Effects" persistKey="timeline.clip.effects">
- <ClipEffects clip={selected} disabled={visualControlsDisabled} onChange={(patch) => updateClip(selected.id, patch)} />
+ <ClipEffects clip={selected} disabled={visualControlsDisabled} onChange={(patch, key) => updateClip(selected.id, patch, key && `effect:${selected.id}:${key}`)} />
</PropSection>
</> : <div className="inspector-empty">
<span>{clipCount === 0 ? "Nothing on the timeline yet" : "No clip selected"}</span>