Skip to content

Persist local user settings #30

Description

@williamthorsen

Problem

The Factory sidebar allows orchestration runs to be dismissed from the list, but dismissals are stored in React state (useState) and lost on page refresh. The entire list reappears after any reload.

Proposed solution

Persist user settings to a server-side JSON file via new REST API endpoints. The Express server gains a SettingsStore service that reads/writes settings.json to a configurable directory (FACTORY_SETTINGS_PATH env var, defaulting to ~/.config/codeassembly/factory/). New GET/PATCH /api/settings endpoints expose settings to the client. The useDismissedRuns hook switches from in-memory useState to server-synced state with optimistic updates.

Key design decisions

  • Server-persisted to disk (not browser localStorage) because the app runs locally
  • Configurable path: FACTORY_SETTINGS_PATH env var > ~/.config/codeassembly/factory/settings.json default (follows existing AI_PROJECTS_PATH pattern)
  • Status-aware dismissals: Each dismissed run records the status at dismissal time. If a run's status changes (e.g., re-executed), it reappears automatically
  • Extensible settings model: UserSettings interface supports future UI preferences as new top-level keys
  • Atomic writes: Write to temp file + rename to prevent corruption on crash
  • Graceful degradation: Missing/corrupted settings file falls back to defaults; client falls back to session-only behavior if server is unreachable

Data model

{
  "dismissedRuns": {
    "my-project/TICKET-1/run-001": { "status": "completed" },
    "my-project/TICKET-2/run-002": { "status": "failed" }
  }
}

Acceptance criteria

  • Dismissing a run persists to settings.json on disk
  • Dismissed runs remain dismissed after page refresh
  • A dismissed run reappears if its status changes (e.g., re-executed)
  • "Clear all" persists all dismissals at once
  • Settings directory is created automatically if it doesn't exist
  • Missing or corrupted settings file falls back to empty defaults without crashing
  • Settings path is configurable via FACTORY_SETTINGS_PATH env var
  • All new code has unit tests (SettingsStore, settings route, updated hook)
  • pnpm run check passes

Metadata

Metadata

Labels

featureAdded or improved external functionalityscope:factory

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions