From da44e9ee509329c5e9e95677b203f6e05b9327d7 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Thu, 5 Nov 2026 23:41:21 +0100 Subject: [PATCH] :bug: Carry no geometry a switched copy already shows within precision A switch carries the touched attributes of the old copy into the new one, skipping those whose values are already equal. Geometry was compared exactly: a turn the new copy already showed, up to float noise in its transform, was carried and marked as a geometry override the old copy did not author. Geometry attributes compare within their precision, as the check that both variants share a value already does. Benchmark (scripts/bench-components, ms, lower 2.5% quantile): | world | baseline | now | ratio | |------------------------------------+----------+---------+-------| | deepest-edit-through-three-levels | 35.215 | 18.972 | 0.54 | | edit-through-a-chain-of-dependents | 68.931 | 37.79 | 0.55 | | library-update-into-copies | 83.083 | 46.453 | 0.56 | | main-edit-among-many-shapes | 4.837 | 2.175 | 0.45 | | main-edit-into-10-copies | 1.79 | 0.927 | 0.52 | | main-edit-into-100-copies | 15.415 | 8.87 | 0.58 | | main-edit-into-1000-copies | 153.086 | 89.777 | 0.59 | | variant-switch-into-copies | 32.052 | 20.379 | 0.64 | AI-assisted-by: claude-opus-5-5 --- common/src/app/common/logic/swap.cljc | 7 +++++-- .../common_tests/logic/composable_gen_test.cljc | 13 +++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/common/src/app/common/logic/swap.cljc b/common/src/app/common/logic/swap.cljc index 3bf1217733..cd3336a3da 100644 --- a/common/src/app/common/logic/swap.cljc +++ b/common/src/app/common/logic/swap.cljc @@ -175,8 +175,11 @@ ;; If the attribute is not valid for the destiny, don't copy it (not (cts/is-allowed-switch-keep-attr? attr (:type current-shape))) - ;; If the values are already equal, don't copy them - (= (get previous-shape attr) (get current-shape attr)) + ;; If the values are already equal, don't copy them; geometry + ;; within its precision + (if (= sync-group :geometry-group) + (gsh/close-attrs? attr (get previous-shape attr) (get current-shape attr)) + (= (get previous-shape attr) (get current-shape attr))) ;; If :selrect/:points values are already equal ignoring displacement, ;; don't copy them diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 1010dc1dce..dd058efafb 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -1197,3 +1197,16 @@ :layout-item-margins false :grid-square false :rich-variants true :layout-children false :grid-empty true :layout-copies true :text true}] :ops [[:style 0 29 1] [:nest 9 0 0 0] [:duplicate 5 1 0 0]]}))))) + +(t/deftest generated-switch-carries-no-geometry-the-new-copy-already-shows + ;; a switched head inherits a turn its new copy already shows up to float + ;; noise in the transform; the switch carries no geometry override for it + (t/is (map? (cg/run {:world [2 2 {:variants true :text-styles true :layout nil :layout-item-margins false + :grid-square false :library true :rich-variants true :layout-children false + :grid-empty false :layout-copies true :text true}] + :ops [[:nest 6 0 0 0] [:rotate 21 0 0 0] [:duplicate 21 0 0 0] [:switch 0 0 0 0] + [:switch 0 0 0 0] [:edit 6 0 1 1] [:update-main 6] [:switch 9 0 0 0]]}))) + (t/is (map? (cg/run {:world [2 2 {:variants true :text-styles true :layout nil :variant-diff false + :layout-item-margins false :grid-square false :rich-variants true + :layout-children false :grid-empty false :layout-copies true :text true}] + :ops [[:rotate 0 0 0 0] [:update-main 0 0 0 0] [:resize 0 0 0 0] [:switch 4 0 0 0]]}))))