From fb24f8c19e1fb6fd66dae0c2828dc7f55152362f Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 13 Nov 2026 02:05:21 +0100 Subject: [PATCH] :bug: Count a copy bool that mirrors apart from its main as moved A bool keeps its corners in one order whatever its flips. Sync places the shapes of a copy shape that authors its geometry like it only when its geometry differs from its main's, so a flipped bool in a copy looked like its main, and sync gave its shapes their main's unflipped geometry. A group or bool also differs from its main when it mirrors differently, read from its transform. Test: syncing-the-shapes-of-a-flipped-copy-bool-keeps-them-flipped. Benchmark (alone, shared with the next commit): | :world | :baseline | :now | :mean | :ratio | |------------------------------------+-----------+--------+---------+--------| | deepest-edit-through-three-levels | 35.215 | 20.498 | 21.134 | 0.58 | | edit-through-a-chain-of-dependents | 68.931 | 40.257 | 42.557 | 0.58 | | library-update-into-copies | 83.083 | 51.433 | 52.577 | 0.62 | | main-edit-among-many-shapes | 4.837 | 2.145 | 2.365 | 0.44 | | main-edit-into-10-copies | 1.79 | 1.012 | 1.093 | 0.57 | | main-edit-into-100-copies | 15.415 | 10.535 | 10.754 | 0.68 | | main-edit-into-1000-copies | 153.086 | 99.04 | 105.491 | 0.65 | | variant-switch-into-copies | 32.052 | 22.662 | 23.464 | 0.71 | AI-assisted-by: claude-opus-5-5 --- common/src/app/common/logic/libraries.cljc | 8 +++++++- common/test/common_tests/logic/composable_gen_test.cljc | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index 12ab7fb0b5..3154612828 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -550,11 +550,17 @@ (gpt/point (-> root-inst :selrect :x) (-> root-inst :selrect :y)))] (gsh/move shape delta))) +(declare flips) + (defn- close-geometry? + "Whether `shape` and `other` have the same geometry: a bool keeps its + corners in one order whatever its flips, so they count too." [shape other] (and (gsh/close-attrs? :selrect (:selrect shape) (:selrect other)) (gsh/close-attrs? :points (:points shape) (:points other)) - (mth/close? (:content-scale shape 1) (:content-scale other 1)))) + (mth/close? (:content-scale shape 1) (:content-scale other 1)) + (or (not (#{:group :bool} (:type shape))) + (= (flips shape) (flips other))))) (defn- authored-constraints "The constraints that the copy shapes `ids` author, by the id of the main diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index adf5c584b0..ead5e8b0d0 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -2519,6 +2519,11 @@ :layout-copies false :layout-children false}] :ops [[:structure 1 1 1] [:remove-child 1]]})))) +(t/deftest syncing-the-shapes-of-a-flipped-copy-bool-keeps-them-flipped + (t/is (map? (cg/run {:world [1 0 {:variants false :rich-variants false :text false :layout :grid + :layout-copies false :layout-children false}] + :ops [[:structure 0 4] [:transform 0 4 0 2]]})))) + (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}]