From 61ba182549ee118b75e1d44346c14660ef8fbbd1 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 17 Nov 2026 11:47:05 +0100 Subject: [PATCH] :bug: Make an update main into a nested copy author the sizing it fixes An update main that pushes a transformed fill child into the nested copy its main holds fixes that copy's layout sizing, as a resize does, so the layout keeps the pushed size. It did not mark the sizing as the nested copy's own override: the copy differed from its reference without an override, and the next sync would give it the fill back and undo the pushed size (F588, reachable since moves are generated). A main that is itself a copy now touches the sizing groups the push fixes. The composable model expects it to author them. Test: generated `generated-an-update-main-into-a-nested-copy-authors-the-sizing-it-fixes` (JVM and frontend replay). Benchmark (bench-components, alone): | :world | :baseline | :now | :mean | :ratio | |------------------------------------+-----------+--------+---------+--------| | deepest-edit-through-three-levels | 35.215 | 21.333 | 22.41 | 0.61 | | edit-through-a-chain-of-dependents | 68.931 | 42.992 | 44.734 | 0.62 | | library-update-into-copies | 83.083 | 55.577 | 58.064 | 0.67 | | main-edit-among-many-shapes | 4.837 | 2.625 | 3.164 | 0.54 | | main-edit-into-10-copies | 1.79 | 1.131 | 1.216 | 0.63 | | main-edit-into-100-copies | 15.415 | 11.226 | 12.849 | 0.73 | | main-edit-into-1000-copies | 153.086 | 103.22 | 108.455 | 0.67 | | variant-switch-into-copies | 32.052 | 23.27 | 24.267 | 0.73 | AI-assisted-by: claude-opus-5-5 --- common/src/app/common/logic/libraries.cljc | 8 ++++++-- .../src/app/common/test_helpers/composable/shadow.cljc | 10 ++++++++++ .../test/common_tests/logic/composable_gen_test.cljc | 5 +++++ .../composable_tests/generated_test.cljs | 5 +++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index 3aaf881e95..824a459bea 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -1181,9 +1181,13 @@ (and keep-name? (ctk/touched-group? shape-inst :name-group)) (conj :name-group)))) ;; A previous update is not a reset of the main's authored - ;; overrides. Repeating it must retain the groups it pushed. + ;; overrides. Repeating it must retain the groups it pushed, + ;; and a main that is itself a copy authors the sizing the + ;; push fixes. (set-touched shape-main main-container - (set/union (:touched shape-main) (set/difference inst-touched kept-items)))) + (cond-> (set/union (:touched shape-main) (set/difference inst-touched kept-items)) + (:shape-ref shape-main) + (into (map #(ctk/resolve-sync-group (:type shape-main) %)) (keys fixed))))) (ctsl/any-layout? shape-main) (update-layout-children main-container shape-main shape-inst #(ctf/get-shape-in-copy container % shape-inst) false) diff --git a/common/src/app/common/test_helpers/composable/shadow.cljc b/common/src/app/common/test_helpers/composable/shadow.cljc index b5bfe7a003..16e0c1e4da 100644 --- a/common/src/app/common/test_helpers/composable/shadow.cljc +++ b/common/src/app/common/test_helpers/composable/shadow.cljc @@ -612,6 +612,16 @@ (update id merge kept-items) kept-name (assoc-in [id :name-group] kept-name) + ;; a main that is itself a copy authors the layout sizing a + ;; pushed geometry fixes on it, which keeps the pushed size + (and (:shape-ref ref) (contains? groups :geometry-group)) + (update (:id ref) merge + (into {} + (keep (fn [group] + (when (not= (get (get before (:id ref)) group) (get ref group)) + [group (values ref group)]))) + [:layout-item-h-sizing :layout-item-v-sizing])) + (and (:shape-ref ref) (seq groups)) (update (:id ref) (fn [main-groups] diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index ca1569a95f..20a9a31ac6 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -4469,3 +4469,8 @@ :layout-copies true :layout-children false}] :ops [[:remove-child 0 0 0 0] [:add-child 1] [:structure 0 4 0] [:transform 0 16 0 3] [:rotate 0 0 0 0] [:rotate 1 0 0 0]]})))) + +(t/deftest generated-an-update-main-into-a-nested-copy-authors-the-sizing-it-fixes + ;; a copy child filling a row pushes a transform into the nested copy its + ;; main holds, which takes it with its sizing fixed as its own override + (t/is (map? (cg/run {:world [3 2 {:text true :layout :flex}] :ops [[:nest 24 11 9 6] [:delete 1] [:restore 1] [:add-child 15 16 4 29] [:move 23 24 12 20] [:edit 25 25 27 25] [:undo 23 17 15 25] [:style 23 29 25 20] [:transform 29 11 7 27] [:update-main 2 19 2 29]]})))) diff --git a/frontend/test/frontend_tests/composable_tests/generated_test.cljs b/frontend/test/frontend_tests/composable_tests/generated_test.cljs index 7f0bada4cd..e3b3ee122d 100644 --- a/frontend/test/frontend_tests/composable_tests/generated_test.cljs +++ b/frontend/test/frontend_tests/composable_tests/generated_test.cljs @@ -1191,3 +1191,8 @@ (pr-str (merge-with - (select-keys after [:pass :fail :error]) (select-keys before [:pass :fail :error])))))) (recur (inc index))))))) + +(t/deftest ^:async generated-an-update-main-into-a-nested-copy-authors-the-sizing-it-fixes + ;; a copy child filling a row pushes a transform into the nested copy its + ;; main holds, which takes it with its sizing fixed as its own override + (await (replay {:world [3 2 {:text true :layout :flex}] :ops [[:nest 24 11 9 6] [:delete 1] [:restore 1] [:add-child 15 16 4 29] [:move 23 24 12 20] [:edit 25 25 27 25] [:undo 23 17 15 25] [:style 23 29 25 20] [:transform 29 11 7 27] [:update-main 2 19 2 29]]})))