From dc485e2e0878c152fb350e2966e665596b995553 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Thu, 12 Nov 2026 14:42:17 +0100 Subject: [PATCH] :bug: Give the groups around a new bool the bounds of its result A group takes its bounds from its children. Creating a bool inside a group left the group with its old bounds, though the bool's result can be smaller: a difference of a 12 px shape and a 20 px one inside a 30 px group kept the group at 30 px in the main, while sync gave the copies' groups the bool's 12 px. Creating a bool now refreshes the groups around it, as masking does. Tests: a-bool-made-in-a-group-gives-the-group-its-bounds; a-bool-made-in-a-main-group-gives-the-copy-groups-its-bounds (the shape structure program of gate seed 660536824). Benchmark (scripts/bench-components, ms, lower 2.5% quantile), with a 3 GB heap, alone: | :world | :baseline | :now | :mean | :ratio | |------------------------------------+-----------+---------+---------+--------| | deepest-edit-through-three-levels | 35.215 | 21.558 | 23.752 | 0.61 | | edit-through-a-chain-of-dependents | 68.931 | 43.004 | 48.489 | 0.62 | | library-update-into-copies | 83.083 | 50.926 | 53.941 | 0.61 | | main-edit-among-many-shapes | 4.837 | 2.427 | 2.862 | 0.5 | | main-edit-into-10-copies | 1.79 | 1.121 | 1.214 | 0.63 | | main-edit-into-100-copies | 15.415 | 10.652 | 11.179 | 0.69 | | main-edit-into-1000-copies | 153.086 | 105.051 | 119.813 | 0.69 | | variant-switch-into-copies | 32.052 | 23.083 | 25.483 | 0.72 | AI-assisted-by: claude-opus-5-5 --- common/src/app/common/logic/bool.cljc | 4 +++- .../test/common_tests/logic/composable_gen_test.cljc | 5 +++++ common/test/common_tests/logic/groups_test.cljc | 12 ++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/common/src/app/common/logic/bool.cljc b/common/src/app/common/logic/bool.cljc index 129fdb280b..047c786751 100644 --- a/common/src/app/common/logic/bool.cljc +++ b/common/src/app/common/logic/bool.cljc @@ -131,4 +131,6 @@ [parent-id] (fn [parent] (assoc-in parent [:layout-grid-cells (:id target-cell) :shapes] [shape-id])))) - (pcb/update-shapes grid-parents ctl/assign-cells {:with-objects? true}))])))) + (pcb/update-shapes grid-parents ctl/assign-cells {:with-objects? true}) + ;; the groups around the bool take the bounds of its result + (pcb/resize-parents [shape-id]))])))) diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 367f4c6f56..4832e704c0 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -2467,6 +2467,11 @@ [:add-child 0 0 0 0] [:add-child 0] [:structure 14 1 0] [:rotate 15 0 0 0] [:add-child 0] [:structure 0 3 0]]})))) +(t/deftest a-bool-made-in-a-main-group-gives-the-copy-groups-its-bounds + (t/is (map? (cg/run {:world [1 0 {:variants true :rich-variants true :text false :layout :flex + :layout-copies false :layout-children false}] + :ops [[:delete] [:swap] [:add-child 1] [:structure] [:structure 4 0 1] [:structure 2 5 3]]})))) + (t/deftest random-shape-structure-compositions (let [coverage (atom {}) failure (atom nil)] diff --git a/common/test/common_tests/logic/groups_test.cljc b/common/test/common_tests/logic/groups_test.cljc index 299c5c4217..61d0936600 100644 --- a/common/test/common_tests/logic/groups_test.cljc +++ b/common/test/common_tests/logic/groups_test.cljc @@ -144,3 +144,15 @@ tree (gm/set-objects-modifiers {(:id bool) {:modifiers (ctm/change-size bool 80 nil)}} objects) rect (gsh/transform-shape (get objects (thi/id :rect)) (get-in tree [(thi/id :rect) :modifiers]))] (t/is (mth/close? 80 (-> rect :selrect :width))))) + +(t/deftest a-bool-made-in-a-group-gives-the-group-its-bounds + (let [file (-> (thf/sample-file :file1) + (ths/add-sample-shape :badge :width 12 :height 12) + (ths/add-sample-shape :rect :x 10 :y 10 :width 20 :height 20)) + [id file] (group file [:badge :rect]) + page (thf/current-page file) + [shape changes] (clb/generate-create-bool nil (:id page) (:objects page) + [(thi/id :badge) (thi/id :rect)] :difference nil) + objects (objects (thf/apply-changes file changes))] + (t/is (= (-> (get objects (:id shape)) :selrect ((juxt :x :y :width :height))) + (-> (get objects id) :selrect ((juxt :x :y :width :height)))))))