feat: surface command outcomes (success/noop) from Edit mutators#134
Merged
Conversation
|
🎉 This PR is included in version 2.13.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 toPromise<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,deleteTrackundo/redo(noopwhen there is nothing to undo/redo)setOutputSize/Fps/Format/Destinations/Resolution/AspectRatio,setTimelineBackground)applyMergeField/removeMergeFieldnoopwith a message instead of only logging a console warningdeleteTrackpreviously returnedvoidsynchronously 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
noopmeans 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 intests/edit-clip-operations.test.tsandtests/edit-merge-fields.test.ts(last-clip refusal, atomic luma-path refusal, unknown ids, last track, undo/redo exhaustion, output setters, merge fields).