Skip to content

Unified selection: transforms - #142

Open
DaveMDS wants to merge 8 commits into
hew3d:mainfrom
DaveMDS:feat/unified-transforms
Open

DaveMDS wants to merge 8 commits into
hew3d:mainfrom
DaveMDS:feat/unified-transforms

Conversation

@DaveMDS

@DaveMDS DaveMDS commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Unified selection, part 2: transforms

Second of the three PRs planned in #106. Move, Rotate, Scale, Flip and their
copies and arrays carry the selected construction guides with the nodes, as
one undo step: the kernel and wasm-api half with its specs, then the app.

Kernel

Every addition sits beside an existing entry point, which now delegates to
it with no guides, so no existing signature or caller changes.

  • Document::transform_mixed_selection(nodes, sketches, guides, t), behind
    transform_selection.
  • Document::duplicate_mixed_placements(nodes, guides, placements, policy)
    and duplicate_mixed_array(nodes, guides, step, count, policy), behind
    duplicate_nodes_placements and duplicate_nodes_array. They return the
    guide copies beside the node roots, placement-major.
  • Document::flip_mixed and flip_mixed_copy, behind flip_nodes and
    flip_copy.

What they hold to:

  • All or nothing. Every guide is checked and posed before anything
    mutates. A stale or deleted guide refuses UnknownGuide, and a pose that
    breaks a guide refuses DegenerateGuide. Either refuses the whole batch,
    nodes included, with the document and its history untouched.
  • Recorded state, never a computed inverse. DocAction::TransformSelection
    gains guides: Vec<(GuideId, Guide)>, the prior geometry of each carried
    guide, the same posture as Rescale. Undo writes it back verbatim, and
    redo re-poses that same value. DocAction::DuplicatedArray gains
    guides: Vec<GuideId>, hidden on undo and shown on redo like the node
    copies, including inside LinkedCopies. Both are in-memory history only,
    so there is no .hew change.
  • One step. Nodes and guides share one entry. A transform of guides
    alone is the transform kind with the new noun guide ("Move 2
    guides"), and the counts take in the guides. A copy of guides alone is
    recorded as DuplicatedGuides, as duplicate_guide_array records it.
  • Copied guides are independent. LinkPolicy::Linked links the nodes
    only.
  • Annotations are not listed. One anchored to a moving node already
    follows it, once. One anchored elsewhere stays where it is.
  • Flip takes its mirror plane from the nodes and sketches alone. Guides
    with nothing else selected refuse EmptySelection, and the app will say
    there is nothing to flip. Scale will refuse the same way, since it sizes
    its grips from the nodes.
  • A guide listed twice moves once in a transform. In a copy it refuses
    DuplicateMember, as a node listed twice does.
  • An empty selection keeps the existing EmptySelection refusal rather than
    becoming a no-op, which is what transform_selection has always answered.

wasm-api (additive)

New Scene methods, beside the existing ones, which are unchanged and keep
their recorded shapes:

  • transform_mixed_selection(kinds, ids, sketches, guides, affine)
  • duplicate_mixed_selection_array(kinds, ids, guides, affine, count, linked)
  • duplicate_mixed_selection_placements(kinds, ids, guides, affines, linked)
  • flip_mixed_selection(kinds, ids, sketch_ids, guides, nx, ny, nz, about_kind, ax, ay, az, copy)

The three copy methods return {"nodes":[...],"linked":[...],"guides":[...]},
the existing linked JSON plus the guide copies.

New additive RecordedCall variants: TransformMixedSelection,
DuplicateMixedSelectionArray, DuplicateMixedSelectionPlacements and
FlipMixedSelection, documented in DIAGNOSTICS.md. Existing recordings
replay unchanged.

Specs

  • crates/kernel/tests/mixed_transform_specs.rs. Each mixed operation is
    checked against a twin document that reaches the same state through the
    existing single-kind operations, and must match it in one undo step that
    undo and redo reproduce bit for bit. Also covered: stale, deleted, listed
    twice, degenerate and singular refusals; guides alone; linked copies;
    flip; an anchored annotation moving once. A property test runs random
    selections through moves, rotations, scales and reflections, then an
    array copy.
  • session_fuzz.rs gains a mixed transform and a mixed copy array, each
    salted with a stale guide handle.
  • wasm-api tests for each method, and a record/replay round trip.

App

Which guides a tool carries:

  • Move and Rotate carry every selected guide when nodes are selected
    too, or when several guides are selected alone. A single guide selected
    alone keeps its existing path (transform_guide, duplicate_guide_array,
    the click that takes a guide), unchanged.
  • Scale and Flip carry every selected guide with the nodes. Their grips
    and mirror plane come from the nodes alone, so guides with nothing else
    selected are refused with "Nothing to scale" or "Nothing to flip", and the
    status bar says why.

What each tool does with them:

  • Move: a move, a copy, an ×N or /N array, a grid
    (duplicate_mixed_selection_placements) and a retyped distance. A grid of
    guides alone is refused, as a grid of one guide already is: its copies
    would stack along each guide's own line. A Select drag on a selected node
    carries the selected guides too.
  • Rotate: a rotation, a copy, an ×N or /N fan and a retyped angle. With
    guides alone, the click sets their pivot.
  • Scale: the scale and a retyped factor or dimension.
  • Flip: in place through flip_mixed_selection, and a linked or
    independent mirrored copy that copies the guides beside the nodes. Beside
    drawing with no solid, the kernel has nothing to center a flip on, so the
    guides take the same flip matrix the drawing takes
    (transform_mixed_selection, duplicate_mixed_selection_array). Object ▸
    Flip Along carries them too.

Common to all four:

  • Every copy joins the new selection, nodes and guides, so a follow-up
    transform chains off the copies.
  • The ghost shows the guides beside the nodes (withGuidePreviews, shared
    by the four tools).
  • Inside a component session the members go through the definition as
    before, and the guides take the world transform through
    transform_mixed_selection in the same history bracket: one undo step.
    A mirrored copy inside a component stays refused, as before.
  • Undo names the step by what moved ("Move 2 items", "Move 2 guides").

App tests:

  • Mocked-kernel unit tests per tool (*.guides.test.ts) for each path above,
    checked by mutation: removing the guides from a commit or an array fails
    them.
  • Real-kernel tests: transformSelection.guides.wasm.test.ts and
    FlipTool.guides.test.ts check one undo step that undo and redo reproduce
    exactly, a stale guide refusing with the document untouched, and the
    mirror plane ignoring the guides.
  • E2E: mixed-selection.spec.ts (Move with a retyped distance, a Select
    drag, Rotate, each undone in one step) and flip.spec.ts (two boards and
    a guide across the blue plane).

New strings are in the catalogs, with German translations.

Plugin bus

Unchanged. hew.entity.move, rotate, scale and flip act on explicit
node ids rather than on the selection. Extending them to guides would be new
bus surface, to discuss separately if it is wanted.

Docs

  • The user guide (Moving and transforming, Measurement and guides),
    docs/agents/ROADMAP.md and docs/agents/ARCHITECTURE.md §2.9 describe
    the carried guides.
  • A second commit brings the user guide and the roadmap up to date with
    part 1's mixed selection (click modifiers, marquee, Select All, Object
    Info counts, the mixed Delete), which that PR left undocumented.

