🐛 Mark a pasted copy's geometry only when it changes parent

A copy duplicated in place under a stale library differs from its
updated main, and the check that keeps a pasted copy's look marked its
geometry although its source had none marked. The check now applies only
to a copy that lands under a parent other than its source's. The harness
model authors a pasted copy's geometry where it lands when its source
authored it, and when another parent gave it its orientation or size.

Benchmark (lower quantile, ms):

| world                              | baseline |     now |    mean | ratio |
|------------------------------------+----------+---------+---------+-------|
| deepest-edit-through-three-levels  |   35.215 |  21.980 |  22.894 |  0.62 |
| edit-through-a-chain-of-dependents |   68.931 |  43.830 |  44.755 |  0.64 |
| library-update-into-copies         |   83.083 |  53.028 |  54.143 |  0.64 |
| main-edit-among-many-shapes        |    4.837 |   2.352 |   2.487 |  0.49 |
| main-edit-into-10-copies           |    1.79  |   1.103 |   1.125 |  0.62 |
| main-edit-into-100-copies          |   15.415 |  10.851 |  11.191 |  0.70 |
| main-edit-into-1000-copies         |  153.086 | 108.036 | 112.301 |  0.71 |
| variant-switch-into-copies         |   32.052 |  22.906 |  23.847 |  0.71 |

AI-assisted-by: claude-opus-5-5
This commit is contained in:
alonso.torres 2026-11-14 00:50:45 +01:00
parent f8f378ac74
commit d4471ea9fb
2 changed files with 19 additions and 3 deletions

View File

@ -552,11 +552,14 @@
objects (pcb/get-objects changes)
;; the new copies that no other copy holds
;; the new copies that no other copy holds, under a parent other than
;; the one their source has on the page
heads (filterv (fn [id]
(let [shape (get objects id)]
(let [shape (get objects id)
source (some (fn [[old new]] (when (= new id) old)) ids-map)]
(and (ctk/instance-head? shape)
(= 1 (count (ctn/get-parent-copy-heads objects shape))))))
(= 1 (count (ctn/get-parent-copy-heads objects shape)))
(not= (:parent-id shape) (get-in page [:objects source :parent-id])))))
(keep ids-map ids))]
(-> changes

View File

@ -4294,3 +4294,16 @@
:layout-copies true :layout-children false}]
:ops [[:transform 7 0 0 8] [:detach 6 0 0 0] [:add-child 0] [:structure 0 2 0]
[:sync 0 0 0 0]]}))))
(t/deftest generated-a-duplicate-in-place-or-a-paste-marks-only-the-geometry-it-moves
;; a stale copy duplicated in place marks nothing; a pasted copy keeps what
;; it authored where it lands
(t/is (map? (cg/run {:world [2 0 {:variants true :text-styles false :library-variants false :stale-libraries true
:layout nil :layout-item-margins false :grid-square false :library-depth 2
:library true :rich-variants false :layout-children false :library-text false
:grid-empty false :layout-copies false :text false}]
:ops [[:library-delete 1] [:library-restore] [:library-transform 11 5] [:duplicate 11]]})))
(t/is (map? (cg/run {:world [2 0 {:variants true :text-styles false :layout :grid :layout-item-margins false
:grid-square false :library true :rich-variants true :layout-children false
:grid-empty false :layout-copies false :text true}]
:ops [[:switch 11] [:switch 5] [:nest 17] [:add-child 15] [:rotate 15] [:style 12 9 1] [:paste 12]]}))))