From c5602b81708184b346e909c0992a5c0246f16682 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Mon, 16 Nov 2026 17:07:31 +0100 Subject: [PATCH] :bug: Fit a synced masked group to its mask again A masked group takes all its geometry from its mask. When a copy turned the mask of a masked group, a sync gave the copy's group the geometry of its main's group, square to the page, and fitted only the group's parents, so the group no longer matched its turned mask; a reflow then fitted it again, and settling and a full sync gave different files. After a sync writes a masked group's attributes, the group fits its mask again along with its parents. Test: generated `a-synced-masked-group-fits-the-mask-its-copy-turned` (fails before the fix). Benchmark (bench-components, alone): | :world | :baseline | :now | :mean | :ratio | |------------------------------------+-----------+---------+--------+--------| | deepest-edit-through-three-levels | 35.215 | 22.245 | 23.118 | 0.63 | | edit-through-a-chain-of-dependents | 68.931 | 43.743 | 44.839 | 0.63 | | library-update-into-copies | 83.083 | 54.447 | 57.814 | 0.66 | | main-edit-among-many-shapes | 4.837 | 2.742 | 2.876 | 0.57 | | main-edit-into-10-copies | 1.79 | 1.077 | 1.135 | 0.6 | | main-edit-into-100-copies | 15.415 | 10.488 | 11.093 | 0.68 | | main-edit-into-1000-copies | 153.086 | 106.222 | 112.37 | 0.69 | | variant-switch-into-copies | 32.052 | 23.155 | 23.929 | 0.72 | AI-assisted-by: claude-opus-5-5 --- common/src/app/common/logic/libraries.cljc | 7 +++++-- common/test/common_tests/logic/composable_gen_test.cljc | 7 +++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index cc91a5a61a..f9f25282b5 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -1907,8 +1907,11 @@ it to them meanwhile, while it keeps the transform the change gave it, rewrites geometry the change did not touch." [changes dest-shape container roperations uoperations] - (let [update-parents {:type :reg-objects - :shapes (cfh/get-parent-ids (:objects container) (:id dest-shape))} + (let [;; a masked group takes all its geometry from its mask, so it fits + ;; its mask again after taking its main's + update-parents {:type :reg-objects + :shapes (cond->> (vec (cfh/get-parent-ids (:objects container) (:id dest-shape))) + (:masked-group dest-shape) (into [(:id dest-shape)]))} undone (into #{} (map :attr) uoperations) uoperations (cond-> (vec uoperations) (and (#{:group :bool} (:type dest-shape)) diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 65858e96bb..324d9c3fca 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -2495,6 +2495,13 @@ :ops [[:variant-property 0 9 3 0] [:switch 4] [:combine 2] [:switch 8] [:style 11 7 1] [:update-main 2 0 0 0]]})))) +(t/deftest a-synced-masked-group-fits-the-mask-its-copy-turned + ;; a copy turns the mask of a masked group; a sync gives the group its + ;; main's geometry and then fits it to the turned mask again + (t/is (map? (cg/run {:world [2 0 {:variants true :rich-variants true :text true :layout nil :layout-copies true + :layout-children false}] + :ops [[:add-child 1] [:structure 3 1 0] [:transform 2 3 0 2]]})))) + (t/deftest a-pasted-copy-compares-with-the-main-the-file-accepted ;; the library widened a main the stale file has not accepted: a copy ;; pasted from it shows the accepted size, which is no override