feat(console): capture as template — export, parameterize, save (CHOO-2658) - #406
abeldantas wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
There are a couple of correctness/quality blockers in the new backend parsing/endpoint path (input validation + an unused local that will fail Ruff) that should be fixed before merging.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds end-to-end “capture room as a template” support: the backend YAML import surface now supports typed template params + JSON inputs, and the Console can export a live room’s YAML, optionally parameterize it, then save/copy it for sharing.
Changes:
- Backend: extend
RoomYamlService.parse()to support top-levelparams:+{name}interpolation, and allowPOST /rooms/from-yamlto accept JSON{ yaml, inputs }. - Console: add a room “Capture as template” flow (new view) with export, parameterize, preview, save-to-file, and copy-to-clipboard.
- Tests: add backend coverage for param resolution/interpolation + a round-trip export→parameterize→re-parse scenario; add unit tests for the client-side parameterize transform.
File summaries
| File | Description |
|---|---|
| core/tests/switch_core/test_rooms_yaml.py | Adds tests for params resolution/interpolation and an export→parameterize→re-parse round trip. |
| core/switch_core/rooms_yaml.py | Implements params: + placeholder interpolation in parse(), plus param coercion helpers. |
| core/switch_core/gateway/rooms.py | Allows /rooms/from-yaml to accept JSON {yaml, inputs} in addition to raw YAML. |
| console/packages/shared/src/parameterize.ts | Adds client-side YAML parameterization transform and YAML-safe quoting. |
| console/packages/shared/src/parameterize.test.ts | Adds vitest coverage for parameterize() behavior and quoting rules. |
| console/packages/shared/src/index.ts | Re-exports parameterize and ParamSubstitution. |
| console/apps/switch-console-desktop/src/shared/core/views/view-ids.ts | Registers new roomTemplateCapture view id. |
| console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-configuration-panel.tsx | Adds “Capture as template” button entry point from a live room. |
| console/apps/switch-console-desktop/src/renderer/features/room-templates/room-template-capture-view.tsx | Implements the capture UI: export, candidate selection, preview, save, copy. |
| console/apps/switch-console-desktop/src/renderer/app/view-registry.ts | Wires the new capture view into the registry. |
| console/apps/switch-console-desktop/src/main/core/switch-servers/gateway-client.ts | Adds exportRoomYaml() client calling GET /rooms/{id}/yaml with section toggles. |
| console/apps/switch-console-desktop/src/main/core/switch-servers/controller.ts | Exposes exportRoomYaml over RPC. |
| console/apps/switch-console-desktop/src/main/core/room-templates/controller.ts | Adds saveToFile + copyToClipboard RPC helpers and keeps YAML parsing utilities. |
Review details
- Files reviewed: 13/13 changed files
- Comments generated: 4
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
4382925 to
a6994cc
Compare
|
All contributors have signed the CLA. ✅ |
7546f9e to
817783b
Compare
56fba8c to
ce83b33
Compare
|
recheck |
37a875f to
8983d27
Compare
7d03f1b to
be25001
Compare
810313b to
fbc2d4c
Compare
…-2658)
Adds the reverse of "Create from template": a button on a live room that
packages it into a shareable template file with an optional parameterize step.
Console:
- "Capture as template" button on the room configuration panel
- Capture view: two-column layout with parameterize panel (editable param
names, "keep literal" toggle per field), YAML preview, round-trip check
sidebar (parse validity, param defaults, no-secrets confirmation), share-it
guidance, full-width stacked Copy YAML / Save file buttons
- gateway-client: exportRoomYaml() (GET /rooms/{id}/yaml)
- roomTemplatesController: saveToFile (Electron dialog), copyToClipboard
Shared:
- parameterize transform: pure function replacing values with {key}
placeholders, quoting for YAML safety, prepending a params: block
matching the server-side grammar — 12 unit tests
Backend:
- Refactored export() to share _export_room_data() helper
- Parameterized export round-trip test (export → {room_name} → re-parse)
be25001 to
d19e73b
Compare
Brief
Closes the share loop for room templates: the reverse of CHOO-2656's "Create from template" — a button on a live room that packages it into a template file, with an optional parameterize step before saving. Part of the room-templates workstream (epic CHOO-2600). Anyone can now capture a room, mark fields as parameters, save or clipboard the result, and share it in a channel for others to import.
Jira: CHOO-2658
Summary
exportRoomYaml()appended — callsGET /rooms/{id}/yamlwith optional section toggles@switch-console/shared): pure function replacing values with{key}placeholders, quoting for YAML safety, and prepending aparams:block matching the server-side grammar from CHOO-2657exportRoomYamlon switchServersController,saveToFile+copyToClipboardon roomTemplatesController{room_name}) → re-parse with inputs → structurally identical room under a new namework/group-templates(CHOO-2657) for the params parser