@DaveMDS
DaveMDS force-pushed the feat/unified-transforms branch from 2fa7abc to 34799a2 Compare November 22, 2026 09:43
… copies

Document::transform_mixed_selection moves, rotates, or scales a selection
that also holds construction guides as one undo step: each guide is carried
as transform_guide carries one, beside the nodes and sketches. Its
neighbours do the same for copies and mirrors: duplicate_mixed_placements
and duplicate_mixed_array copy each guide once per placement with the
nodes, and flip_mixed and flip_mixed_copy reflect or mirror-copy the guides
across the plane the nodes name. The existing entry points delegate to them
with no guides, so their behavior and callers are unchanged.

Every guide is checked and posed before anything mutates: a stale or
deleted guide, or a pose that would break one, refuses the whole batch,
nodes included, with the document and its history untouched.

TransformSelection records each carried guide's prior geometry; undo writes
it back verbatim and redo re-poses that same value, so undo and redo
reproduce the commit bit for bit. DuplicatedArray records its guide copies,
hidden on undo and shown on redo like the node copies, also inside a linked
copy. Copied guides are always independent: linking is a property of
component definitions, and a guide has none. A copy of guides alone is
recorded as a guide array, and a transform of guides alone names its step
for guides.

The mirror plane of a flip comes from the nodes and sketches alone, so
guides with nothing else listed refuse as an empty selection. Annotations
are not listed: one anchored to a moving node already follows it, once.

The specs compare each mixed operation with a twin document that reaches
the same state through the single-kind operations, with a property over
random selections and transforms. The session fuzz harness gains a mixed
transform and a mixed copy array, each also salted with a stale guide.

Signed-off-by: Dave Andreoli <dave@gurumeditation.it>
Scene gains transform_mixed_selection, duplicate_mixed_selection_array,
duplicate_mixed_selection_placements and flip_mixed_selection: the
existing selection transform, array copy, grid copy and flip, each taking
the selection's construction guides beside its nodes, in the same one undo
step. The copy methods return the linked-copy JSON with the guide copies
beside it, so a caller can select them.

Each records under a new additive RecordedCall variant, documented in
DIAGNOSTICS.md. The existing methods keep their signatures and their
recorded shapes, so every existing recording replays unchanged, and a new
recording that uses a mixed method fails to parse on an older build,
loudly.

Signed-off-by: Dave Andreoli <dave@gurumeditation.it>
…y fuzz

The mixed transform and copy arms of the session fuzz accepted any
refusal that left the document untouched, so a wrong error on a valid
selection went unnoticed. They now hold the mixed delete's standard:
with every handle live, a refusal must be one the kernel documents for
that listing — a lock on a moved node, an open session refusing outside
geometry, a linked copy of a node beside the group that holds it, or a
transform of nodes that flatten to nothing with no guide listed. Any
other refusal fails the case.

The mixed picks now take only world nodes, as the mixed delete's do, so
a definition member no longer reaches these arms as a handle that is
always refused.

Signed-off-by: Dave Andreoli <dave@gurumeditation.it>
Guides selected with nodes, or several guides at once, move with the
selection in one undo step through transform_mixed_selection, and a
copy, an ×N / /N array or a grid copies them beside the nodes through
the mixed duplicate calls, every copy joining the new selection. Inside
a component session the guides take their own world transform in the
same history bracket as the members. A Select drag on a selected node
carries the selected guides too. A grid of guides alone is refused, as
for a single guide: its copies would stack along each guide's own line.

Signed-off-by: Dave Andreoli <dave@gurumeditation.it>
Guides selected with nodes, or several guides at once, rotate with the
selection in one undo step through transform_mixed_selection, and a
copy or an ×N / /N array copies them beside the nodes through
duplicate_mixed_selection_array, every copy joining the new selection.
With guides alone the click sets their pivot. The node and guide ghost
is now shared with Move (withGuidePreviews).

Signed-off-by: Dave Andreoli <dave@gurumeditation.it>
Guides selected with nodes scale and mirror with them in one undo step,
through transform_mixed_selection and flip_mixed_selection, and a
mirrored copy copies them beside the nodes' copies, every copy joining
the new selection. Object > Flip Along carries them too. The grips and
the mirror plane come from the nodes alone, so guides with nothing else
selected are refused: there is nothing to scale or flip.

Signed-off-by: Dave Andreoli <dave@gurumeditation.it>
@DaveMDS
DaveMDS force-pushed the feat/unified-transforms branch from 34799a2 to d02bc5a Compare November 24, 2026 16:49
The user guide says how guides selected with objects, or several guides
at once, move, rotate, scale and mirror with the selection, copies and
arrays included, and when they are refused: a grid of guides alone, and
guides alone in Scale and Flip. The roadmap records the carried guides
and the mixed kernel and wasm-api calls behind them, and the
architecture notes how a transform or copy records its guides in one
undo entry.

Signed-off-by: Dave Andreoli <dave@gurumeditation.it>
…odes

The user guide still described a selection of nodes beside at most one
guide or annotation. It now says that a click, every click modifier, a
marquee and Select All take guides, dimensions and text as they take
objects, that an endless guide line is taken only by a crossing, that
Object Info counts a mixed selection per kind, and that Delete removes
it all as one undo step named by what it took. The roadmap records the
ordered mixed selection and the mixed delete.

Signed-off-by: Dave Andreoli <dave@gurumeditation.it>
@DaveMDS
DaveMDS marked this pull request as ready for review November 24, 2026 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant