Skip to content

feat: surface command outcomes (success/noop) from Edit mutators#134

Merged
dazzatronus merged 3 commits into
mainfrom
derk/surface-command-results
Jul 3, 2026
Merged

feat: surface command outcomes (success/noop) from Edit mutators#134
dazzatronus merged 3 commits into
mainfrom
derk/surface-command-results

Conversation

@dazzatronus

@dazzatronus dazzatronus commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

What

Commands have always distinguished a mutation that applied (success) from one that was refused or matched nothing (noop, e.g. deleting the last clip, an unknown clip id, undo on empty history) — but the public API flattened both to Promise<void>, so callers could not tell them apart. Deleting the only clip in the timeline, for example, resolved normally while the document stayed unchanged.

Mutators now resolve with the CommandResult ({ status: "success" | "noop", message? }), exported from the package root:

  • addClip, updateClip(ById), deleteClip(ById), moveClipById, addTrack, deleteTrack
  • undo / redo (noop when there is nothing to undo/redo)
  • output setters (setOutputSize/Fps/Format/Destinations/Resolution/AspectRatio, setTimelineBackground)
  • applyMergeField / removeMergeField
  • unknown-id lookups now resolve noop with a message instead of only logging a console warning

deleteTrack previously returned void synchronously while the command ran on the queue; it now returns the queued result promise.

Also fixes a partial-mutation edge the new contract exposed: deleting a content clip that has a luma matte attached, when they are the last two clips, used to delete the luma and then refuse the content clip. The refusal is now atomic — a noop means nothing changed.

Why

Programmatic callers (editor tooling, automation) need to know whether a mutation actually applied. Resolution no longer implies success — check status.

Compatibility

Additive: existing callers that ignore the resolved value are unaffected. Timeline invariants are unchanged (always ≥1 clip and ≥1 track).

Verify

npm test — 1833 tests pass, including new result-contract cases in tests/edit-clip-operations.test.ts and tests/edit-merge-fields.test.ts (last-clip refusal, atomic luma-path refusal, unknown ids, last track, undo/redo exhaustion, output setters, merge fields).

@dazzatronus dazzatronus merged commit 7d6e6b1 into main Jul 3, 2026
1 check passed
@dazzatronus dazzatronus deleted the derk/surface-command-results branch July 3, 2026 08:28
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 2.13.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant