From fdfa75074c6b4b318b54172d559f84ac852d9234 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Mon, 9 Nov 2026 10:12:45 +0100 Subject: [PATCH] :paperclip: Compare both variants' child turns in one frame in the switch model The switch model carries an authored geometry value only where both variants agree on it. It compared the new main's child turned into the new copy parent's orientation with the old main's child unturned, so under a turned copy the variants seemed to disagree on rotation and the model dropped the turn the copy's child authors. Both are now turned into their copy parent's orientation. Harness only; the benchmark is not run. AI-assisted-by: claude-opus-5-5 --- .../app/common/test_helpers/composable/shadow.cljc | 6 +++++- .../test/common_tests/logic/composable_gen_test.cljc | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/common/src/app/common/test_helpers/composable/shadow.cljc b/common/src/app/common/test_helpers/composable/shadow.cljc index 6a5ef7a71b..54af0bb30f 100644 --- a/common/src/app/common/test_helpers/composable/shadow.cljc +++ b/common/src/app/common/test_helpers/composable/shadow.cljc @@ -751,10 +751,14 @@ (placed-flips main (get after (:parent-id main)) new-parent)) (and (not root?) (= :geometry-group group) new-parent) (in-orientation (get after (:parent-id main)) new-parent)) + ;; the old main as the old copy showed it, in the + ;; same frame as `placed` old-placed (cond-> old-main (and root? (= :geometry-group group)) (merge {:rotation old-placed-rotation} - (placed-flips old-main (get before (:parent-id old-main)) old-parent))) + (placed-flips old-main (get before (:parent-id old-main)) old-parent)) + (and (not root?) (= :geometry-group group) old-main old-parent) + (in-orientation (get before (:parent-id old-main)) old-parent)) old (if (= :geometry-group group) old-resized old) orientation #{:rotation :flip-x :flip-y} ;; the head's turn and flips carry as one: only where the diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index ef93e20bea..888ac5b8e4 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -1945,6 +1945,17 @@ [:swap 12 0 0 0] [:make-variant 4] [:switch 9] [:switch 16 0 0 0] [:combine 7] [:switch 11]]})))) +(t/deftest switching-a-turned-copy-keeps-the-turn-its-child-authors + (t/is (map? (cg/run {:world [2 0 {:variants true :text-styles true :library-variants true :stale-libraries true + :layout :flex :layout-item-margins false :grid-square false :library-depth 1 + :library true :rich-variants true :layout-children true :library-text true + :grid-empty false :layout-copies true :text true}] + :ops [[:nest 3 0 0 0] [:library-add-child 0] [:library-sync] [:remove-child 5 0 0 0] + [:library-delete 2 0 0 0] [:library-combine 10] [:library-sync] [:switch 10] + [:library-add-variant 1 0 0 0] [:transform 12 3 0 7] [:library-add-variant 1 0 0 0] + [:library-add-variant 0 0 0 0] [:library-transform 0 3 4 0] [:library-add-child 5] + [:library-sync] [:library-variant-property 0 0 0 0] [:library-sync] [:switch 10]]})))) + (t/deftest random-variant-compositions (let [coverage (atom {}) failure (atom nil)]