YAML export wiring + CORS / proxy notes for HA integration (slice of #5) #10

Closed
opened 2026-09-18 16:24:11 +00:00 by Mark · 1 comment
Owner

Parent-Issue: #5

Slice 6 of issue #5 decomposition (plus acceptance-criteria items related to deployment concerns). Once the user has picked which entities belong to which room, the editor must round-trip them through static YAML export, and the deployment story must address HA's CORS posture.

Scope (one PR):

  • Update the existing YAML exporter (wherever it lives in the editor; figure out from current code) to emit the per-room haEntities list alongside the existing static entity IDs.
  • Add a small test (or a documented fixture) showing: two rooms with associated HA entities → YAML output contains both rooms' entities under a stable key.
  • Document the CORS / proxy path for local development in the README or a new docs/home-assistant.md:
    • HA server http:/https: is the canonical entry; users will hit CORS when the editor is served from a different origin.
    • Recommend using a small Vite dev-server proxy (vite.config.ts server.proxy['/ha']) that forwards /ha/* to the HA URL with the user's token injected from localStorage. Same proxy pattern can be reused for production via nginx (see issue #6's nginx config).
  • Surface connection errors in the existing UI: at minimum, error toasts / inline banners for fetch failures during YAML export and entity browsing.

Acceptance criteria:

  • A saved editor state with HA entity selections exports to YAML that round-trips through loadFromYaml (or equivalent importer) without losing selections.
  • YAML output key for selected entities is documented (e.g. ha_entities: with a stable schema).
  • CORS / proxy doc clearly explains the Vite dev-server proxy and references #6's nginx config for production.
  • npm run build, npm run lint, npm run typecheck (tsc -b) all pass. Add a unit test or fixture for the YAML round-trip.

Out of scope:

  • Building the picker UI itself (covered by the sibling child issue).
  • Editing src/lib/ha-api.ts (kept as-is from #5 Slice 1).
**Parent-Issue:** #5 Slice 6 of issue #5 decomposition (plus acceptance-criteria items related to deployment concerns). Once the user has picked which entities belong to which room, the editor must round-trip them through static YAML export, and the deployment story must address HA's CORS posture. **Scope (one PR):** - Update the existing YAML exporter (wherever it lives in the editor; figure out from current code) to emit the per-room `haEntities` list alongside the existing static entity IDs. - Add a small test (or a documented fixture) showing: two rooms with associated HA entities → YAML output contains both rooms' entities under a stable key. - Document the CORS / proxy path for local development in the README or a new `docs/home-assistant.md`: - HA server `http:`/`https:` is the canonical entry; users will hit CORS when the editor is served from a different origin. - Recommend using a small Vite dev-server proxy (`vite.config.ts` `server.proxy['/ha']`) that forwards `/ha/*` to the HA URL with the user's token injected from localStorage. Same proxy pattern can be reused for production via nginx (see issue #6's nginx config). - Surface connection errors in the existing UI: at minimum, error toasts / inline banners for fetch failures during YAML export and entity browsing. **Acceptance criteria:** - A saved editor state with HA entity selections exports to YAML that round-trips through `loadFromYaml` (or equivalent importer) without losing selections. - YAML output key for selected entities is documented (e.g. `ha_entities:` with a stable schema). - CORS / proxy doc clearly explains the Vite dev-server proxy and references #6's nginx config for production. - `npm run build`, `npm run lint`, `npm run typecheck` (`tsc -b`) all pass. Add a unit test or fixture for the YAML round-trip. **Out of scope:** - Building the picker UI itself (covered by the sibling child issue). - Editing `src/lib/ha-api.ts` (kept as-is from #5 Slice 1).
Author
Owner

Closing retroactively after fix landed on origin/main.

Commits (rebased onto origin/main):

  • a8d385b — Apply changes from kilo-gsd.py run for Mark/kimi_agent_home_assistant#10 (full slice: YAML exporter with ha_entities: stable key, Vite dev-server proxy + nginx cross-ref, docs/home-assistant.md CORS guide, error toast UI)
  • 984e603 — test(floorplan): fix no-regex-spaces lint error in YAML round-trip test (companion: test for the round-trip acceptance criterion)

Acceptance criteria check:

  • ✅ YAML exporter emits ha_entities: per-room stable key — src/hooks/useFloorplan.ts (280 lines)
  • ✅ YAML round-trip test passes — 984e603 companion commit
  • ✅ Vite dev-server proxy documented with nginx cross-ref — vite.config.ts + docs/home-assistant.md
  • ✅ npm run build, npm run lint, npm run typecheck (tsc -b) all pass — confirmed in kilo-gsd Verify gate

Card closure was correct; close step was bypassed by a push-failed-recovery retry path (non-fast-forward against remote 529de40, rebase onto origin/main + fast-forward push landed the fix).

Closing retroactively after fix landed on origin/main. **Commits (rebased onto origin/main):** - `a8d385b` — Apply changes from kilo-gsd.py run for Mark/kimi_agent_home_assistant#10 (full slice: YAML exporter with `ha_entities:` stable key, Vite dev-server proxy + nginx cross-ref, `docs/home-assistant.md` CORS guide, error toast UI) - `984e603` — test(floorplan): fix no-regex-spaces lint error in YAML round-trip test (companion: test for the round-trip acceptance criterion) **Acceptance criteria check:** - ✅ YAML exporter emits `ha_entities:` per-room stable key — `src/hooks/useFloorplan.ts` (280 lines) - ✅ YAML round-trip test passes — `984e603` companion commit - ✅ Vite dev-server proxy documented with nginx cross-ref — `vite.config.ts` + `docs/home-assistant.md` - ✅ `npm run build`, `npm run lint`, `npm run typecheck` (tsc -b) all pass — confirmed in kilo-gsd Verify gate Card closure was correct; close step was bypassed by a push-failed-recovery retry path (non-fast-forward against remote `529de40`, rebase onto origin/main + fast-forward push landed the fix).
Mark closed this issue 2026-09-30 21:03:32 +00:00
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#10
No description provided.