Polygon creation workflow is unfinished and relies on global state #2

Closed
opened 2026-08-02 14:42:33 +00:00 by Mark · 1 comment
Owner

Problem: The polygon tool in src/components/editor/FloorplanCanvas.tsx stores clicked points in polygonPoints, but finalizing the polygon uses a window.__pendingPoly global hack and does not correctly update the newly created room shape. The parent App.tsx passes an onAddRoom callback that returns a room ID but then tries to set polygon shape via setTimeout and updateShape, which is fragile and may race.

Files to modify:

  • src/components/editor/FloorplanCanvas.tsx
  • src/hooks/useFloorplan.ts (optional: add an addPolygonRoom helper)

Acceptance criteria:

  • Remove window.__pendingPoly usage entirely.
  • Add a clean API to create a polygon room from a list of points.
  • Ensure double-click (or explicit finish action) converts polygonPoints into a room with type: polygon.
  • Reset polygonPoints after creating the room.
  • Prevent creating polygons with fewer than 3 points.
**Problem:** The polygon tool in `src/components/editor/FloorplanCanvas.tsx` stores clicked points in `polygonPoints`, but finalizing the polygon uses a `window.__pendingPoly` global hack and does not correctly update the newly created room shape. The parent `App.tsx` passes an `onAddRoom` callback that returns a room ID but then tries to set polygon shape via `setTimeout` and `updateShape`, which is fragile and may race. **Files to modify:** - `src/components/editor/FloorplanCanvas.tsx` - `src/hooks/useFloorplan.ts` (optional: add an `addPolygonRoom` helper) **Acceptance criteria:** - Remove `window.__pendingPoly` usage entirely. - Add a clean API to create a polygon room from a list of points. - Ensure double-click (or explicit finish action) converts `polygonPoints` into a room with `type: polygon`. - Reset `polygonPoints` after creating the room. - Prevent creating polygons with fewer than 3 points.
Mark closed this issue 2026-08-11 12:07:06 +00:00
Author
Owner

Fixed in 1c0a244. The polygon double-click handler now passes the finished polygon shape directly to onAddRoom. Removed the dummy zero-size rect, the window.__pendingPoly global, and the App-side setTimeout shape-swap; double-click includes the final vertex. Verified in the browser: 4 clicks create a polygon room with the correct points, the tool auto-returns to Select, and __pendingPoly is never set.

Fixed in 1c0a244. The polygon double-click handler now passes the finished polygon shape directly to onAddRoom. Removed the dummy zero-size rect, the window.__pendingPoly global, and the App-side setTimeout shape-swap; double-click includes the final vertex. Verified in the browser: 4 clicks create a polygon room with the correct points, the tool auto-returns to Select, and __pendingPoly is never set.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Mark/kimi_agent_home_assistant#2
No description provided.