Skip to content

Web UI: YAML config editor (view/test/apply/save the active .profiles) #95

Closed
8 of 8 issues completed

Description

@falbany

Goal

Add a YAML text editor to the web front-end to view and edit the active .profiles configuration file, with a two-step safety model: edits are applied in memory first (session trial, reusing the drop-config pipeline), and written to disk only through an explicit, compliance-gated Save.

Design spec: docs/superpowers/specs/2026-11-03-yaml-config-editor-design.md
Implementation plan: docs/superpowers/plans/2026-11-03-yaml-config-editor.md

Editor technology

CodeMirror 6 (codemirror + @codemirror/lang-yaml, ~150 KB) in a full-screen modal, themed from the existing data-theme tokens. Monaco (~2 MB) rejected as too heavy for the PWA; plain textarea rejected (no highlighting).

Backend — new endpoints on /api/config

  1. GET /content — raw YAML text + filename + config_path; session_trial: true when the active config came from a drop (no disk path).
  2. POST /validate — {content, filename} → 200 {valid, issues: [{severity, message}]}. Always 200; validity in the body. Parses via ConfigReader.from_content; no state change. Powers Test and the save gates.
  3. POST /template — renders STARTER_CONFIG_TEMPLATE.format(cwd=active directory) in memory (same content as --init); nothing written.
  4. POST /save — validate → optional force: true → write to config_path. 400 for session-trial configs (no path). Bad YAML never touches the file without force.
  5. POST /save-as — {content, filename, directory, force, overwrite}; extensions restricted to .profiles / .profiles.yaml; existing target refused without overwrite: true; on success applies the saved config and re-derives the active directory.

Apply reuses the existing POST /load-content unchanged.

Frontend — full-screen modal

Toolbar: New (template, confirms if dirty) · Test (✓ valid / ✗ inline issue list) · Apply (live session-trial apply) · Save · Save as (directory browse + filename input, "Replace?" confirm on existing target) · Revert.

  • Save / Save as run server validation first; on issues, show the list and offer "Go back and fix" / "Force save anyway".
  • Dirty indicator; Escape/✕ warns on unsaved edits; Cmd/Ctrl+S → Save (falls back to Apply for session trials).
  • Save disabled for session-trial configs (no disk path).
  • Entry point next to the existing config actions; Apply refreshes the app like a config load.
  • dist/ rebuilt and committed.

Non-goals

  • No form-based GUI editor.
  • No schema autocomplete for v1 (server-validated feedback is enough).
  • No file picker for arbitrary configs (edits the active config only).

Documentation (en + fr)

  • User guide: Config Editor section (toolbar, two-step model, compliance gate, force-save, Save-as extensions).
  • --init / starter-template docs: pointer to New in the UI.
  • Advanced guide: the new /api/config/* endpoints for alternative front-ends.
  • README feature bullet (en/fr).

Tests

  • pytest route tests for the 5 endpoints (valid/invalid/force/overwrite/extension restriction/session-trial refusal).
  • vitest for the modal (open/load, Test, Apply, save gating, force path, Save-as dialog, dirty-escape warning).

Sub-issues

Sub-issues

8 of 8 Issues completed
Loading 8 sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementfrontend

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions