🐛 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
This commit is contained in:
alonso.torres 2026-10-23 14:51:30 +02:00
parent 4e7cca7ff4
commit 1ed6476a53
2 changed files with 17 additions and 1 deletions

View File

@ -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"

View File

@ -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)