From 1ed6476a53e20675ba02eced65c3f315b3ccb2a8 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 23 Oct 2026 14:51:30 +0200 Subject: [PATCH] :bug: Normalize newly allocated grid cells in the same assignment pass Assign positions after adding overflow cells so a second assignment leaves the grid unchanged. This keeps main and copy cell metadata in agreement. Fix F129. The red regression now passes; layout suite: 60 tests, 344 asserts. Benchmark ratios against Phase 1e: main 10/100/1000 0.46/0.52/0.53; three levels 0.47; chain 0.51; library 0.51; many shapes 0.49; variant switch 0.61. No regression flag. AI-assisted-by: GPT-6 --- common/src/app/common/types/shape/layout.cljc | 4 +++- .../test/common_tests/types/shape_layout_test.cljc | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/common/src/app/common/types/shape/layout.cljc b/common/src/app/common/types/shape/layout.cljc index e6e776d8a8..215d9709cf 100644 --- a/common/src/app/common/types/shape/layout.cljc +++ b/common/src/app/common/types/shape/layout.cljc @@ -1271,7 +1271,9 @@ ;; TODO: Remove after testing (assert (empty? (overlapping-cells parent)) (dm/str (overlapping-cells parent))) - (assoc parent :layout-grid-cells cells))))) + (-> parent + (assoc :layout-grid-cells cells) + (assign-cell-positions objects)))))) (defn free-cell-push "Frees the cell at index and push the shapes in the order given by the `cells` attribute" diff --git a/common/test/common_tests/types/shape_layout_test.cljc b/common/test/common_tests/types/shape_layout_test.cljc index 3aa0b08b95..d32ea5a6b6 100644 --- a/common/test/common_tests/types/shape_layout_test.cljc +++ b/common/test/common_tests/types/shape_layout_test.cljc @@ -1308,6 +1308,20 @@ ;; check-deassigned-cells ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(t/deftest assigning-overflow-cells-is-idempotent-after-a-manual-cell + (let [children [(make-shape) (make-shape)] + objects (into {} (map (juxt :id identity)) children) + parent (-> (make-grid-frame :shapes (mapv :id children)) + (layout/add-grid-row {:type :flex :value 1}) + (layout/add-grid-column {:type :flex :value 1})) + cell-id (first (keys (:layout-grid-cells parent))) + parent (-> parent + (assoc-in [:layout-grid-cells cell-id :shapes] [(:id (first children))]) + (assoc-in [:layout-grid-cells cell-id :position] :manual)) + assigned (layout/assign-cells parent objects)] + (t/is (= assigned (layout/assign-cells assigned objects))) + (t/is (= #{:manual} (into #{} (map :position) (vals (:layout-grid-cells assigned))))))) + (t/deftest check-deassigned-cells-test (t/testing "removes shape ids no longer in parent's shapes list" (let [old-id (uuid/next)