🐛 Keep the parent's turn out of an update main of a resized top copy

A top copy turned with its parent board keeps that turn when the board
is detached. Resizing the copy gives it a geometry of its own, and
update main then pushed the board's turn into the main, while sync
composes the copy with its parent's turn again: the copy turned twice.
Update main now turns back the parent's turn for a top copy root with
its own geometry, as it does for nested roots; under an unturned parent
that is no turn.

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

| world                              | baseline |     now | ratio |
|------------------------------------+----------+---------+-------|
| deepest-edit-through-three-levels  |   35.215 |  19.207 |  0.55 |
| edit-through-a-chain-of-dependents |   68.931 |  37.719 |  0.55 |
| library-update-into-copies         |   83.083 |  47.009 |  0.57 |
| main-edit-among-many-shapes        |    4.837 |    2.17 |  0.45 |
| main-edit-into-10-copies           |     1.79 |   1.039 |  0.58 |
| main-edit-into-100-copies          |   15.415 |  10.179 |  0.66 |
| main-edit-into-1000-copies         |  153.086 | 101.906 |  0.67 |
| variant-switch-into-copies         |   32.052 |  20.838 |  0.65 |

AI-assisted-by: claude-opus-5-5
This commit is contained in:
alonso.torres 2026-11-02 22:02:53 +01:00
parent c13dcdd71f
commit 0b30155159
2 changed files with 13 additions and 5 deletions

View File

@ -780,11 +780,11 @@
:root-main root-main
;; An orientation the copy root inherits places it
;; and is not pushed into the main. Sync composes a
;; nested root with its parent's turn; a top copy
;; root owns its turn only when it authors geometry.
:inherited-turn (if (:component-root shape-inst)
(when-not (ctk/touched-group? shape-inst :geometry-group)
(orient-like shape-inst root-main center))
;; root with its parent's turn; a top copy root that
;; does not author its geometry inherits all of it.
:inherited-turn (if (and (:component-root shape-inst)
(not (ctk/touched-group? shape-inst :geometry-group)))
(orient-like shape-inst root-main center)
(when-let [parent (ctn/get-shape container (:parent-id shape-inst))]
(orient-like parent
(or (ctn/get-shape main-container (:parent-id root-main)) {})

View File

@ -1004,3 +1004,11 @@
:layout-copies true :text true}]
:ops [[:nest 0 0 0 0] [:text-style 0 1 1] [:duplicate 0 0 0 0]
[:update-main 1 0 0 0] [:text-style 0 0 1]]}))))
(t/deftest generated-resized-copy-in-a-turned-board-pushes-its-own-turn
;; a copy turned with a board that is detached and then resized pushes its
;; size to its main but not the board's turn, which sync gives it back
(t/is (map? (cg/run {:world [2 2 {:variants true :text-styles true :library true :rich-variants true
:layout-copies true :text true}]
:ops [[:rotate 15 0 0 0] [:detach 15 0 0 0] [:delete 5] [:restore 5]
[:resize 14 0 0 0] [:edit 3 0 1 1] [:update-main 3]]}))))