🐛 Make an update main into a nested copy author the sizing it fixes

An update main that pushes a transformed fill child into the nested copy
its main holds fixes that copy's layout sizing, as a resize does, so the
layout keeps the pushed size. It did not mark the sizing as the nested
copy's own override: the copy differed from its reference without an
override, and the next sync would give it the fill back and undo the
pushed size (F588, reachable since moves are generated).

A main that is itself a copy now touches the sizing groups the push
fixes. The composable model expects it to author them.

Test: generated
`generated-an-update-main-into-a-nested-copy-authors-the-sizing-it-fixes`
(JVM and frontend replay).

Benchmark (bench-components, alone):

|                             :world | :baseline |   :now |   :mean | :ratio |
|------------------------------------+-----------+--------+---------+--------|
|  deepest-edit-through-three-levels |    35.215 | 21.333 |   22.41 |   0.61 |
| edit-through-a-chain-of-dependents |    68.931 | 42.992 |  44.734 |   0.62 |
|         library-update-into-copies |    83.083 | 55.577 |  58.064 |   0.67 |
|        main-edit-among-many-shapes |     4.837 |  2.625 |   3.164 |   0.54 |
|           main-edit-into-10-copies |      1.79 |  1.131 |   1.216 |   0.63 |
|          main-edit-into-100-copies |    15.415 | 11.226 |  12.849 |   0.73 |
|         main-edit-into-1000-copies |   153.086 | 103.22 | 108.455 |   0.67 |
|         variant-switch-into-copies |    32.052 |  23.27 |  24.267 |   0.73 |

AI-assisted-by: claude-opus-5-5
This commit is contained in:
alonso.torres 2026-11-17 11:47:05 +01:00
parent 56ef4e88d7
commit 61ba182549
4 changed files with 26 additions and 2 deletions

View File

@ -1181,9 +1181,13 @@
(and keep-name? (ctk/touched-group? shape-inst :name-group))
(conj :name-group))))
;; A previous update is not a reset of the main's authored
;; overrides. Repeating it must retain the groups it pushed.
;; overrides. Repeating it must retain the groups it pushed,
;; and a main that is itself a copy authors the sizing the
;; push fixes.
(set-touched shape-main main-container
(set/union (:touched shape-main) (set/difference inst-touched kept-items))))
(cond-> (set/union (:touched shape-main) (set/difference inst-touched kept-items))
(:shape-ref shape-main)
(into (map #(ctk/resolve-sync-group (:type shape-main) %)) (keys fixed)))))
(ctsl/any-layout? shape-main)
(update-layout-children main-container shape-main shape-inst
#(ctf/get-shape-in-copy container % shape-inst) false)

View File

@ -612,6 +612,16 @@
(update id merge kept-items)
kept-name
(assoc-in [id :name-group] kept-name)
;; a main that is itself a copy authors the layout sizing a
;; pushed geometry fixes on it, which keeps the pushed size
(and (:shape-ref ref) (contains? groups :geometry-group))
(update (:id ref) merge
(into {}
(keep (fn [group]
(when (not= (get (get before (:id ref)) group) (get ref group))
[group (values ref group)])))
[:layout-item-h-sizing :layout-item-v-sizing]))
(and (:shape-ref ref) (seq groups))
(update (:id ref)
(fn [main-groups]

View File

@ -4469,3 +4469,8 @@
:layout-copies true :layout-children false}]
:ops [[:remove-child 0 0 0 0] [:add-child 1] [:structure 0 4 0] [:transform 0 16 0 3]
[:rotate 0 0 0 0] [:rotate 1 0 0 0]]}))))
(t/deftest generated-an-update-main-into-a-nested-copy-authors-the-sizing-it-fixes
;; a copy child filling a row pushes a transform into the nested copy its
;; main holds, which takes it with its sizing fixed as its own override
(t/is (map? (cg/run {:world [3 2 {:text true :layout :flex}] :ops [[:nest 24 11 9 6] [:delete 1] [:restore 1] [:add-child 15 16 4 29] [:move 23 24 12 20] [:edit 25 25 27 25] [:undo 23 17 15 25] [:style 23 29 25 20] [:transform 29 11 7 27] [:update-main 2 19 2 29]]}))))

View File

@ -1191,3 +1191,8 @@
(pr-str (merge-with - (select-keys after [:pass :fail :error])
(select-keys before [:pass :fail :error]))))))
(recur (inc index)))))))
(t/deftest ^:async generated-an-update-main-into-a-nested-copy-authors-the-sizing-it-fixes
;; a copy child filling a row pushes a transform into the nested copy its
;; main holds, which takes it with its sizing fixed as its own override
(await (replay {:world [3 2 {:text true :layout :flex}] :ops [[:nest 24 11 9 6] [:delete 1] [:restore 1] [:add-child 15 16 4 29] [:move 23 24 12 20] [:edit 25 25 27 25] [:undo 23 17 15 25] [:style 23 29 25 20] [:transform 29 11 7 27] [:update-main 2 19 2 29]]})))