Combining same-name components as variants gives each one the first
unused "Value N", in the order the mains enter the variant container.
`generate-combine-as-variants` moved all the remaining mains in one
relocation, which takes them in layer order, so the values followed the
layers and not the combine order. It now moves them one at a time, in
the order of the ids, as the frontend combine on develop does.
Test: `test-combine-as-variants-same-name-values-follow-combine-order`.
Benchmark (scripts/bench-components, ms, lower 2.5% quantile):
| :world | :baseline | :now | :mean | :ratio |
|------------------------------------+-----------+--------+--------+--------|
| deepest-edit-through-three-levels | 35.215 | 20.749 | 21.213 | 0.59 |
| edit-through-a-chain-of-dependents | 68.931 | 40.771 | 41.457 | 0.59 |
| library-update-into-copies | 83.083 | 50.674 | 51.835 | 0.61 |
| main-edit-among-many-shapes | 4.837 | 1.967 | 2.133 | 0.41 |
| main-edit-into-10-copies | 1.79 | 1.039 | 1.059 | 0.58 |
| main-edit-into-100-copies | 15.415 | 9.153 | 9.626 | 0.59 |
| main-edit-into-1000-copies | 153.086 | 93.347 | 99.626 | 0.61 |
| variant-switch-into-copies | 32.052 | 21.86 | 22.36 | 0.68 |
AI-assisted-by: claude-opus-5-5
Updating a main from a copy with a name override renamed the component
and its main to the copy's name. A variant takes its name from its
set, though, and every member carries it, so a renamed copy of a
variant left the file failing validation (a variant main and component
with a name other than their set's). Updating the main of a variant
copy now pushes everything but the name, and the copy keeps its name as
an override. The component model and its update-main check expect the
same.
Benchmark (scripts/bench-components, ms, lower 2.5% quantile):
| world | baseline | now | ratio |
|------------------------------------+----------+---------+-------|
| deepest-edit-through-three-levels | 35.215 | 20.618 | 0.59 |
| edit-through-a-chain-of-dependents | 68.931 | 40.714 | 0.59 |
| library-update-into-copies | 83.083 | 49.993 | 0.60 |
| main-edit-among-many-shapes | 4.837 | 2.112 | 0.44 |
| main-edit-into-10-copies | 1.790 | 1.105 | 0.62 |
| main-edit-into-100-copies | 15.415 | 9.427 | 0.61 |
| main-edit-into-1000-copies | 153.086 | 101.540 | 0.66 |
| variant-switch-into-copies | 32.052 | 21.918 | 0.68 |
AI-assisted-by: claude-opus-5-5
Undoing the creation of a component removed it from the file. A copy
another file had made of it in the meantime, as a consumer of a library
can after a variant is added there, then pointed at a component that
did not exist: the file failed validation, and the copy could not find
its main shapes or be restored. Undoing the creation now marks the
component deleted and keeps its main's shapes in it, as deleting it
does; redoing it adds it again.
The undo and redo checks of the component tests compare files without
their deleted components, since an undone creation leaves one where
there was none.
Benchmark (scripts/bench-components, ms, lower 2.5% quantile):
| world | baseline | now | ratio |
|------------------------------------+----------+---------+-------|
| deepest-edit-through-three-levels | 35.215 | 19.745 | 0.56 |
| edit-through-a-chain-of-dependents | 68.931 | 37.914 | 0.55 |
| library-update-into-copies | 83.083 | 48.026 | 0.58 |
| main-edit-among-many-shapes | 4.837 | 1.944 | 0.40 |
| main-edit-into-10-copies | 1.790 | 1.047 | 0.58 |
| main-edit-into-100-copies | 15.415 | 10.179 | 0.66 |
| main-edit-into-1000-copies | 153.086 | 91.854 | 0.60 |
| variant-switch-into-copies | 32.052 | 21.546 | 0.67 |
AI-assisted-by: claude-opus-5-5
Adding a variant, or duplicating a variant main into its set, gives the
new member a "Value n" in its last property. The values came from the
last entry of the properties grouped by name, which is a hash map once
a set has nine properties, so the count could come from another
property: with eight empty properties before "Property 9", the new
member took "Value 2", its source's value, and duplicated it.
Both actions now take, through one function, the first "Value n" no
member has at the position the value goes to, n counting up from one
more than the values there. Duplicating a variant main into its set
could also repeat a value in use after a member was deleted, as adding
a variant did.
Benchmark (scripts/bench-components, ms, lower 2.5% quantile):
| world | baseline | now | ratio |
|------------------------------------+----------+---------+-------|
| deepest-edit-through-three-levels | 35.215 | 20.529 | 0.58 |
| edit-through-a-chain-of-dependents | 68.931 | 40.136 | 0.58 |
| library-update-into-copies | 83.083 | 45.708 | 0.55 |
| main-edit-among-many-shapes | 4.837 | 1.972 | 0.41 |
| main-edit-into-10-copies | 1.790 | 0.920 | 0.51 |
| main-edit-into-100-copies | 15.415 | 9.714 | 0.63 |
| main-edit-into-1000-copies | 153.086 | 96.513 | 0.63 |
| variant-switch-into-copies | 32.052 | 21.386 | 0.67 |
AI-assisted-by: claude-opus-5-5
Adding a variant names the new member's last value "Value n", n one
more than the number of values that property has. Once a member is
deleted, that count can repeat a value still in use: after adding
"Value 3" and "Value 4" and deleting "Value 3", the next member added
from "Value 4" got "Value 4" again, the same properties as its source.
The new member takes the first "Value n" from that number up that no
member has.
Benchmark (scripts/bench-components, ms, lower 2.5% quantile):
| world | baseline | now | ratio |
|------------------------------------+----------+---------+-------|
| deepest-edit-through-three-levels | 35.215 | 21.352 | 0.61 |
| edit-through-a-chain-of-dependents | 68.931 | 39.364 | 0.57 |
| library-update-into-copies | 83.083 | 46.730 | 0.56 |
| main-edit-among-many-shapes | 4.837 | 1.943 | 0.40 |
| main-edit-into-10-copies | 1.790 | 1.051 | 0.59 |
| main-edit-into-100-copies | 15.415 | 9.726 | 0.63 |
| main-edit-into-1000-copies | 153.086 | 101.415 | 0.66 |
| variant-switch-into-copies | 32.052 | 20.744 | 0.65 |
AI-assisted-by: claude-opus-5-5
The namespace held 3,300 lines: component sync, instance creation and
detach, swap and the variant switch's attribute carry, duplication,
and the sync of library colors and typographies. Each now has its own
namespace:
- app.common.logic.libraries (cll): component sync, reset, update
main, attribute and placement sync, and the sync of a file with its
libraries;
- app.common.logic.instances (cli): create, instantiate and restore a
component, detach a copy;
- app.common.logic.swap (clsw): swap a copy head, carry overrides
across a variant switch;
- app.common.logic.duplicate (cld): duplicate components and shapes;
- app.common.logic.library-assets (clla): sync of library colors and
typographies, which the asset multimethods delegate to.
Each new namespace may require libraries, never the reverse; the
helpers they share became public there (attr-operations,
reposition-shape, orient-like, swap-content-root-id, ...). Callers use
the new aliases. The functions move as they were.
No behavior change: the golden masters and the suites are unchanged.
Benchmark (lower quantile, ms; baseline / now / ratio):
deepest-edit-through-three-levels 35.2 / 37.3 / 1.06
edit-through-a-chain-of-dependents 68.9 / 69.7 / 1.01
library-update-into-copies 83.1 / 79.8 / 0.96
main-edit-into-10-copies 1.8 / 1.6 / 0.92
main-edit-into-100-copies 15.4 / 15.4 / 1.00
main-edit-into-1000-copies 153.1 / 156.0 / 1.02
variant-switch-into-copies 32.1 / 27.0 / 0.84
AI-assisted-by: claude-opus-5-5
When components whose name matches the variant container are moved into
it, removing the container name leaves an empty value. Combining several
components named the same produced "Value 1" for the first variant and
empty values for the rest, so variants shared the same combination.
Assign the first unused "Value N" to the last property when all computed
values are blank, tracking values given within the same batch.
Combine moves the remaining mains into the container one at a time, in
the combine order, so the generated values follow that order instead of
the layer order.
Closes#12878