Skip to content

feat(wall): typed exact length during two-click wall drafting - #883

Closed
dkbbdev wants to merge 8 commits into
pascalorg:mainfrom
dkbbdev:feat/wall-typed-length
Closed

dkbbdev wants to merge 8 commits into
pascalorg:mainfrom
dkbbdev:feat/wall-typed-length

Conversation

@dkbbdev

@dkbbdev dkbbdev commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Closes #308.

What

While drafting a wall in the two-click flow, typing an exact length (e.g. 3m, 180cm, 2500 in mm notation, 10'6") now locks the draft to that length along the current draft direction — the pointer keeps steering the direction only.

  • Enter commits the wall at the typed length.
  • Escape is two-stage: first press clears the typing buffer, second press cancels the draft (per the triage note on unit toggle only affects the display of dimensions, not the input #308).
  • Backspace/Delete edit the buffer.
  • The HUD label shows the buffer while typing and falls back to the normal drafting label when empty.

How

  • New shared store useWallDraftTyping (packages/editor/src/store/use-wall-draft-typing.ts) holds the buffer so the 2D floor-plan draft and the 3D wall tool stay in lockstep per the 2D ↔ 3D parity rule in wiki/architecture/tools.md.
  • 3D (packages/nodes/src/wall/tool.tsx): a window keydown listener mirrors the cabinet tool's applyTypedDimension pattern — parseMeasurement resolves the buffer with the same bare-unit defaults; grid:move projects the draft end onto the typed length; Enter synthesizes a grid:click at the projected endpoint so the normal commit pipeline (chain continuation, auto-close, support-slab election) runs unchanged.
  • 2D (floorplan-panel.tsx): the same projection in the wall-draft pointer move, the same key handling in the window keydown effect, and the HUD label override.
  • Angle snap / junction snap / magnetic alignment continue to work on untyped drafts; the typed commit intentionally bypasses endpoint snap so the typed length survives exactly (drafting direction is taken from the current snapped pointer, so snapped angles still steer it).

Testing

  • packages/editor/src/store/use-wall-draft-typing.test.ts — buffer lifecycle + accepted keys.
  • packages/nodes/src/wall/typed-length.test.ts — the projection math shared by both views.
  • Full @pascal-app/editor + @pascal-app/nodes suites pass (turbo run test: 3119 tests across 268 files, plus the editor suite).
  • tsgo --noEmit clean for both packages; biome check clean on touched files.

Verified end-to-end on a self-hosted deployment (design.dekorproduct.com) in both the 2D plan and 3D views with metric-m and mm notations.

Thanks for the detailed triage spec on #308 — the interaction follows it point by point.


Note

Medium Risk
Touches core wall drafting, keyboard routing, and 2D/3D split-view chain sync; incorrect commit or cancel handling could mis-place walls or exit tools unexpectedly.

Overview
Adds typed exact-length wall drafting (#308) shared between the 3D wall tool and the 2D floor plan via a new useWallDraftTyping store (buffer, projected end, resolveTypedCommitEnd, start-key gating so letter shortcuts still work).

While a buffer is active, pointer move projects the draft end onto the typed length (direction from the cursor); the HUD shows the buffer instead of live length. Enter commits at that length; Escape first clears the buffer then cancels the draft; typed commits bypass endpoint snap so the entered length is preserved.

2D floorplan-panel: window keydown handling, sync of projectedEnd with draft preview, Enter via wallPlacementPointRef, and split-view hooks that re-base draftStart from useSegmentDraftChain and tear down the draft when the 3D chain clears—plus stage-1 Escape consumption via markToolCancelConsumed.

3D tool.tsx: capture-phase keydown (skipped in pure 2D view), matching projection/commit logic, trusts floorplan grid:move when typing to avoid double-snap, and clears the buffer per segment.

Exports the typing helpers from @pascal-app/editor; adds unit tests for the store, commit math, and projection.

Reviewed by Cursor Bugbot for commit 69100e1. Bugbot is set up for automated code reviews on this repo. Configure here.

…org#308)

While drafting a wall, printable keys open a typing buffer; the draft
endpoint is projected onto the typed length along the current draft
direction, so the pointer keeps steering direction only. Enter commits
at the typed length, two-stage Escape clears the buffer first and then
cancels the draft, Backspace/Delete edit the buffer. Shared zustand
store keeps the 2D floor plan and the 3D view in lockstep (parity rule
in wiki/architecture/tools.md); angle/junction snapping is preserved on
untyped drafts and bypassed only for the typed commit.
@pascal

pascal Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

I hit an error while handling your request (Model unavailable on AI Gateway free tier: Free tier users do not have access to this model. Upgrade to paid credits at https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%3Fmodal%3Dtop-up for unrestricted…).

Please try again, rephrase, or reach out if it keeps failing.

Error id: 91943371-ceba-4f22-9d28-001dcd5623f3

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/nodes/src/wall/tool.tsx Resolved
- click/Enter commit reuses the projected endpoint the previews show
  instead of re-snapping the raw pointer (2D + 3D parity)
- HUD subscribes to the typing store so the label tracks keystrokes
- typing buffer cleared on every commit/cancel path; never carries
  into the next chain segment
- 2D typing keys stopPropagation so tool shortcuts don't fire mid-type
- drop unused begin() action
@dkbbdev

dkbbdev commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Addressed all 5 Bugbot findings in 11e8fa5:

  • Click commit ignores typed length / Enter re-snaps typed endpoint — the typing store now carries the projected endpoint (projectedEnd); click and Enter commits reuse it verbatim in both 2D and 3D, bypassing magnetic/angle/grid snap so the committed wall is exactly the previewed length.
  • HUD ignores typing store updates — the 2D layer subscribes to the store (useWallDraftTyping((s) => s.input)) instead of reading getState() inside useMemo.
  • Typing buffer persists after commit — clearInput() now fires on every exit path: 3D commit, 2D commit + chain continuation, clearWallPlacementDraft, cancel; removed the unused begin().
  • 2D typing keys leak to shortcuts — typing/Enter/Escape handlers now stopPropagation() as well as preventDefault().

Full check-types + test suites pass (3,125 tests).

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/nodes/src/wall/tool.tsx Resolved
Comment thread packages/nodes/src/wall/tool.tsx Resolved
… Enter commit

- 3D Enter keeps the buffer across the synthetic grid:click so the
  commit is recognized as typed (no re-snap), clears defensively after
- stopDrafting clears the typing store: double-click finish and chain
  auto-close no longer leak the old length into the next draft
- 2D Enter commits through a latest-ref instead of the first-render
  closure, which used to restart the draft at the typed point
- 2D move preview publishes projectedEnd so a click mid-type commits
  the projected endpoint, matching the 3D tool
@dkbbdev

dkbbdev commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Round 2 findings fixed in 596c7e7:

  • 3D Enter re-snaps the typed endpoint — the buffer now survives the synthetic grid:click (commit recognized as typed, snap bypassed), with a defensive clear after in case the commit path bails early.
  • Stopped draft keeps typed buffer — stopDrafting clears the typing store, so double-click finish and chain auto-close no longer leak the old length into the next draft.
  • 2D Enter uses a stale callback — the placement callback is now kept current via a useEffect latest-ref instead of self-assigning on first call; typed Enter commits the wall instead of restarting the draft. The 2D move preview also publishes projectedEnd so a click mid-type commits the projected endpoint, matching 3D.

check-types + biome + full test suite pass.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@dkbbdev

dkbbdev commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

(merged upstream/main @ 5ce7211 — hosting/duplicate fixes in; no conflicts; CI green pre-merge)

@dkbbdev

dkbbdev commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

@Aymericr gentle ping for review priority when you have a moment 🙂 This addresses #308 (the unit toggle currently affecting display only, not input) — typed exact length during two-click wall drafting. The branch is up to date with main as of today (merged cleanly, no conflicts, Cursor Bugbot neutral). We're planning to build further exact-input features on this base, so an early review would help us stay aligned with the direction you'd prefer. Happy to split it into smaller pieces if that eases review.

Bugbot 8497d792 (round 3, high): append/backspace only change the
buffer, while projectedEnd is published by pointer move — so digits
typed after the last move left the click commit using a stale
endpoint (typed "1" then "2" without moving committed 1, not 12).
Enter already re-parsed and re-projected; click now does too, via a
shared resolveTypedCommitEnd(start, currentEnd, input, parseOpts)
helper used by both the 3D grid-click path and the 2D floor-plan
placement callback, falling back to the last projected end only when
there is no usable direction. The 2D move preview also re-binds on
unit/metricNotation changes so the parse options stay in sync.

check-types + biome + editor (1072) + nodes (3392) suites pass.
@dkbbdev

dkbbdev commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

Round 3 finding (Bugbot 8497d792, high: "click commits stale typed length") fixed in afe71e4:

  • append/backspace only change the buffer while projectedEnd was published by the last pointer move — digits typed after that move left the click commit using a stale endpoint (type 1 then 2 without moving → committed 1 m, not 12 m). Enter already re-parsed and re-projected.
  • New shared resolveTypedCommitEnd(start, currentEnd, input, parseOpts) re-derives the endpoint from the live draft direction at commit time; both the 3D grid-click path and the 2D floor-plan placement callback now use it, falling back to the last projected end only when there is no usable direction.
  • The 2D move preview dependency array now lists unit/metricNotation so the parse options stay in sync across unit changes.
  • Unit tests cover stale-buffer re-derivation, direction normalization, unit suffixes, and null fallbacks. check-types + biome + editor (1072) + nodes (3392) suites pass.

Also includes the upstream/main merge (hosting fixes #894–#896, settings dialog #904, cli #893) noted earlier — no conflicts.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/nodes/src/wall/tool.tsx Resolved
Bugbot cb434c3d (round 4, high): the 3D tool's capture-phase Enter
handler synthesized grid:click and stopped the event, so the 2D Enter
path never ran handleWallPlacementPoint. In 2D-only that click pipeline
commits nothing (the canvas is display:none), so a typed Enter silently
did nothing; in split view the 3D commit left the panel's draftStart on
the previous segment, so the next 2D preview and typed commit projected
from a stale origin.

The tool's key handler now yields in 2D-only view — the floor-plan
panel is the committer there (view-gated createWallOnCurrentLevel
already exists). For split view, the panel subscribes to the chain
start the 3D tool publishes on useSegmentDraftChain and re-bases its
draft onto it, so both views keep drafting from the same point with a
single commit owner. The subscription re-arms reactively on
mode/tool instead of reading the store once at mount.

check-types + biome + editor (1072) + nodes (3393) suites pass.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

- Escape during a typed 2D draft now only clears the buffer: the panel's
  cancel handler recognizes the stage-1 tool:cancel via
  wallTypingEscapeClearedRef and consumes it, so the draft and the tool
  survive (Bugbot e9c12894).
- A null publish from the 3D chain store (auto-close, T-junction,
  single-segment finish, cancel) now tears the 2D draft down too —
  clearWallPlacementDraft resets draftStart and wallChainFirstVertex
  (Bugbot a172c934).
- 2D Enter guards before clearing: a valid buffer with a degenerate
  preview no longer wipes the input without committing; clearInput moves
  after the guards and after setDraftEnd, matching the 3D path (Bugbot
  622bea04).
- Split view: a grid:move emitted by the floor-plan panel carries a
  screenProjection; while a typing buffer is active the 3D move path now
  trusts that point verbatim instead of re-running magnetic/grid snap,
  which could rotate the draft ray away from the 2D preview (Bugbot
  3cd53dd1).
- acceptsWallTypingKey gates buffer START on a digit or leading dot;
  letters only continue an active buffer, so c/m/t/f drafting shortcuts
  stay live before typing begins (Bugbot 7dcff331).
@dkbbdev

dkbbdev commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Round 4 findings fixed in 7e114a8:

  • Escape cancels typed 2D draft (high) — the panel's cancel handler now recognizes the stage-1 tool:cancel that follows a buffer-clearing Escape (wallTypingEscapeClearedRef) and consumes it via markToolCancelConsumed, so the first Escape clears only the typed buffer; draft and tool stay alive (mirrors the 3D stage check).
  • Stale 2D draft after 3D stop (high) — the useSegmentDraftChain teardown now also fires on a null clear: clearWallPlacementDraft resets draftStart and wallChainFirstVertex, so auto-close / T-junction / single-segment finishes end the 2D draft and stop it consuming typing keys.
  • Enter drops typed length early (medium) — guards before clearing: 2D Enter validates direction + length + draftStart before touching the buffer, and clearInput now runs only after setDraftEnd — a valid value on a degenerate preview keeps its buffer and commits once the pointer resolves a direction, matching the 3D path.
  • Split view re-snaps typed endpoint (medium) — a grid:move from the floor-plan panel carries screenProjection (native 3D raycasts never set it); while a typing buffer is active the 3D move path trusts that already-projected point verbatim and skips magnetic/grid snap, so the committed wall matches the 2D preview.
  • Typing keys steal drafting shortcuts (medium) — new acceptsWallTypingKey(key, buffer): a buffer starts only on a digit or leading .; letters (c/m/t/f…) continue an active buffer only, so single-letter drafting shortcuts stay live pre-buffer. Covered by new unit tests.

Tests 14/14, typecheck + biome clean.

…penings)

# Conflicts:
#	packages/editor/src/components/editor/floorplan-panel.tsx
#	packages/nodes/src/wall/tool.tsx
@dkbbdev

dkbbdev commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged upstream/main (@ 67f8041, freeform elements + scripted openings) into this branch to clear the merge conflicts in floorplan-panel.tsx / wall/tool.tsx — the round-4 typed-length logic is preserved and both sides' changes kept.

Verified on the merge result: check-types 13/13 packages green, wall-typing unit tests 18/18 green. (One pre-existing failure in packages/mcp safe-fetch.test.ts — IPv4-mapped-IPv6 loopback — is byte-identical to upstream/main and untouched by this PR.)

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 69100e1. Configure here.

magnetic: isMagneticSnapActive(),
}).point,
{ applySnap: !angleLocked },
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Polygon keeps typed length next side

Medium Severity

A typed click that adds an open polygon corner never calls clearInput. Linear commits clear the buffer so the next segment is not locked, but the next polygon side stays projected to the same length until the user edits or cancels the buffer.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 69100e1. Configure here.

Copy link
Copy Markdown
Member

Thanks @dkbbdev! Typed wall lengths have been a long-standing ask. Since this changes drafting behavior, could you add a short screen recording of typing a length, using Enter and the two-stage Escape, and the HUD label? Please also rebase onto current main if it no longer merges cleanly. Once it's rebased we'll do a hands-on review.

Aymericr added a commit that referenced this pull request Nov 9, 2026
…es (#1249)

* feat(wall): typed exact length during two-click wall drafting (#308)

While drafting a wall, printable keys open a typing buffer; the draft
endpoint is projected onto the typed length along the current draft
direction, so the pointer keeps steering direction only. Enter commits
at the typed length, two-stage Escape clears the buffer first and then
cancels the draft, Backspace/Delete edit the buffer. Shared zustand
store keeps the 2D floor plan and the 3D view in lockstep (parity rule
in wiki/architecture/tools.md); angle/junction snapping is preserved on
untyped drafts and bypassed only for the typed commit.

* fix(wall): address review — commit typed length exactly, no buffer leaks

- click/Enter commit reuses the projected endpoint the previews show
  instead of re-snapping the raw pointer (2D + 3D parity)
- HUD subscribes to the typing store so the label tracks keystrokes
- typing buffer cleared on every commit/cancel path; never carries
  into the next chain segment
- 2D typing keys stopPropagation so tool shortcuts don't fire mid-type
- drop unused begin() action

* fix(wall): honor typed length on Enter/click exits, latest-ref for 2D Enter commit

- 3D Enter keeps the buffer across the synthetic grid:click so the
  commit is recognized as typed (no re-snap), clears defensively after
- stopDrafting clears the typing store: double-click finish and chain
  auto-close no longer leak the old length into the next draft
- 2D Enter commits through a latest-ref instead of the first-render
  closure, which used to restart the draft at the typed point
- 2D move preview publishes projectedEnd so a click mid-type commits
  the projected endpoint, matching the 3D tool

* feat(cabinet): add typed coordinate placement

* fix(cabinet): address typed-placement review findings

- Strip insertionPreview/insertionFailure in applyTypedPlacement so Enter
  commits the typed wall position instead of re-entering the pointer
  path's run-insertion branch (Bugbot: stale insertion, high).
- Drop the trailing setProjectedPosition(snap) in beginTypedPlacement that
  pinned the HUD to the pre-typing snap instead of the first digit's
  projection.
- Clear typedWallHitRef/typedCoordinateDefaultsRef on every typing exit
  (becameInactive), covering Escape typed inside the HUD input whose
  window handler skips INPUT targets.
- Render the coordinate HUD from exactly one surface: 2D pane in 2d/split,
  3D Html in 3d-only — split view mounts both panes, so both instances
  fought over caret/focus.

* fix(cabinet): typed-commit hardening + screen-space 2D HUD

- Neutralize altKey on the reused pointer event for typed commits so a
  stale force-place modifier cannot override the typed pose (Bugbot:
  stale Alt click).
- onClick now reports whether a cabinet was committed; a rejected typed
  commit (e.g. collision) keeps the typing session so values survive and
  can be adjusted instead of being silently wiped.
- 2D typed-entry HUD sizes its foreignObject from CSS px × unitsPerPixel
  and counter-rotates by -sceneRotationDeg (mirrors the measurement
  extrusion control), so inputs render screen-upright at a usable size
  at any zoom/rotation.

* fix(cabinet): typed-commit stretch seeding + click ends typing session

- Continuous-mode typed Enter now seeds the stretch preview at the typed
  position (zero-length span) via a rawOverride on
  resolveStretchedPlacement, instead of growing toward the stale cursor
  position carried by the reused pointer event (Bugbot: high).
- A canvas click while typed entry is active ends the typing session
  before committing, so a newly started stretch can follow the pointer
  instead of being frozen until Escape (Bugbot: medium).

* fix(cabinet): keep typed entry reachable after large offsets

findClosestCabinetWallInPlan now accepts maxDistance; beginTypedPlacement
passes Infinity since the placement already knows its wallId and only
needs the projection onto it. A typed perpendicular offset (or deep
cabinet) can push the center beyond WALL_SNAP_DISTANCE_M, which made the
next session fail to start and let digits fall through to global phase
shortcuts.

* fix(cabinet): typed-entry cancel/island/short-wall hardening

- Restore the pre-typing pose when a typing session ends uncommitted
  (Escape/tool cancel): placementRef kept the typed pose, so a click right
  after Escape committed the cancelled coordinates (Bugbot: high).
- Ending the session on island toggle: island has no wall snapping, so the
  session would be orphaned (frozen pointer, vanished HUD) until Escape.
- resolveCabinetTypedPlacementPosition clamps distance instead of
  rejecting when the cabinet is wider than the wall, matching the
  coordinate getter's clamp so the pose stays committable (Bugbot: medium).

* fix(cabinet): typed-entry WYSIWYG click, click-swallow, miter station

- A canvas click during typed entry now commits the typed preview pose
  (suppress the pre-typing restore; keep placementRef) instead of the
  restored original snap (Bugbot: high).
- Strip 'node' from the synthetic typed-commit event so
  stopPlacementCommitPropagation does not install its 300ms window click
  swallow, which could eat the user's next real click (Bugbot: medium).
- resolveCabinetTypedPlacementPosition samples the mitered face offset at
  the destination station (hit.localX = typed distance + width/2) instead
  of the frozen pre-typing snap (Bugbot: medium).

* fix(review): HIGH-2, HIGH-3, QUICKWIN-2

- HIGH-2: recompute wallSurfaceNormal from updated resolved.yaw in applyTypedPlacement

- HIGH-3: re-resolve and publish placement from lastPlacementEventRef when typing ends without commit

- QUICKWIN-2: allow '/' and ',' in isPlacementTypingKey and advance field on comma in PlacementCoordinateInput

Note: HIGH-1 and QUICKWIN-1 were already addressed in commit 7c7851a.

* fix(cabinet): keep typing session on invalid click commit; comma toggles field

- A canvas click during typed entry now ends the session only when the
  commit succeeds (onClick wrapper defers clear() past onClickInner). An
  invalid typed pose keeps the session alive so values stay editable
  (Bugbot: invalid click ends typed entry, high).
- The capture-phase window keydown handler now treats ',' as a field
  toggle like the focused HUD input does, so comma advances to the
  offset field even when the HUD is unfocused (Bugbot: medium).

* fix(cabinet): center a cabinet wider than its wall on typed entry

Wall snap centers an oversized cabinet on the wall (empty span →
midpoint), but typed entry mapped default distance 0 to
localX = width / 2, sliding the cabinet off the wall center — possibly
past the wall end — the moment coordinate entry started or the default
was committed. resolveCabinetTypedPlacementPosition now resolves the
centered pose (wallLength / 2) when the cabinet is wider than the wall,
matching getCabinetPlacementCoordinates and resolveCabinetWallSnapPlacement.

Adds a regression test: wall 4m, cabinet 5m wide → distance 0 resolves
to wallLocalX 2 (wall center), not 2.5.

* fix(wall): re-derive typed endpoint at click commit time

Bugbot 8497d792 (round 3, high): append/backspace only change the
buffer, while projectedEnd is published by pointer move — so digits
typed after the last move left the click commit using a stale
endpoint (typed "1" then "2" without moving committed 1, not 12).
Enter already re-parsed and re-projected; click now does too, via a
shared resolveTypedCommitEnd(start, currentEnd, input, parseOpts)
helper used by both the 3D grid-click path and the 2D floor-plan
placement callback, falling back to the last projected end only when
there is no usable direction. The 2D move preview also re-binds on
unit/metricNotation changes so the parse options stay in sync.

check-types + biome + editor (1072) + nodes (3392) suites pass.

* fix(wall): let the 2D-only view own the typed Enter commit

Bugbot cb434c3d (round 4, high): the 3D tool's capture-phase Enter
handler synthesized grid:click and stopped the event, so the 2D Enter
path never ran handleWallPlacementPoint. In 2D-only that click pipeline
commits nothing (the canvas is display:none), so a typed Enter silently
did nothing; in split view the 3D commit left the panel's draftStart on
the previous segment, so the next 2D preview and typed commit projected
from a stale origin.

The tool's key handler now yields in 2D-only view — the floor-plan
panel is the committer there (view-gated createWallOnCurrentLevel
already exists). For split view, the panel subscribes to the chain
start the 3D tool publishes on useSegmentDraftChain and re-bases its
draft onto it, so both views keep drafting from the same point with a
single commit owner. The subscription re-arms reactively on
mode/tool instead of reading the store once at mount.

check-types + biome + editor (1072) + nodes (3393) suites pass.

* fix(wall): round-4 bugbot fixes for the typed 2D draft

- Escape during a typed 2D draft now only clears the buffer: the panel's
  cancel handler recognizes the stage-1 tool:cancel via
  wallTypingEscapeClearedRef and consumes it, so the draft and the tool
  survive (Bugbot e9c12894).
- A null publish from the 3D chain store (auto-close, T-junction,
  single-segment finish, cancel) now tears the 2D draft down too —
  clearWallPlacementDraft resets draftStart and wallChainFirstVertex
  (Bugbot a172c934).
- 2D Enter guards before clearing: a valid buffer with a degenerate
  preview no longer wipes the input without committing; clearInput moves
  after the guards and after setDraftEnd, matching the 3D path (Bugbot
  622bea04).
- Split view: a grid:move emitted by the floor-plan panel carries a
  screenProjection; while a typing buffer is active the 3D move path now
  trusts that point verbatim instead of re-running magnetic/grid snap,
  which could rotate the draft ray away from the 2D preview (Bugbot
  3cd53dd1).
- acceptsWallTypingKey gates buffer START on a digit or leading dot;
  letters only continue an active buffer, so c/m/t/f drafting shortcuts
  stay live before typing begins (Bugbot 7dcff331).

* refactor(typed-entry): share one store, key convention and HUD between walls and cabinets

#883 (typed wall length) and #887 (typed cabinet distance/offset) each
brought their own typed-entry store, key handling and HUD. Replace
`useWallDraftTyping` with the cabinet's `usePlacementTyping`, now carrying
its session's field labels, so both tools share:

- `routePlacementTypingKey`: a digit or `.` opens a session, Tab or comma
  switches field, Enter commits, Escape clears the session (the next Escape
  cancels the draft), Backspace edits, Delete empties the field; Cmd/Ctrl/Alt
  chords are never consumed.
- A display-only `PlacementCoordinateInput` (no focused inputs), rendered in
  3D through `LocalizedHtml` and in the plan through
  `FloorplanPlacementTypingHud`, so split view shows it in both panes.
- `resolveTypedWallEnd` for the wall projection, used by the 3D tool and
  the plan alike. The plan forwards the pointer itself on `grid:move` and
  each side re-projects it, and a typed Enter that resolves to nothing
  keeps the session instead of dropping it.

Also drops the floorplan preview layer's cabinet kind check (E-002), clears
the session after each Polygon corner, and removes the frozen-copy
typed-length test in favour of tests through the exported resolver.

* feat(wall): type the drafted wall's angle as well as its length

Adapted from the typed-angle idea in #1207: the wall draft's typed entry
gets a second field, the heading. Tab (or comma) switches between length
and angle, and Tab with no session open starts on the angle.

- Length only: the pointer steers the direction, the length is exact.
- Angle only: the direction is locked and the pointer's projection onto it
  sets the length, on the grid step when grid snapping is on.
- Both: the endpoint is fully determined.

Degrees are measured the way the 15° angle snap builds its rays,
`atan2(dz, dx)` from the building's +X axis towards +Z; the field's
placeholder shows the live heading in that convention. The same resolver
drives the 3D tool and the plan, so 2D, 3D and split view agree. Only the
angle field is taken from #1207; its chain, guide and parser changes are
not.

Co-authored-by: saadmooh <[email protected]>

* docs(tools): describe the shared typed-entry convention

Co-authored-by: dkbbdev <[email protected]>
Co-authored-by: saadmooh <[email protected]>

* fix(floorplan): take 2D-only typed wall keys ahead of the global shortcuts

The plan's typed entry sat in its bubble-phase keydown listener, which is
re-registered (after the global `useKeyboard` one) on every draft's first
click. In 2D-only view a typed `1`/`2` switched phase, `m` armed Measure and
the first Escape cancelled the tool instead of clearing what was typed.

Move it into `installFloorplanWallTypingKeys`, a window capture listener
registered once that reads the draft through refs, consumes its keys before
any shortcut sees them, and stands down outside 2D-only view, where the 3D
wall tool's capture listener owns them. The stage-1 Escape marker and its
`tool:cancel` workaround are gone: that Escape no longer reaches the global
handler. Also tidies two comments left half-edited.

* fix(wall): let a 3D typed Enter commit before the pointer moves

Right after the start click the tool has no pointer yet, so Enter with both
length and angle typed did nothing and typing showed no preview. Fall back
to the start point, as the plan does.

* fix(floorplan): keep the typed-entry HUD off the ghost it labels

The plan's HUD was centred on the cabinet with a pointer-active box around
it, so clicks on the ghost hit the HUD. Lift it just above its anchor and
let only the HUD panel take the pointer.

* fix(wall): wrap the angle placeholder's rounded heading to 0°

A heading just under 360° rounded to a 360° placeholder; show 0° as the
typed-angle convention reads it.

* docs(tools): spell out the typed wall angle convention and pointer forwarding

The typed angle is an absolute heading in the plan frame, as the angle snap
measures it, and its placeholder shows the live heading the same way, while
the draft's angle labels stay relative. The plan forwards its snapped
pointer, never the typed end, and takes 2D-only keys in a capture listener.

* test(floorplan): start the typed wall key test from an empty session

The typing store is shared across test files, so a session another file
left open turned the typed `1m` into `51m` in the full suite.

* fix(floorplan): size the 2D wall typing HUD from the plan's own scale

The wall draft renders outside FloorplanRenderProvider, so the shared HUD
read the context defaults (unitsPerPixel 1, rotation 0) and drew a
plan-metre-sized box far off screen in the 2D-only view. The HUD now takes
unitsPerPixel and sceneRotationDeg from its caller.

Co-authored-by: dkbbdev <[email protected]>

* docs(floorplan): reflow the typing HUD comment

---------

Co-authored-by: dkbbdev <[email protected]>
Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: saadmooh <[email protected]>

Copy link
Copy Markdown
Member

Thanks @dkbbdev, typed wall lengths are on main now. #1249 combined this PR with #887 (and the angle field from #1207) into a single typed-entry feature on current main. Your commits, including every Bugbot round, kept their authorship. Since this branch is fully covered by #1249 and now conflicts with main, I'm closing it. Thanks for the careful iteration here. If you notice anything in the shipped behaviour that differs from what you intended, please open an issue and tag me.

@Aymericr Aymericr closed this Nov 22, 2026
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.

unit toggle only affects the display of dimensions, not the input

2 participants