🐛 Give a reset head back its grid cell when it leaves absolute

A reset clears a copy head's own layout item values after its sync, so a
head made absolute in the copy came back into its parent grid's flow
after the cells had been assigned, and its cell stayed empty until a full
sync. The reset now assigns its grid parent's cells again at its end.

Benchmark (scripts/bench-components, ms, lower 2.5% quantile):

| world                              | baseline |    now | ratio |
|------------------------------------+----------+--------+-------|
| deepest-edit-through-three-levels  |   35.215 |   18.5 |  0.53 |
| edit-through-a-chain-of-dependents |   68.931 |  36.37 |  0.53 |
| library-update-into-copies         |   83.083 | 44.588 |  0.54 |
| main-edit-among-many-shapes        |    4.837 |   2.03 |  0.42 |
| main-edit-into-10-copies           |     1.79 |  0.953 |  0.53 |
| main-edit-into-100-copies          |   15.415 |    9.2 |   0.6 |
| main-edit-into-1000-copies         |  153.086 | 91.647 |   0.6 |
| variant-switch-into-copies         |   32.052 | 20.181 |  0.63 |

AI-assisted-by: claude-opus-5-5
This commit is contained in:
alonso.torres 2026-11-01 02:09:49 +01:00
parent b2757fdbb9
commit 9664a1ecc6
2 changed files with 13 additions and 2 deletions

View File

@ -2068,11 +2068,14 @@
(defn generate-reset-component
"Reset the copy head to its near main. A swapped head turns back into the
component of the main shape it refers to, keeping its id. A nested head
also takes its position's placement and inherited layout item values."
also takes its position's placement and inherited layout item values,
and its grid parent's cells follow when that takes it in or out of the
flow."
[changes file-full libraries container id]
(-> changes
(pcb/with-container container)
(pcb/with-objects (:objects container))
(generate-sync-shape-direct file-full libraries container id true)
(settle-reset-placement file-full libraries container id)
(reset-layout-item file-full libraries container id)))
(reset-layout-item file-full libraries container id)
(reassign-parent-grid-cells container id)))

View File

@ -881,3 +881,11 @@
(t/is (map? (cg/run {:world [2 2 {:variants true :text-styles true :layout :flex :library true
:rich-variants true :layout-copies true :text true}]
:ops [[:transform 7 0 0 8] [:delete 0] [:restore 0] [:add-child 9 0 0 0]]}))))
(t/deftest generated-reset-of-an-absolute-grid-head-gives-it-back-its-cell
;; a copy makes a nested head absolute and authors its grid's cells; the
;; reset takes the head back into the flow and into a cell
(t/is (map? (cg/run {:world [2 1 {:variants true :text-styles true :library-variants true :stale-libraries true
:layout :grid :library-depth 1 :library true :rich-variants true
:layout-children true :library-text true :layout-copies true :text true}]
:ops [[:style 11 35 1] [:grid-direction 13 0 0 1] [:grid-cell 13 0 0 1] [:reset 14 0 0 0]]}))))