The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.
Rust ffmpegfree-video-editormodel-context-protocolnon-linear-editoroffline-firstopen-source-video-editorself-hostedvideo-editingvideo-editing-automationvideo-editing-softwarevideo-editing-toolsvideo-editorvoice-cloningyoutube-automationyoutube-shorts
fix(project): a null crop in a patch takes the crop off
Jeff Evertsecea124a724ac
diff --git a/src/crates/concat-project/src/commands/mod.rs b/src/crates/concat-project/src/commands/mod.rsindex 13ccdee0..478b1073 100644--- a/src/crates/concat-project/src/commands/mod.rs+++ b/src/crates/concat-project/src/commands/mod.rs@@ -115,8 +115,13 @@ pub struct ClipPatch {/// The blend mode's name; empty is normal.#[serde(default)]pub blend: Option<String>,- /// The crop; `Some(None)` takes it off.- #[serde(default)]+ /// The crop, same three-way wire semantics as `transition_in`: absent+ /// leaves it alone, null takes it off, a value replaces it.+ #[serde(+ default,+ with = "double_option",+ skip_serializing_if = "Option::is_none"+ )]pub crop: Option<Option<Crop>>,/// Wholesale replacement of the audio filter chain - the UI sends the/// full list, not a diff.diff --git a/src/crates/concat-project/src/lib.rs b/src/crates/concat-project/src/lib.rsindex 5dea7afd..5f45331d 100644--- a/src/crates/concat-project/src/lib.rs+++ b/src/crates/concat-project/src/lib.rs@@ -98,6 +98,42 @@ mod tests {}}+ /// Over JSON a null crop takes the crop off, as the patch documents:+ /// without `double_option` serde read null as "leave it", so no caller+ /// on the far side of the API could ever remove a crop.+ #[test]+ fn a_null_crop_on_the_wire_takes_the_crop_off() {+ let (mut editor, _, clip_id) = fixture();+ let patch = |crop: serde_json::Value| -> Command {+ serde_json::from_value(json!({+ "op": "updateClip",+ "clipId": clip_id,+ "patch": { "crop": crop }+ }))+ .expect("parses")+ };+ editor+ .apply(patch(+ json!({ "left": 0.2, "top": 0.0, "right": 0.0, "bottom": 0.1 }),+ ))+ .expect("crops");+ assert!(editor.project().active().clips[0].crop.is_some());+ let outcome = editor.apply(patch(json!(null))).expect("uncrops");+ assert!(outcome.applied, "null is take it off, not leave it");+ assert!(editor.project().active().clips[0].crop.is_none());++ let untouched: Command = serde_json::from_value(json!({+ "op": "updateClip",+ "clipId": clip_id,+ "patch": { "opacity": 0.5 }+ }))+ .expect("parses");+ match untouched {+ Command::UpdateClip { patch, .. } => assert_eq!(patch.crop, None),+ _ => panic!("not an update"),+ }+ }+/// Editor with one media item and one clip at [0, 10) on track one.fn fixture() -> (Editor, String, String) {let mut editor = Editor::new();