From 9dc405b65e60d86649d228ffac2445608fe8e024 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 30 Oct 2026 21:28:28 +0100 Subject: [PATCH] :bug: Cancel a nested copy's parent turn in update main Update main turned a copy back into its main's frame only when the copy root authored no geometry. A nested copy that inherited its parent's turn and then authored a resize still pushed the turn into its main, and sync composed it again: 45 degrees became 90. Sync composes a nested copy root with its parent's turn, so cancel exactly that turn, relative to the main's parent, whatever the root authors. A top-level copy root keeps the existing rule: it owns its turn only when it authors its geometry. The shrunk library program fails I9 before the fix and passes unchanged after it; the earlier inherited-turn regression still passes. Goldens are unchanged. Full suites ran on the tree with the fixture fix, this update-main fix and the grid rollout. Common JVM passes 2061 tests / 33765 assertions; JavaScript passes 1997 / 32400; common lint and formatting pass. All six component properties pass 40 programs each at seed 712 in both runtimes. Full rebuilt frontend passes 1798 / 16138. Backend passes 1838 / 9293; exporter passes 16 / 40; consumer lint and formatting pass. Compare lower-quantile milliseconds with the saved baseline; keep that baseline unchanged. The machine/JVM warning makes ratios rough. No world is flagged. World Baseline Now Ratio Main into 10 copies 1.790 0.866 0.48 Main into 100 copies 15.415 8.393 0.54 Main into 1000 copies 153.086 85.279 0.56 Three nesting levels 35.215 17.172 0.49 Dependency chain 68.931 34.199 0.50 Library update 83.083 42.833 0.52 Many plain shapes 4.837 2.064 0.43 Variant switch 32.052 19.599 0.61 AI-assisted-by: claude-opus-5-5 --- common/src/app/common/logic/libraries.cljc | 24 ++++++++++++------- .../logic/composable_gen_test.cljc | 9 +++++++ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index 9537161e51..d59750fd2c 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -671,20 +671,28 @@ (generate-rename-component (:component-id shape-inst) (:name shape-inst) library))] (if component - (let [synced-ids (volatile! #{}) - root-main (ctf/get-component-root library component)] + (let [synced-ids (volatile! #{}) + main-container (ctf/get-component-container library component) + root-main (ctf/get-component-root library component) + center (grc/rect->center (:selrect shape-inst))] (-> (update-main-recursive changes {:container container - :main-container (ctf/get-component-container library component) + :main-container main-container :component component :libraries libraries :root-inst shape-inst :root-main root-main - ;; An orientation the copy root inherits from its - ;; parent places it; it is not pushed into the main. - :inherited-turn (when-not (ctk/touched-group? shape-inst :geometry-group) - (orient-like shape-inst root-main - (grc/rect->center (:selrect shape-inst)))) + ;; 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)) + (when-let [parent (ctn/get-shape container (:parent-id shape-inst))] + (orient-like parent + (or (ctn/get-shape main-container (:parent-id root-main)) {}) + center))) :remote-synced (when-not (:component-root shape-inst) true) :synced-ids synced-ids} shape-inst diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index e30767f8b5..dc25f2c33e 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -696,6 +696,15 @@ (t/is (true? (:fixed-scroll pushed))) (t/is (contains? (:touched pushed) :constraints-group)))) +(t/deftest updating-a-main-from-a-resized-copy-turned-by-its-parent-keeps-its-turn + ;; The nested copy authors only its size; its 45 degree turn still comes + ;; from its parent, so update-main must not turn the main. + (t/is (map? (cg/run {:world [2 2 {:variants true :text-styles true :layout nil :layout-item-margins false + :library true :rich-variants true :layout-children false + :layout-copies true :text true}] + :ops [[:transform 6 15 0 0] [:resize 0 0 0 0] [:resize 2 0 0 0] [:resize 1 0 0 0] + [:edit 22 20 0 0] [:edit 11 0 1 1] [:update-main 11]]})))) + (t/deftest detached-swapped-head-follows-its-own-component-without-position-overrides (t/is (map? (cg/run {:world [2 1 {:library true :variants true}] :ops [[:edit 0 0 1 2] [:update-main 0] [:library-sync]