From 3d1ea0b5993f7727da38cb506cbd526e41fe1be7 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Thu, 12 Nov 2026 13:25:36 +0100 Subject: [PATCH] :bug: Scale the shapes of a bool with it, as a group's A resize reaches the shapes of a group or bool through their constraints, and a bool takes its bounds from its shapes. Grouping sets its shapes' constraints to scale for this, but creating a bool kept theirs: a bool made of a shape constrained to the left could not be resized, since its shape kept its width and the bool its bounds. A bool now sets the constraints of its shapes to scale, as a group does. Test: resizing-a-bool-resizes-the-shapes-it-combines (found by a shape structure program of seed 498). Benchmark (scripts/bench-components, ms, lower 2.5% quantile), with a 3 GB heap while a second devenv ran on the machine; no benchmark world creates a bool, and the two higher ratios are that load: | :world | :baseline | :now | :mean | :ratio | |------------------------------------+-----------+---------+---------+--------| | deepest-edit-through-three-levels | 35.215 | 21.819 | 24.186 | 0.62 | | edit-through-a-chain-of-dependents | 68.931 | 49.562 | 52.525 | 0.72 | | library-update-into-copies | 83.083 | 57.254 | 63.14 | 0.69 | | main-edit-among-many-shapes | 4.837 | 2.973 | 3.289 | 0.61 | | main-edit-into-10-copies | 1.79 | 1.551 | 2.602 | 0.87 | | main-edit-into-100-copies | 15.415 | 15.578 | 24.16 | 1.01 | | main-edit-into-1000-copies | 153.086 | 107.415 | 126.523 | 0.7 | | variant-switch-into-copies | 32.052 | 25.21 | 26.393 | 0.79 | AI-assisted-by: claude-opus-5-5 --- common/src/app/common/logic/bool.cljc | 6 ++++++ common/test/common_tests/logic/groups_test.cljc | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/common/src/app/common/logic/bool.cljc b/common/src/app/common/logic/bool.cljc index a5f3d0b484..129fdb280b 100644 --- a/common/src/app/common/logic/bool.cljc +++ b/common/src/app/common/logic/bool.cljc @@ -118,6 +118,12 @@ (-> (pcb/empty-changes it page-id) (pcb/with-objects objects) (pcb/add-object shape {:index (inc index)}) + ;; as a group's, the shapes of a bool scale with it + (pcb/update-shapes (map :id shapes) + (fn [shape] + (-> shape + (d/assoc-when :constraints-h :scale) + (d/assoc-when :constraints-v :scale)))) (pcb/update-shapes (map :id shapes) ctl/remove-layout-item-data) (pcb/change-parent shape-id shapes) (cond-> target-cell diff --git a/common/test/common_tests/logic/groups_test.cljc b/common/test/common_tests/logic/groups_test.cljc index 3a812b815c..299c5c4217 100644 --- a/common/test/common_tests/logic/groups_test.cljc +++ b/common/test/common_tests/logic/groups_test.cljc @@ -7,13 +7,17 @@ (ns common-tests.logic.groups-test (:require [app.common.files.changes-builder :as pcb] + [app.common.geom.modifiers :as gm] + [app.common.geom.shapes :as gsh] [app.common.logic.bool :as clb] [app.common.logic.groups :as clg] + [app.common.math :as mth] [app.common.test-helpers.components :as thc] [app.common.test-helpers.compositions :as tho] [app.common.test-helpers.files :as thf] [app.common.test-helpers.ids-map :as thi] [app.common.test-helpers.shapes :as ths] + [app.common.types.modifiers :as ctm] [app.common.types.shape.layout :as ctl] [app.common.uuid :as uuid] [clojure.test :as t])) @@ -127,3 +131,16 @@ (t/is (= (thi/id :copy-root) (:parent-id rect))) (t/is (= 0.5 (:opacity rect))) (t/is (= #{:layer-effects-group} (:touched rect))))) + +(t/deftest resizing-a-bool-resizes-the-shapes-it-combines + (let [file (-> (thf/sample-file :file1) + (tho/add-frame :board :width 200 :height 200) + (ths/add-sample-shape :rect :parent-label :board :width 50 :height 50 + :constraints-h :left :constraints-v :top)) + page (thf/current-page file) + [shape changes] (clb/generate-create-bool nil (:id page) (:objects page) [(thi/id :rect)] :union nil) + objects (objects (thf/apply-changes file changes)) + bool (get objects (:id shape)) + 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)))))