From babab40c93b8ce4b6d6c87561c6347666adf0afa Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Wed, 4 Nov 2026 06:59:00 +0100 Subject: [PATCH] :bug: Reassign the cells of an untouched grid without authoring them Updating shapes reassigns the cell positions of the grids among them. That reassignment ignored the update's touched options, so a layout reflow, which updates every layout without touching it, marked the cells of a copy grid as its own whenever they moved, as when a copy child switched to a hidden variant left its cell. Each grid reassigns its cells with the touched options of its own update. The model expects a copy grid's direction change to author its cells only when the change itself moves auto items, not when the reflow after it makes a cell manual. Benchmark (scripts/bench-components, ms, lower 2.5% quantile): | world | baseline | now | ratio | |------------------------------------+----------+---------+-------| | deepest-edit-through-three-levels | 35.215 | 21.005 | 0.60 | | edit-through-a-chain-of-dependents | 68.931 | 39.064 | 0.57 | | library-update-into-copies | 83.083 | 48.602 | 0.58 | | main-edit-among-many-shapes | 4.837 | 2.246 | 0.46 | | main-edit-into-10-copies | 1.79 | 0.984 | 0.55 | | main-edit-into-100-copies | 15.415 | 10.081 | 0.65 | | main-edit-into-1000-copies | 153.086 | 100.708 | 0.66 | | variant-switch-into-copies | 32.052 | 20.063 | 0.63 | AI-assisted-by: claude-opus-5-5 --- common/src/app/common/logic/shapes.cljc | 10 ++++++++-- .../test/common_tests/logic/composable_gen_test.cljc | 7 +++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/common/src/app/common/logic/shapes.cljc b/common/src/app/common/logic/shapes.cljc index 4e6e78b50e..413eb9964c 100644 --- a/common/src/app/common/logic/shapes.cljc +++ b/common/src/app/common/logic/shapes.cljc @@ -132,8 +132,14 @@ ids))) changes (cond-> changes (seq grid-ids) - (-> (pcb/update-shapes grid-ids ctl/assign-cell-positions {:with-objects? true}) - (pcb/reorder-grid-children ids)) + (as-> changes + ;; a grid the update does not touch reassigns its cells as a consequence + (reduce (fn [changes id] + (pcb/update-shapes changes [id] ctl/assign-cell-positions + {:with-objects? true + :ignore-touched (boolean (or (true? (get ignore-tree id)) ignore-touched))})) + changes grid-ids) + (pcb/reorder-grid-children changes ids)) (seq hidden-grid-ids) (-> (pcb/update-shapes hidden-grid-ids ctl/assign-cells diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 92a277349e..83677c227f 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -1077,3 +1077,10 @@ (t/is (map? (cg/run {:world [2 2 {:variants true :text-styles true :variant-diff false :rich-variants true :layout-copies true :text true}] :ops [[:resize 0 0 0 0] [:rotate 1 0 0 0] [:switch 4 0 0 0]]})))) + +(t/deftest generated-reflow-of-a-copy-grid-keeps-its-cells-inherited + ;; a copy child switched to a hidden variant leaves its grid cell; the + ;; layout reflow reassigns the copy grid's cells without authoring them + (t/is (map? (cg/run {:world [2 2 {:variants true :text-styles true :layout :grid :variant-diff false + :rich-variants true :layout-copies true :text true}] + :ops [[:nest 6 0 0 0] [:style 8 1 1] [:switch 4 0 0 0]]}))))