Skip to content

feat(settings): persist user settings server-side with a /settings page#28

Merged
setkyar merged 7 commits into
mainfrom
feat/settings-persistence
Jun 2, 2026
Merged

feat(settings): persist user settings server-side with a /settings page#28
setkyar merged 7 commits into
mainfrom
feat/settings-persistence

Conversation

@setkyar
Copy link
Copy Markdown
Contributor

@setkyar setkyar commented Jun 1, 2026

Summary

  • Add a server-backed settings KV table in pi-web.sqlite plus GET/POST /api/settings, moving durable preferences (theme, spinner style, view layout, notify-on-done + sound, cat-gatekeeper config) off per-browser localStorage. Unknown keys are ignored; with no DB, reads return defaults and writes no-op.
  • Inject the persisted theme into the HTML shell server-side via a <meta name="pi-web-theme"> tag (read by the boot scripts) so the page paints the right theme before first paint and it is shared across browsers.
  • Make localStorage a write-through cache (web/src/shared/settings-store.js): hydrated from the server on load, written through on change. Existing setters (theme, done-notifier, cat-settings, index layout) route through it.
  • Add a dedicated /settings page (Go shell + Vite entry) and strip the appearance/notifications/spinner items from the nav dropdown, replacing the placeholder with a real link.
  • Fix live theme switching: applyTheme now updates the inline <html> background (and theme-color) so the page background changes without a refresh; settings page uses subtle --dim borders for dark mode.

Testing

  • make check (vitest + go test ./... + go build + go vet)
  • npx vitest run (49 files, 297 tests passing)
  • Manual: ran the server, verified GET/POST /api/settings round-trips and the persisted theme is injected into /, /session, and /settings.

setkyar added 2 commits June 2, 2026 00:05
Move durable user preferences (theme, spinner, view layout, notifications +
sound, cat-gatekeeper config) from per-browser localStorage to the existing
pi-web.sqlite via a new settings KV table and GET/POST /api/settings. The
theme is injected into the HTML shell server-side (a meta tag) so the page
paints correctly before first paint; localStorage becomes a write-through
cache hydrated from the server on load.

Adds a dedicated /settings page (Go shell + Vite entry) and removes the
appearance/notifications/spinner items from the nav dropdown, replacing the
placeholder with a real link. Fixes live theme switching so the page
background updates without a refresh, and uses subtle border tokens on the
settings page for dark mode.
…ence

# Conflicts:
#	docs/architecture/system-overview.md
#	internal/server/server.go
@setkyar
Copy link
Copy Markdown
Contributor Author

setkyar commented Jun 2, 2026

Merge conflicts with main are resolved and pushed (6ca199f).

Conflicts were in two files, resolved to keep both sides:

  • internal/server/server.go — this branch's settings table + /api/settings route now coexist with main's project_prefs/app_settings tables and /api/btw routes.
  • docs/architecture/system-overview.md — merged the Local DB row, route list (/api/settings + /api/projects), and directory-layout note.

Verification: git diff --check clean, no conflict markers remain, make build succeeds, and all Go tests + 315 frontend tests pass.

setkyar added 5 commits June 2, 2026 10:50
Add a global Cmd/Ctrl+, shortcut (the standard preferences shortcut) that
navigates to /settings. It works regardless of focus, like a native app, and
is installed on every page via setupKeyboardNav.
Turn the Settings placeholder into a real /settings link with a ⌘, hint,
move Settings above Version so Version always sits at the bottom, and remove
the non-functional Import Session / Active Sessions / Archived Sessions items.
Replace the fixed 8-hour sleep window with an explicit wakeup time (default
23:00–07:00) computed from bedtime→wakeup, and add a one-time snooze at the
bedtime warning. Settings persistence for the new wakeup key lands with the
settings-page changes.
Add server-backed interface and content fonts (curated keywords, typed custom
families, or Local Font Access detection) plus separate UI/content font sizes,
all injected into the HTML shell so pages paint correctly before JS runs and
applied live on the settings page. Add the Cat Gatekeeper wakeup row + its
persistence plumbing, and make the settings back button return to the previous
in-app page (e.g. a session detail) instead of always going home.
…routes

Add a getPostHandler helper that routes GET/POST to their handlers and returns
405 (with an Allow header) for any other method before the auth middleware
runs. Apply it to /api/projects, /api/scratchpad, and /api/settings.
@setkyar setkyar merged commit 808c5d0 into main Jun 2, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant