Plan for the next session: attach in touch mode
Status tags are used throughout. Nothing in this plan has been run, and anything marked Verify or Open is unread or undecided.
1. Where things stand
- Decided:
bench-split-6-collideis merged intomain, and the owner reports all tests and the build pass. - Decided: the fix for
app/i18n.test.mjs(it now readssrc/bench/*.ts) and thetouchUiguard inbench/config.tswent in as one commit. - Still open from the handover:
- whether
collide-client,collide-storeandcollide.workerbelong inbench/; - the settings registry (
roadmap/next/settings-registry.md), which comes after attach unless the owner says otherwise.
- whether
2. The design for ui=touch (owner's words, restated)
Decided:
- The user taps a part in the scene. This is the target. The history list, Select and Pick are not used.
- In attach mode the gizmo sits on the target. It cycles through the target's open connector types. "Open" means the a least on connector of that type has no mate.
- Cycling sets the padlocks. A wall part is locked when it has no connector that fits the cycled type.
- The user picks an unlocked part from the wall. It previews on the attachment point with the lowest index eg stud[0], and the gizmo moves to the previewed part.
- On the previewed part the gizmo does three jobs:
- it moves the part between mate points when there are several; it is not a 'free' move mode so cannot be moved to be unattached.
- it changes rotation while the part stays connected;
- it shows a collision warning.
- The preview is held uncommitted, because that is the simpler option. Cancel drops it. Confirming commits one
putop. - Cancel and Undo already exist. Undo is not the way back from the preview, because nothing is committed until confirm.
- A move or rotate after a placement is a new mate. Nothing is released or recorded.
- "Used" means the connector already has a mate. Touching or overlapping alone does not count.
- The wall's connector types are precomputed. The collision warning replaces the "collide priority" big list which is still use in other modes.
Proposed (not yet confirmed by the owner):
- The gizmo's "type" is the key
(kind, sub, polarity), notConnector.type. Compatibility depends on those three fields, so cycling bytypealone would be wrong. - Rotation while connected is the discrete set the code already has: four yaws, plus flip where the joint allows it. It is not free rotation.
- Moving between mate points means candidates with the same cycled type but a different
to.indexorby.index.
3. What the code does today (read, not run)
attach-ui.ts
- It is a fieldset panel with a relation select, a position select, a Go button and a status line.
- It works whenever a placed part is selected and a palette part is held (
ctx.activeRow). - It builds candidates with
jointCandidates(sel, act.stem, rel)plustouchCandidates, and rebuilds when a key changes: target id and pose, held stem, relation, andsceneKey. host.rank()asynchronously returnsclear,hitorunknownper candidate, andseatedOverlapexempts pin-in-hole and open-stud joints.- Go calls
host.commit(c, sel.id).
bench/actions.ts
putCandidatepushes{ k: 'put', id, row, pose, to, joined, exempt }. It drops the candidate'stoandbyaddresses.cancelclearsactiveRowfirst, thenselId.undoandredoonly movectx.cursor.
bench/state.ts
derive()builds placed parts asrecposes and never builds anAssembly, so no mate record exists.- Anchors (stem
85861) are ordinary entries inrecs. buildExtentshows the LDraw conversion:[...rec.m, rec.x, -rec.y, -rec.z].
bench/input.ts line 144: in touch mode, tapping a wall part does pick(); place(), which puts it on the free anchor. With a target selected this must change to pick and preview.
snap/graph.ts and snap/pairs.ts
connectionsFor(parts: PosedPart[], index, cat)returns the edges between one part and the rest.PosedPartis{ stem, pose }in LDraw space.GEdge.aConnandGEdge.bConnare native connector indices, the same asConnector.nativeIndex.findPairsuses a spatial hash withPOS_THR = 3and passes each candidate throughjudge(). Onlyfastandextraverdicts become edges, so merely touching parts do not count.judge()rules:- Stud and hole pairs use
STUD_MATE_MAT, with a signed axis dot of at least 0.95. - Hinge and ball need the same
subEncand opposite polarity, and hinge also needs an axis match. - Fixed uses a position, axis and frame-trace test.
- Axles use
AXLE_MATE_MAT, an overlap rule and a wider search radius.
- Stud and hole pairs use
graph.tsis not exported fromagent.ts. The bench would import it directly.connectionsForis only called fromgraph.test.ts. It is a new call from the bench.data().catalogis available once the attach data has loaded, andbench.tsalready loads it at start.Connhaskind,sub,pol,subIdx,length,subEnc,polEncandframe.
4. The open-connector list (Decided method, not built)
- Build
PosedPart[]fromst().recswith thebuildExtentconversion. - Get the target index from
st().idx.get(ctx.selId). - Call
connectionsFor(parts, index, data().catalog). - For each edge, the used connector on the target is
aConnifa === index, otherwisebConn. - Open list =
info(stem).connsindices minus the used set. Wrap each as aConnectorforcompatible()andplacement(). - Group by
(kind, sub, pol). Those groups are the gizmo's cycle. - Rebuild on selection change and scene change, using the same trigger as the picker's
sceneKey.
5. Padlocks
- Static layer: for each distinct wall stem, read its connector keys once from
connectors(stem)and cache them. The cache never changes during a session. - Dynamic layer: for the target's current cycled key, a wall stem is locked if none of its connectors satisfies
compatible()with that key. - The lookup can use
STUD_MATESandAXLE_MATESfromcatalog.ts, and same-subopposite-polfor hinge, ball and fixed.
6. Work order
- Read first (no code):
snap/catalog.tslines 54-135 (theCatalogclass and whether anchor stem85861has connectors);bench/input.ts,bench/scene.ts,bench/rows.ts,bench/palette.tsandbench.tsin full;- the 15 Nov post "Bench anchors as parts, floating wall and cameras", to learn how the wall is built and how a wall part maps to a stem;
- whether any gizmo code already exists (Verify, not found in the files read).
- Finish the design with the owner (no code): settle the three Open items in section 7.
- Build in small commits, one step each, on a new branch:
- The open-connector function (pure, no UI) with a test against
connectionsForon two stacked bricks. Runnpm testinapp. - The per-stem connector-key cache and the padlock lookup, with a test.
- An attach-mode state in
ctx(target, cycled key, preview candidate), and the touch tap change atinput.tsline 144. - The preview: show the candidate pose uncommitted, with Cancel dropping it and confirm calling
putCandidate. - The gizmo controls: cycle type, step mate points, step yaw and flip, and show the rank result as the warning.
- Retire the picker panel's relation select, position select and big list once the gizmo covers them.
- The open-connector function (pure, no UI) with a test against
- Test on the real phone with
?ui=touch. Report theanchors.tsphone check at the same time.
7. Open design questions
- Relation (
on,under,front,behind,left,right): the new flow has no relation select.jointCandidatesneeds one. It could become a facet of the gizmo, or default to all relations. Note: relational positioning is not attach it is PLACE. - Touch candidates (
touchCandidates): they have no connector, so they do not fit the connector cycle. Keep them as a fallback or drop them. - Which part of the gizmo the user can reach on a phone: the controls are handles in the scene around the active part.
8. Rules for the next Claude
- Follow
CLAUDE.md. Read the code before writing, and say "untested" or "not read" on every unchecked claim. - Ask at most one question per reply, and put it last. Do not ask what the code can answer.
- This starts as a design session. Write no code until the owner says build.
- When building, give Python patch scripts with
count == 1anchors, thengit diff --statandnpx tsc --noEmit -p app. The owner runsnpm testinsideapp, and the snap tests areapp/src/snap/*.test.ts. - The
devworkspace has notestscript. Runnode --test changelog.test.mjsfromdevif needed. - At session end, the usual script writes the blog post, changelog entries (plain sentences for visitors) and roadmap items. This session produced no script, only this plan.