From 0b301551592703786d7e96d8210cb357c6b312dd Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Mon, 2 Nov 2026 22:02:53 +0100 Subject: [PATCH] :bug: Keep the parent's turn out of an update main of a resized top copy A top copy turned with its parent board keeps that turn when the board is detached. Resizing the copy gives it a geometry of its own, and update main then pushed the board's turn into the main, while sync composes the copy with its parent's turn again: the copy turned twice. Update main now turns back the parent's turn for a top copy root with its own geometry, as it does for nested roots; under an unturned parent that is no turn. Benchmark (scripts/bench-components, ms, lower 2.5% quantile): | world | baseline | now | ratio | |------------------------------------+----------+---------+-------| | deepest-edit-through-three-levels | 35.215 | 19.207 | 0.55 | | edit-through-a-chain-of-dependents | 68.931 | 37.719 | 0.55 | | library-update-into-copies | 83.083 | 47.009 | 0.57 | | main-edit-among-many-shapes | 4.837 | 2.17 | 0.45 | | main-edit-into-10-copies | 1.79 | 1.039 | 0.58 | | main-edit-into-100-copies | 15.415 | 10.179 | 0.66 | | main-edit-into-1000-copies | 153.086 | 101.906 | 0.67 | | variant-switch-into-copies | 32.052 | 20.838 | 0.65 | AI-assisted-by: claude-opus-5-5 --- common/src/app/common/logic/libraries.cljc | 10 +++++----- .../test/common_tests/logic/composable_gen_test.cljc | 8 ++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index 2c781aa426..f4ffb6072c 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -780,11 +780,11 @@ :root-main root-main ;; An orientation the copy root inherits places it ;; and is not pushed into the main. Sync composes a - ;; nested root with its parent's turn; a top copy - ;; root owns its turn only when it authors geometry. - :inherited-turn (if (:component-root shape-inst) - (when-not (ctk/touched-group? shape-inst :geometry-group) - (orient-like shape-inst root-main center)) + ;; root with its parent's turn; a top copy root that + ;; does not author its geometry inherits all of it. + :inherited-turn (if (and (:component-root shape-inst) + (not (ctk/touched-group? shape-inst :geometry-group))) + (orient-like shape-inst root-main center) (when-let [parent (ctn/get-shape container (:parent-id shape-inst))] (orient-like parent (or (ctn/get-shape main-container (:parent-id root-main)) {}) diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 13441cae57..9573d89976 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -1004,3 +1004,11 @@ :layout-copies true :text true}] :ops [[:nest 0 0 0 0] [:text-style 0 1 1] [:duplicate 0 0 0 0] [:update-main 1 0 0 0] [:text-style 0 0 1]]})))) + +(t/deftest generated-resized-copy-in-a-turned-board-pushes-its-own-turn + ;; a copy turned with a board that is detached and then resized pushes its + ;; size to its main but not the board's turn, which sync gives it back + (t/is (map? (cg/run {:world [2 2 {:variants true :text-styles true :library true :rich-variants true + :layout-copies true :text true}] + :ops [[:rotate 15 0 0 0] [:detach 15 0 0 0] [:delete 5] [:restore 5] + [:resize 14 0 0 0] [:edit 3 0 1 1] [:update-main 3]]}))))