Skip to content

feat(web-ui): Settings panel — view, edit, backup and export config #38

@adrianwedd

Description

@adrianwedd

Summary

Add a Settings panel to the SPARK web dashboard (GET /) covering all runtime configuration: session state, voice tuning, mind backend, and data backup/export. Currently none of this is accessible from the UI — you have to SSH in and edit files.

Scope

UI — new "Settings" tab in sidebar or gear icon → modal/panel

Five collapsible sections:


1. Session & Persona

Fields (all editable, PATCH /api/v1/session on save):

Field Type Notes
persona select: spark / gremlin / vixen / — Live switch
confirm_motion_allowed toggle Safety gate
wheels_on_blocks toggle Dev safety
spark_quiet_mode toggle Regulation state
obi_routine text (read-only) Current routine name
obi_step number (read-only) Current step index
obi_mood text (read-only) Last recorded mood
obi_streak number (read-only) Current streak count

2. Voice

Fields (saved to a new PATCH /api/v1/voice endpoint that writes env overrides to session):

Field Type Range
variant select: en+m3 / en+f4 / en+croak / … espeak voice variants
pitch slider 0–99
rate slider 80–200
  • Preview button: calls tool_voice with "Hello, I'm SPARK" using current slider values
  • Changes written to session (voice_variant, voice_pitch, voice_rate) and picked up by execute_tool()'s persona env injection

3. Mind & Model

Fields (saved to .env via new PATCH /api/v1/config endpoint):

Field Type Default
PX_MIND_BACKEND select: claude / ollama claude
PX_MIND_CLAUDE_MODEL select: claude-haiku-4-5-20251001 / claude-sonnet-4-6 claude-haiku-4-5-20251001
PX_OLLAMA_HOST text http://M1.local:11434
PX_MIND_MODEL text qwen3.5:0.8b
PX_OLLAMA_HOST (tool-chat) text same
Awareness interval number (seconds) 30
Reflection interval (idle) number (seconds) 120

4. Backup & Export

Buttons only — no editing:

Button Action Notes
Download session.json GET /api/v1/backup/session Direct file download
Download notes (SPARK) GET /api/v1/backup/notes notes-spark.jsonl
Download thoughts (SPARK) GET /api/v1/backup/thoughts thoughts-spark.jsonl
Download full backup GET /api/v1/backup/all ZIP: all state + .env (masked)
Export config JSON GET /api/v1/config All non-secret settings as JSON
Restore from backup POST /api/v1/backup/restore Upload ZIP — restores state files

5. Danger Zone

Action Confirmation required
Clear SPARK thoughts Wipes thoughts-spark.jsonl
Clear SPARK notes Wipes notes-spark.jsonl
Reset session to defaults Restores session.template.json
Restart API server Kills + relaunches px-api-server

All danger actions require a confirmation dialog ("Type CONFIRM to proceed").


New API endpoints required

Method Path Auth Description
GET /api/v1/config Yes All non-secret runtime config as JSON
PATCH /api/v1/config Yes Update .env-based config (model, host, intervals)
PATCH /api/v1/voice Yes Update voice settings (variant/pitch/rate) in session
GET /api/v1/backup/session Yes Download session.json
GET /api/v1/backup/notes Yes Download notes-{persona}.jsonl
GET /api/v1/backup/thoughts Yes Download thoughts-{persona}.jsonl
GET /api/v1/backup/all Yes Download ZIP of all state files
POST /api/v1/backup/restore Yes Upload ZIP, restore state files

.env editing safety

.env writes go through a dedicated write_env_var(key, value) helper that:

  1. Reads existing .env line by line
  2. Updates matching key in-place or appends
  3. Writes atomically (temp file + rename)
  4. Never exposes PX_API_TOKEN or ANTHROPIC_API_KEY values in GET /api/v1/config responses (mask as "***")

Implementation order

  1. GET /api/v1/config + GET /api/v1/backup/* endpoints (read-only, safe)
  2. Settings panel UI (tabbed sections, read-only first)
  3. Session edit fields + PATCH /api/v1/voice
  4. PATCH /api/v1/config + .env writer
  5. Backup ZIP download + restore upload
  6. Danger zone actions

Non-goals

  • No live log streaming (separate issue)
  • No file browser
  • No SSH terminal in browser
  • No user management / multi-user auth

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiREST API (port 8420)enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions