From 6f7a77504f63f9948ffc7f9b255d8a15f3168d82 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 13 Nov 2026 12:22:45 +0100 Subject: [PATCH] :paperclip: Model an authored size through its parent's later resizes A nested copy in a main that authors its height and scales vertically has its height scaled when an update main resizes that main. The model kept only the size as authored, as the copy's place in a plain main is not an override, and compared it raw. An authored size now follows its parent's later resizes through its constraints, though its place stays unauthored. Test: an-authored-size-follows-a-resize-of-its-main-through-its-constraint. Structure, swap and scale programs pass (seed 9006, 150 each). Harness only; the benchmark is not run. AI-assisted-by: claude-opus-5-5 --- common/src/app/common/test_helpers/composable/shadow.cljc | 6 ++++++ common/test/common_tests/logic/composable_gen_test.cljc | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/common/src/app/common/test_helpers/composable/shadow.cljc b/common/src/app/common/test_helpers/composable/shadow.cljc index c849b527c1..0f8dd60d25 100644 --- a/common/src/app/common/test_helpers/composable/shadow.cljc +++ b/common/src/app/common/test_helpers/composable/shadow.cljc @@ -190,6 +190,10 @@ parent) placed (when (and objects (not (:sized? (::position (meta expected))))) (authored-placement expected parent shape)) + ;; an authored size follows its parent's later resizes through its + ;; constraints too, though its place is not authored + sized-placed (when (and objects (:sized? (::position (meta expected)))) + (authored-placement expected parent shape)) ;; a group or bool takes its corners from its children: at its ;; expected corners, its turn and flips say nothing more derived (and (#{:group :bool} (:type shape)) @@ -241,6 +245,8 @@ ;; a recorded place sizes it through its constraints as its parent resizes (and (#{:width :height} key) placed (number? actual)) (mth/close? (get placed key) actual 0.01) + (and (#{:width :height} key) sized-placed (number? actual)) + (mth/close? (get sized-placed key) actual 0.01) (#{:flip-x :flip-y} key) (= (boolean value) (boolean actual)) ;; under one flip, either order of turn and flip stores the opposite turn (and (= :rotation key) (number? value) (number? actual) diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 780590be1e..ea9e84ba2d 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -2598,6 +2598,12 @@ :layout-copies false :text true}] :ops [[:grid-cell 13] [:grid-track 0 0 11] [:grid-track 0 3] [:add-child 8] [:grid-track 0 2]]})))) +(t/deftest an-authored-size-follows-a-resize-of-its-main-through-its-constraint + (t/is (map? (cg/run {:world [1 0 {:variants true :layout :grid :layout-item-margins false :grid-square false + :rich-variants false :layout-children false :grid-empty false + :layout-copies false :text false}] + :ops [[:duplicate] [:swap] [:resize] [:resize 2] [:style 0 9 1] [:edit 2 0 0 1] [:update-main 2]]})))) + (t/deftest settling-a-bool-in-a-grid-copy-twice-keeps-its-shapes-in-place (t/is (map? (cg/run {:world [3 0 {:variants true :rich-variants true :text true :layout :grid :layout-copies true :layout-children true}]