Skip to content

Save the chosen theme to the user's account and apply it on sign-in - #555

Merged
doomlab merged 1 commit into
devfrom
fix/546-save-theme-to-db
Oct 8, 2026
Merged

doomlab merged 1 commit into
devfrom
fix/546-save-theme-to-db

Conversation

@doomlab

@doomlab doomlab commented Oct 8, 2026

Copy link
Copy Markdown
Member

Closes #546

Finding

The theme picker only wrote to the browser's localStorage. Nothing saved it to the database, and nothing read the User.theme column back (the column exists and MARKER already reads and writes it). So a theme was per-browser, and MARKER never saw what someone picked in STAPLE. I couldn't find the fix mentioned in the issue on dev or in any branch or PR, so this adds it.

What

  • New updateTheme mutation: saves the theme on the signed-in user's own account (validated against the theme list) and refreshes the session.
  • The picker applies the theme immediately, then saves it. If saving fails, the theme stays applied and a toast says it couldn't be saved to the account.
  • The saved theme rides in the session (same way tooltips does: set at login, updated by the mutation), so useInitializeTheme applies it on every page without another query. The database copy wins over the browser's, and the browser copy is updated to match, so the theme follows the user to other devices and matches MARKER.
  • The navbar logo now reads the session theme, so it updates when the theme changes.
  • The theme list moved to src/core/utils/themes.ts (same 30 themes; MARKER's list matches).

Things to know

  • No migration: the column already exists.
  • Default: User.theme defaults to "dark", but STAPLE defaulted to light. Anyone who has never picked a theme will see dark after their next sign-in (a theme they picked in MARKER will show up too).
  • Sessions created before this deploy don't carry a theme, so those users keep their browser's theme until they sign in again or change it.

Testing

8 new tests: the mutation (saves to the right user, refreshes the session, rejects unknown themes), the load behavior (browser theme first, saved theme wins, follows changes, ignores unknown values), and the picker (saves on change, failure message keeps the theme applied). Typecheck (apart from the existing getJsonSchema.test.ts errors), lint and the full test suite (86 passed, 2 skipped as before) pass. Not yet checked in a browser, including signing in on a second browser to see the saved theme.

🤖 Generated with Claude Code

…546)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@doomlab
doomlab merged commit ad83bd1 into dev Oct 8, 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.

make sure that the theme is being saved to the database

1 participant