From fa1edc78bd4b2298ae0148cc61c09df7600f732e Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 13 Nov 2026 02:25:58 +0100 Subject: [PATCH] :paperclip: Place a group's shapes from its board when the harness orients them Flipping the mask of a mask group in a copy makes the group follow it. The model applied the mask's change twice, as the modifier tree passes a mask's change to its group and back, and when the group's orientation changed it placed the mask's authored geometry in the group, whose bounds come from that mask, halving it. The requested geometry of a group's mask applies its change once, and authored geometry under a group or bool follows the board around it when its parent's orientation changes, as elsewhere in the model. Test: flipping-the-mask-of-a-copy-group-flips-the-group-for-good; shape structure programs pass (seed 9002, 300). Harness only; the benchmark is not run. Also in this commit: - Compare a bool by its children, not its segments, when checking undo. Undoing an update main that pushed a flip into a main holding a bool gives the bool back the same rectangle with its segments drawn the other way round. A bool computes its segments from its children, in an order that depends on how it computed them. AI-assisted-by: claude-opus-5-5 --- .../test_helpers/composable/comp/undo_check.cljc | 8 ++++++-- .../src/app/common/test_helpers/composable/gen.cljc | 8 ++++++-- .../app/common/test_helpers/composable/shadow.cljc | 12 ++++++++++-- .../test/common_tests/logic/composable_gen_test.cljc | 5 +++++ 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/common/src/app/common/test_helpers/composable/comp/undo_check.cljc b/common/src/app/common/test_helpers/composable/comp/undo_check.cljc index e267337d4c..81ef0740d1 100644 --- a/common/src/app/common/test_helpers/composable/comp/undo_check.cljc +++ b/common/src/app/common/test_helpers/composable/comp/undo_check.cljc @@ -194,7 +194,11 @@ (and (map? expected) (map? actual) (= (set (keys expected)) (set (keys actual)))) (every? (fn [key] - (same-state? (cond-> (get expected key) + (or + ;; a bool computes its segments from its children, in an order + ;; that depends on how it computed them; its children are compared + (and (= :content key) (= :bool (:type expected)) (contains? expected :parent-id)) + (same-state? (cond-> (get expected key) (and (= :points key) (= :bool (:type expected)) (contains? expected :parent-id)) corner-order) (cond-> (get actual key) @@ -210,7 +214,7 @@ (or (contains? #{:x :y :width :height :rotation :points :selrect :transform :transform-inverse} key) ;; the segments of a bool or path are its geometry - (and (= :content key) (#{:bool :path} (:type expected)))))))) + (and (= :content key) (#{:bool :path} (:type expected))))))))) (keys expected)) (and (sequential? expected) (sequential? actual) (= (count expected) (count actual))) diff --git a/common/src/app/common/test_helpers/composable/gen.cljc b/common/src/app/common/test_helpers/composable/gen.cljc index 5e8d512587..7e8d2dbd64 100644 --- a/common/src/app/common/test_helpers/composable/gen.cljc +++ b/common/src/app/common/test_helpers/composable/gen.cljc @@ -1030,8 +1030,12 @@ :resize (ctm/change-size shape nil (:value op)) :rotate (n/geometry-modifiers shape :rotate (:angle op)) (:transform :library-transform) (n/geometry-modifiers shape (:action op) (:value op))) - tree (gm/set-objects-modifiers {(:id shape) {:modifiers modifiers}} objects)] - (gsh/transform-shape shape (get-in tree [(:id shape) :modifiers])))) + parent (get objects (:parent-id shape)) + ;; the mask of a group passes its change to the group and back, so + ;; the tree would apply it twice; only its group places it + mask? (and (:masked-group parent) (= (:id shape) (first (:shapes parent)))) + tree (when-not mask? (gm/set-objects-modifiers {(:id shape) {:modifiers modifiers}} objects))] + (gsh/transform-shape shape (if mask? modifiers (get-in tree [(:id shape) :modifiers]))))) (defn- kind-file "The file an operation edits: the library `library-id`, or the current one." diff --git a/common/src/app/common/test_helpers/composable/shadow.cljc b/common/src/app/common/test_helpers/composable/shadow.cljc index 87a12519a5..32506ac0ac 100644 --- a/common/src/app/common/test_helpers/composable/shadow.cljc +++ b/common/src/app/common/test_helpers/composable/shadow.cljc @@ -628,8 +628,16 @@ (fn [result id groups] (let [old (get before id) shape (get after id) - parent (get before (:parent-id old)) - new-parent (get after (:parent-id shape))] + ;; a group or bool takes its bounds and turn from its children, + ;; so they take their place from the board around it + board (fn [objects shape] + (let [parent (get objects (:parent-id shape)) + frame (get objects (:frame-id shape))] + (if (and (#{:group :bool} (:type parent)) (not (ctl/any-layout? frame))) + frame + parent))) + parent (when old (board before old)) + new-parent (when shape (board after shape))] (if (and (:geometry-group groups) old shape (= (:parent-id old) (:parent-id shape)) parent new-parent) (if-let [expected (authored-placement (:geometry-group groups) new-parent)] diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 18311a8d96..28932efbce 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -2530,6 +2530,11 @@ :ops [[:remove-child 9] [:add-child 7] [:delete 7] [:add-child] [:undo] [:structure 10 1] [:transform 10 5 0 2]]})))) +(t/deftest undoing-an-update-main-compares-a-bool-by-its-children-not-its-segments + (t/is (map? (cg/run {:world [1 1 {:variants false :rich-variants false :text false :layout nil + :layout-copies false :layout-children false}] + :ops [[:transform 0 5 0 3] [:structure 0 5] [:update-main]]})))) + (t/deftest settling-a-bool-in-a-grid-copy-twice-keeps-its-shapes-in-place (t/is (map? (cg/run {:world [3 0 {:variants true :rich-variants true :text true :layout :grid :layout-copies true :layout-children true}]