Skip to content

Agents: units in author_scene and shared unit tools; opening frames follow the wall - #1186

Merged
wass08 merged 6 commits into
mainfrom
feat/agent-units
Oct 27, 2026
Merged

wass08 merged 6 commits into
mainfrom
feat/agent-units

Conversation

@wass08

@wass08 wass08 commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

Two things the hosted AI agents needed (owner, 2026-10-27):

Units for agents. A condo, apartment building or hotel asked of the agent came back as rooms only: no chat tool could create a unit and author_scene had no way to name one.

  • author_scene: a room takes unit: "Apartment 2B", the payload an optional units list (kind, colour). One UnitNode per name under the building, members across levels (a duplex), defect unit_split_room when one open-plan room names two units, warning unit_no_rooms, check rooms_in_units, report.units and report.ids['unit/<name>']. Units ride the building's own authorSceneWritten list so a revision removes one the payload drops (the per-level baseline of author_scene: keep its bookkeeping in pieces live collaboration accepts #1178 never saw them).
  • create_unit, set_unit_members, list_units become shared core contracts (agent-tools/units.ts) and operations (agent-operations/units.ts, 16-case table), registered on the MCP through shared-tools.ts; the MCP-only files are gone. get_zones answers each room's unit.
  • The public pascal-3d skill says what a unit is, top-down (unit in the payload) and bottom-up (create_unit after the rooms exist).

Opening frame depth follows the wall. frameDepth on doors and windows was a fixed 0.07 m default while walls are 0.1–0.35 m, so the wall's cut faces showed around every frame. frameDepth is now optional: left out, the frame is the host wall's thickness plus a 1 cm lip on each face (resolveOpeningFrameDepth, core lib/opening-frame-depth.ts); a stored number stays explicit (E-003, nothing migrates). Every reader (viewer door/window systems, move tools, plan offset, documentation, schedules) goes through the resolver; the manual tools and planWallOpening stop writing it; the panels show "Depth (auto)" with an Auto reset; MCP templates drop their hardcoded value. Catalog entries for the new panel copy are drafts awaiting review.

How to test

  1. bun run ci (run on this branch in a clean clone: check, i18n, skills, types, tests, build all pass).
  2. Editor: draw a 0.2 m wall, add a door and a window: the frames stand proud of both faces, no grey reveal. Select the door: Frame → "Depth (auto)" reads 0.22 m; drag it to 0.07 and the reveal appears; press Auto and it follows the wall again.
  3. MCP or chat: author_scene with two rooms naming unit: "Apartment A" / "Apartment B" → two units under the building, the report counts units: 2; list_units reads them; set_unit_members moves a room.

Screenshots / screen recording

Auto frames on a 0.2 m wall (door and window, no reveal):

auto frames on a 0.2 m wall

The same wall with the old explicit 0.07 m frame (the grey reveal around both):

explicit 0.07 m frames on a 0.2 m wall

(Branch evidence/agent-units, orphan, two PNGs.)

Checklist

  • I've tested this locally with bun dev
  • My code follows the existing code style (run bun check to verify)
  • I've updated relevant documentation (if applicable)
  • This PR targets the main branch

🤖 Generated with Claude Code


Note

Medium Risk
Changes core author_scene conversion and bookkeeping, global opening rendering/schedules, and agent tool contracts used by MCP and chat—broad surface area but mostly additive with parity tests.

Overview
Adds building units to the agent stack and makes door/window frame depth follow host wall thickness by default.

Units: author_scene accepts per-room unit names and an optional units list (kind, color), creates UnitNodes under the building (including multi-storey duplexes), and reports defects like unit_split_room plus a new rooms_in_units scene check. create_unit, set_unit_members, and list_units are implemented once in core (agent-operations/units.ts, agent-tools/units.ts) with a shared fixture table; MCP drops bespoke handlers and wires them through shared-tools.ts. get_zones now returns each room’s unitId / unit name.

Opening frames: frameDepth on doors and windows is optional; when omitted, depth resolves to wall thickness plus 1 cm per face via resolveHostedOpeningFrameDepth, with editor panels showing “Depth (auto)” and schedules/templates updated accordingly. Explicit stored depths are unchanged.

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

@Aymericr Aymericr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, this is a solid pair of changes. Moving the unit tools into shared core contracts and operations is a nice cleanup, and routing every frame-depth reader through resolveOpeningFrameDepth is the right shape. A few things before it can merge:

  1. Merge conflicts. GitHub reports the branch as conflicting with main, so it needs a rebase (no force-push needed from our side, just update the branch) and a green CI run after.
  2. Screenshots here, please. The before/after of auto frames on a 0.2 m wall vs the explicit 0.07 m frame lives in the private-editor PR, which outside contributors and reviewers of this repo can't see. Could you attach them (or a short recording of the Depth (auto) / Auto reset flow in the door and window panels) on this PR too?
  3. Wall thickness changes. Auto depth now depends on the host wall's thickness at render time. Please confirm that changing a wall's thickness after the openings exist marks its doors and windows dirty so their frames re-resolve, and ideally add a test for it. If the wall system already re-dirties child openings on any wall change, a pointer to that is enough.
  4. Small one, non-blocking. In authorSceneChecks, the COMMON_ROOM regex matches substrings, so a room named e.g. "Hall bedroom" or "Storage loft" inside an apartment would be treated as common area and slip past rooms_in_units. A word-boundary match, or only counting rooms with no unit on levels that are mostly units, would make the check a bit stricter. Fine to leave as a follow-up.

Nothing in here exposes the hosted architect harness, so no concerns there. Once it's rebased and green with the screenshots, I'm happy to approve and merge.

