Brickheart

Handover bench touch page 10 Nov 2026

: Written by a human with AI assistance.

For the next Claude. Read this together with the "Bench plan 09NOV2026" document, which stays the master plan. Where this handover disagrees with it, this handover wins.

1. How to work with the owner

  • Ask, don't assume. Gather data with terminal commands (Ubuntu, VS Code, repo /home/chinapal/brickheart-web). "DATA not assumption."
  • Plan vs build. Check which mode you're in before acting. The owner has asked "are we in plan or build?" once already.
  • Edits come as patch scripts. Use Python with exact-match anchors that assert count == 1 and change nothing if an anchor is missing. Then git diff --stat, and npx tsc --noEmit -p app. Give only the edits, not long explanations. Git exists, so don't be timid.
  • "Backlog" means not today. Acknowledge it, record it, move on.
  • You can't run anything. Mark every untested claim as untested. You were wrong about the DB column, the buttons name clash and the family case. Read the code before patching.
  • Short answers, one step at a time. The owner tests on a real phone, and ?ui=touch forces the touch behaviour on desktop.

2. What is done and confirmed working

All of it is in app/src/bench.ts and was applied by the owner. "Works well and feels natural" was the verdict on picking.

  • bucket column. Added to parts in rebrickable.db, with six buckets: structural, functional, interaction, decorative, wheels, minifig. The mapping comes from the Rebrickable category name. Transportation is a structural placeholder. Gear Parts and Non-System Parts are unmapped (null) and don't appear in subjects 1-3.
  • Query and row. ROWS_SQL selects p.bucket, and Row.bucket exists.
  • In-scene filter block (filterBlock, a child of wallGroup):
    • 6 type buttons on top and 12 colour families below in two rows of 6. Families are Grey, Black, White, Yellow, Red, Blue, Green, Brown, Orange, Purple, Pink and Colorless (the owner likes the label "Colorless").
    • Buttons are rounded and wider than tall. Each shows a label and a count, drawn on a canvas texture. A thick border means active, with no tick. A zero count is dimmed, not hidden.
    • Tapping toggles the filter, and tapping again clears it. One type and one colour combine as AND (filt, match, countBy, toggleFilter). Labels go through L(key, fallback).
    • The wall is at least 6 columns wide. frameWall includes BLOCK_H. The old <select>s still work and stay in sync (the type select now lists buckets).
  • Behaviour flags: touchUi, behaviour.focusOnSelect and behaviour.autoSelect. On touch, tile selection doesn't fly the camera, doesn't auto-select, and doesn't scrollIntoView. focusPart is gated by focusOnSelect.
  • Raycast (pointerdown/up on the canvas, 8 px tap-vs-drag threshold). It tests [filterBlock, tiles, partsGroup, floor] and the nearest hit wins:
    • Filter buttons toggle a filter.
    • A tile tap selects the row. On touch it also runs pick() then place(), which is one-tap placement.
    • A placed part is selected via userData.partIndices[instanceId] or partIndex, mapped through st.order[index].
    • The floor or empty space clears selId. This is view state only, with no history entry.
  • Known limitation: every tap-placed part lands at x=0, z=0 and stacks until default placement exists.

3. Decisions made this session

  • Touch page first. It is the first bench variant, and the owner tests it on a phone.
  • Every control lives in the scene or a screen overlay. The wall carries the filters. The DOM palette, history list and selects stay on the key and button pages for accessibility. The touch page is flagged not accessible.
  • Free orbit, pinch zoom and tap-vs-drag are in scope for touch. Camera presets and camera history entries are deferred, and camera history is a bonus for instructions, not a blocker. A later "mark view" button could write one entry from the current pose.
  • Collision is advice and never blocks. A ghost or part shows clear, overlaps or not checked, with a non-colour cue. The collision pack is optional.
  • The wall has no wobble or precession. That allows render-on-demand (see 6).
  • Tapping a tile picks and places in one tap. Default placement rule (backlog, not built): the first free stud of the selected part, trying stud[0] then stud[1] and so on. If none is free, step back through history. The first part of a build goes at the origin for now.
  • Tapping a placed part selects it. It then gets the emissive glow, and the selected part is the attach target.
  • Gizmo around the selected part. It has 12 move handles and 3 curved rotation arrows (details in section 5).
  • Bottom button bar along the lower edge of the scene window. It holds a gizmo toggle, undo, redo, show-wall, show-baseplate, delete (kept apart from the others), and clear selection. Clear selection lives here with the rest, not top right. This replaces the earlier backlog position.
  • Rotation is screen-relative, consistent with the moves. Pitch turns about the screen-right axis and roll about the screen-forward axis, each snapped to the nearest world axis (the screenAxes approach). Please confirm this with the owner in one line, since I read "be consistent with moves?" as a yes.
  • Dropped from touch:
    • Place (a tile tap does it).
    • Collision mode (move to Settings).
    • The Check button (only relevant in manual mode, and the result could show as a badge on the part).

4. Next steps, in order

  1. Rotation op. Replace rot and rotV with one rot op carrying an axis (yaw, pitch or roll), screen-relative as above. This fixes the rotV bug (not counted in turns, not shown in history). It changes derive and the history text, and MPD export is unaffected because it reads the final matrix. Do the derive extraction with a few unit tests at the same time (place, move, rot, undo, put), using the existing npm test -w app setup.
  2. Bottom bar with the buttons in section 3, drawn in the scene or as a canvas-overlay DOM strip (decide; see ideas).
  3. Static gizmo handles: screen-relative placement, fixed on-screen size (scaled by camera distance), no depth test.
  4. Wire the handles into the raycast, with handles taking priority over parts and the floor, so a handle tap doesn't deselect.
  5. Default placement (the stud rule). It needs relate.ts (jointCandidates, Candidate), graph.ts (connectionsFor for taken studs) and attach-ui.ts. None of these have been read yet.
  6. Attach flow: ghost, free-connector markers, tap a marker, cycle variants, commit. This is the "crafting bench" idea, with the focus camera first and a separate scene only if it's too cluttered.

5. Gizmo spec

  • Lateral (forward, back, left, right): an inner handle moves half a stud (10 LDU) and an outer one moves a full stud (20 LDU).
  • Vertical: the inner handle moves one plate (8 LDU) and the outer one moves one brick (24 LDU).
  • Rotation: three curved arrows on the diagonals between the six axes. Yaw is in the horizontal plane, pitch in the vertical plane containing forward/back, and roll in the vertical plane containing left/right. One direction each is enough, because four taps make a full turn and undo covers mistakes.
  • Moves are free-form: half-stud moves leave the stud grid. That fits "collision is advice", but connectivity will later read the part as unattached.
  • Risk: on a 1x1 part, 12 finger-sized handles will overlap. Test on the phone, rely on pinch zoom, and consider the gizmo toggle.
  • The selection ring is related: it could be the gizmo's base.

6. Backlog (nothing here is for today)

From this session

  • Put the bucket script in the repo and run it in the DB copy/build step. Today the column is added by hand to the dist DB, and a rebuild silently drops it.
  • Default placement by the stud rule, with fallback back through history.
  • Refuse a placement with no valid mate (for example a pin needs a free hole). BrickAgent has no blocking rule, so this probably has to be designed.
  • ctx.roundRect fallback for older browsers (manual arc path).
  • Run the bench.bucket.* and bench.family.* keys through the hash/todo translation workflow.
  • Revisit the Transportation bucket when the owner writes the new rules (connector data may help in mixed categories: Transportation, Panels, Bricks Sloped, Bricks Special, Plates Special).
  • Maybe add a backing panel behind the filter block.
  • Fix the raw lowercase family names in the colour <select>.
  • Floating selection ring around the selected part, not covering it.
  • brickheart-mark.svg in the front-left corner of the canvas. This needs the file location, and the CSP allows data: but not blob:. A DOM overlay is simpler but won't appear in rendered thumbnails.
  • Gizmo toggle and clear-selection button (in the bottom bar).
  • Play button in the scene panel to replay the ops log, replacing the history list. The history list's cursor display and jump-to-step would need a step count or scrubber.
  • Counts on the wall: they are part-and-colour rows, not total pieces. Decide which to show.

From the master plan (still open)

  • Autosave and my-models (see idea 1), set image, OMR pack, settings page, snap and connectivity (connectionsFor, derive taken connectors from poses), instruction builder, monochrome patterns, i18n plurals, offline, data pipeline, shared head().
  • The known bench.ts problems in plan section 6 (dead exempt, y/z flip written four times, Ctrl+Z ignored, onSceneChange late-assigned, ROWS_SQL outside query.ts, duplicated t() and el()).
  • Unresolved questions in Addenda F and K.

7. Ideas the owner may not have considered

  1. Autosave earlier than planned. Reload loses the whole build today. Mobile browsers evict background tabs often, so on a phone this will bite before anything else. A minimal version could write the ops log to localStorage on every change. It could go before the gizmo.
  2. Part names on touch. The DOM palette labels are gone, so a user can't see what a tile is. Show a name and colour toast on tile tap, or a one-line caption in the scene.
  3. Render on demand. The animation loop never stops. With no wobble, render only on pick, orbit, zoom, filter change and camera easing. This should cut battery use and heat, and it's likely part of the "janky" feel.
  4. Multi-touch guard. A pinch can fire a stray pointerup that looks like a tap. Track active pointers, ignore taps when more than one is down, and reset on pointercancel.
  5. Bigger hit areas than visuals for the gizmo handles.
  6. Ghost preview of the one-tap placement. Show where the part will go before committing, with an undo toast afterwards.
  7. A "re-seat" action to snap a half-stud-moved part back to the grid or nearest joint.
  8. Surface the real error in the status line during development. The catch-all "build page could not be loaded" hid a missing DB column. A query guard for a missing bucket column would also help.
  9. Keep the patch helper in the repo (a small tools/patch.py with sub() and rsub()), so edits stay reproducible.
  10. Browser tests for touch. Playwright with touch emulation and ?ui=touch could check tap, drag and pinch. OMR models could serve as replay fixtures.
  11. Swatches vs monochrome. The colour buttons carry text labels, so they already work with the planned monochrome pattern mode. The patterns could be drawn into the swatch canvases.
  12. Haptics. navigator.vibrate on a tap, on Android only.
  13. Manual-mode collision as a badge. A ring or badge on the part replaces the Check button.

8. Unverified and untested

  • None of the patches were type-checked by me. The owner confirmed the behaviour in the browser, not a tsc run.
  • engineRotFromLdraw in parts.ts is marked "INFERRED" in its comment. The y/z flip is still written in four places in bench.ts.
  • I haven't read relate.ts, graph.ts, attach-ui.ts, geometry.ts or main.ts.
  • Rebuilding the DB will lose bucket until the script is in the repo (first backlog item).

Great progress today. Picking, filtering and the touch behaviour are all on a real device now.