@Aymericr Aymericr added the enhancement New feature or request label Oct 27, 2026 — with Cursor

@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.

wass08 added a commit that referenced this pull request Oct 27, 2026
…one; common area is named by common-area words only

Review of #1186: unit_split_room was recorded on a room id, so the floors check counted it as a
failed floor cover (Bugbot). And the common-area test matched substrings, so "Hall bedroom" or
"Storage loft" inside an apartment slipped past rooms_in_units (Aymeric); a room is common area
when every word of its name is a common-area word or a qualifier (Entry hall, Stair landing 2).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@wass08

wass08 commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks for the review. Done on the branch (rebased on main, force-pushed):

  1. Rebased on 87ec430e; the only conflicts were the compiled catalogs, regenerated with i18n:extract.
  2. Screenshots are now in the PR body (orphan branch evidence/agent-units).
  3. Wall thickness changes. The wall system already marks every child dirty on a wall rebuild: packages/viewer/src/systems/wall/wall-system.tsx lines 834–835 (state.markDirty(wall.id) then for (const child of wall.children) state.markDirty(child)), and again at 1232 for the sweep. door-frame-depth.test.ts has "the same door on a thicker wall re-resolves" for the resolver side.
  4. Common-area names are now matched word by word: a room is common area when every word is a common-area word or a qualifier (Entry hall, Stair landing 2), so "Hall bedroom" and "Storage loft" are flagged. Test added.
  5. Bugbot's point: unit_split_room no longer counts as a failed floor; the floors check skips it and the units check reports it. Test added.

🤖 Generated with Claude Code

@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 2 potential issues.

Fix All in Cursor

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

Reviewed by Cursor Bugbot for commit 1726496. Configure here.

Comment thread packages/nodes/src/window/panel.tsx Resolved
wass08 added a commit that referenced this pull request Oct 27, 2026
…one; common area is named by common-area words only

Review of #1186: unit_split_room was recorded on a room id, so the floors check counted it as a
failed floor cover (Bugbot). And the common-area test matched substrings, so "Hall bedroom" or
"Storage loft" inside an apartment slipped past rooms_in_units (Aymeric); a room is common area
when every word of its name is a common-area word or a qualifier (Entry hall, Stair landing 2).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
wass08 and others added 6 commits October 27, 2026 15:12
…bers / list_units shared by both surfaces

A person asking for a condo, an apartment building or a hotel got rooms and no units: author_scene
had no unit field, and the unit tools lived on the MCP only, so the chat and Pro could not group
rooms into dwellings.

- author_scene: a room names its `unit`; the payload's `units` types or colours them. The operation
  makes one UnitNode per distinct name under the building, holding the zones of the rooms that name
  it (after open-plan joining; seeds of one enclosure naming different units are the defect
  `unit_split_room` and the room is in none), reports `units` and `ids['unit/<name>']`, and mints
  through the conversion's seed so a revision keeps an unchanged unit's id and drops one no longer
  named. `authorSceneChecks` gains `rooms_in_units`: where units are named, every room on a level
  with units is in one or is common area by name.
- create_unit, set_unit_members and list_units are shared contracts (`agent-tools/units.ts`) and
  pure operations (`agent-operations/units.ts`): buildingId optional (the viewed floor's building),
  refusals building_not_found / zone_not_found / zone_outside_building / unit_not_found /
  zone_in_other_unit (naming the unit; `move: true` moves the zone). Their edge cases are a case
  table (`__fixtures__/unit-cases.ts`) the core, MCP and chat runners read; the MCP registers them
  through SHARED_TOOLS with its previous output schemas and loses its one-off handlers and test.
- get_zones answers each zone's unitId and unit name (null: common area).
- The pascal-3d skill says what a unit is, top-down (author_scene) and bottom-up (the three tools).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A door's or window's `frameDepth` was a fixed 0.07 m schema default while
walls are 0.1 m by default and often thicker, so the wall's cut faces
showed around every frame the AI or the tools created. `frameDepth` is now
optional: left out, the frame is the host wall's thickness plus a 1 cm lip
on each face (`resolveOpeningFrameDepth` in core); a stored number stays
what it was, so old scenes render unchanged.

Every reader goes through the resolver with the host wall's thickness: the
door and window systems (hit box, frame, leaf offsets, sill, glass and
dividers), the move tools' ghosts and facing pose, the plan symbol's
offset plane, the schedules and the door documentation. The placement
tools stop writing `frameDepth`, so new openings are auto; the panels show
the resolved value as "Depth (auto)" and an Auto pill clears an explicit
one.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… schema page

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ion removes one the payload drops

Since #1178 the conversion's baseline is read from each level's authorSceneWritten; a unit is a
child of the building, so a renamed unit stayed behind on a revision. The building now lists what
it holds itself, and the baseline reads it back.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…one; common area is named by common-area words only

Review of #1186: unit_split_room was recorded on a room id, so the floors check counted it as a
failed floor cover (Bugbot). And the common-area test matched substrings, so "Hall bedroom" or
"Storage loft" inside an apartment slipped past rooms_in_units (Aymeric); a room is common area
when every word of its name is a common-area word or a qualifier (Entry hall, Stair landing 2).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@wass08
wass08 merged commit ac2ba6e into main Oct 27, 2026
5 checks passed
cursor Bot pushed a commit that referenced this pull request Oct 27, 2026
#1186 landed after the previous merge. The compiled en and en-XA catalogs are
regenerated again with i18n:extract and i18n:compile.
@Aymericr
Aymericr deleted the feat/agent-units branch November 5, 2026 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants