[PR #90] [MERGED] feat: persist user settings server-side across devices #4456

Closed
opened 2026-10-22 04:07:45 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/90
Author: @LukaTheHero
Created: 4/16/2026
Status: ✅ Merged
Merged: 4/16/2026
Merged by: @LukaTheHero

Base: main ← Head: Persistent-settings


📝 Commits (1)

  • dd8b7f6 feat: persist user settings server-side across devices

📊 Changes

11 files changed (+263 additions, -0 deletions)

View changed files

📝 packages/client/src/App.tsx (+2 -0)
➕ packages/client/src/hooks/use-settings-sync.ts (+115 -0)
📝 packages/client/src/stores/ui.store.ts (+51 -0)
📝 packages/server/src/db/migrate.ts (+5 -0)
➕ packages/server/src/db/schema/app-settings.ts (+10 -0)
📝 packages/server/src/db/schema/index.ts (+1 -0)
➕ packages/server/src/routes/app-settings.routes.ts (+29 -0)
📝 packages/server/src/routes/index.ts (+2 -0)
➕ packages/server/src/services/storage/app-settings.storage.ts (+30 -0)
📝 packages/shared/src/index.ts (+1 -0)
➕ packages/shared/src/schemas/app-settings.schema.ts (+17 -0)

📄 Description

Summary

User settings were previously stored only in browser localStorage, so every browser and device saw its own independent preferences. This PR moves them to a server-backed key/value table so they follow the user across browsers and devices until explicitly edited.

  • New app_settings (key, value, updated_at) table with a single ui row holding the serialized preference blob
  • GET/PUT /api/app-settings/:key (allowlisted to ui)
  • New client hook useSettingsSync() (wired in App.tsx) that on mount fetches the server blob and overlays it onto the Zustand UI store, then debounces (1s) and pushes any subsequent changes back to the server
  • localStorage is kept as a fast-boot cache — the server is authoritative on mount
  • One-time seed: existing users' localStorage settings are pushed to the server the first time the app loads after this change

What's now persistent across devices/browsers

Defined in pickSyncedSettings in packages/client/src/stores/ui.store.ts:

General tab

  • Enable streaming responses, Streaming speed
  • Send on Enter (Roleplay), Send on Enter (Conversations)
  • Confirm before deleting
  • Messages per page
  • Bold dialogue in quotes

Appearance tab

  • Font size, chat font size, font family
  • Visual theme (default / sillytavern)
  • Chat background
  • Narration color + opacity
  • Chat font color + opacity
  • Text stroke width + color
  • Conversation gradient (from/to)
  • Weather effects
  • HUD position
  • Conversation notification sound, RP notification sound

Advanced tab

  • Debug mode
  • Group consecutive messages
  • Show message timestamps / model name / token usage / message numbers

Other preferences

  • Theme (dark / light)
  • Custom conversation prompt (system prompt override)
  • Sidebar open state + width
  • EchoChamber side
  • User status (manual)
  • "Has completed onboarding" flag
  • "Link API banner dismissed" flag

Explicitly NOT synced (stays device-local)

  • Custom themes — already server-synced via the existing custom_themes table
  • Installed extensions — different devices may legitimately want different ones
  • userStatus (auto-idle) — computed from inactivity per-device
  • Transient UI state — open modals, detail panels, which settings tab is open, etc.
  • hasMigratedCustomThemesToServer — per-device migration flag

Known tradeoffs

  • Last-write-wins: two tabs/devices editing near-simultaneously → the later PUT overwrites the earlier one. No real-time cross-tab sync.
  • Offline edit + reload: if the server is unreachable when a setting is changed and the user reloads before it recovers, the stale server value overlays the local edit.
  • Default-flash: on a brand-new device, defaults render for ~100–300 ms before the server response overlays the real settings.
  • Dual list: new settings must be added to both partialize (localStorage) and pickSyncedSettings (server) or they won't sync.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/90 **Author:** [@LukaTheHero](https://github.com/LukaTheHero) **Created:** 4/16/2026 **Status:** ✅ Merged **Merged:** 4/16/2026 **Merged by:** [@LukaTheHero](https://github.com/LukaTheHero) **Base:** `main` ← **Head:** `Persistent-settings` --- ### 📝 Commits (1) - [`dd8b7f6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/dd8b7f6c349210831dc5eb4f377574955c85de08) feat: persist user settings server-side across devices ### 📊 Changes **11 files changed** (+263 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/App.tsx` (+2 -0) ➕ `packages/client/src/hooks/use-settings-sync.ts` (+115 -0) 📝 `packages/client/src/stores/ui.store.ts` (+51 -0) 📝 `packages/server/src/db/migrate.ts` (+5 -0) ➕ `packages/server/src/db/schema/app-settings.ts` (+10 -0) 📝 `packages/server/src/db/schema/index.ts` (+1 -0) ➕ `packages/server/src/routes/app-settings.routes.ts` (+29 -0) 📝 `packages/server/src/routes/index.ts` (+2 -0) ➕ `packages/server/src/services/storage/app-settings.storage.ts` (+30 -0) 📝 `packages/shared/src/index.ts` (+1 -0) ➕ `packages/shared/src/schemas/app-settings.schema.ts` (+17 -0) </details> ### 📄 Description ## Summary User settings were previously stored only in browser `localStorage`, so every browser and device saw its own independent preferences. This PR moves them to a server-backed key/value table so they follow the user across browsers and devices until explicitly edited. - New `app_settings (key, value, updated_at)` table with a single `ui` row holding the serialized preference blob - `GET/PUT /api/app-settings/:key` (allowlisted to `ui`) - New client hook `useSettingsSync()` (wired in `App.tsx`) that on mount fetches the server blob and overlays it onto the Zustand UI store, then debounces (1s) and pushes any subsequent changes back to the server - `localStorage` is kept as a fast-boot cache — the server is authoritative on mount - One-time seed: existing users' `localStorage` settings are pushed to the server the first time the app loads after this change ## What's now persistent across devices/browsers Defined in `pickSyncedSettings` in `packages/client/src/stores/ui.store.ts`: **General tab** - Enable streaming responses, Streaming speed - Send on Enter (Roleplay), Send on Enter (Conversations) - Confirm before deleting - Messages per page - Bold dialogue in quotes **Appearance tab** - Font size, chat font size, font family - Visual theme (default / sillytavern) - Chat background - Narration color + opacity - Chat font color + opacity - Text stroke width + color - Conversation gradient (from/to) - Weather effects - HUD position - Conversation notification sound, RP notification sound **Advanced tab** - Debug mode - Group consecutive messages - Show message timestamps / model name / token usage / message numbers **Other preferences** - Theme (dark / light) - Custom conversation prompt (system prompt override) - Sidebar open state + width - EchoChamber side - User status (manual) - "Has completed onboarding" flag - "Link API banner dismissed" flag ## Explicitly NOT synced (stays device-local) - **Custom themes** — already server-synced via the existing `custom_themes` table - **Installed extensions** — different devices may legitimately want different ones - **`userStatus`** (auto-idle) — computed from inactivity per-device - **Transient UI state** — open modals, detail panels, which settings tab is open, etc. - **`hasMigratedCustomThemesToServer`** — per-device migration flag ## Known tradeoffs - **Last-write-wins**: two tabs/devices editing near-simultaneously → the later PUT overwrites the earlier one. No real-time cross-tab sync. - **Offline edit + reload**: if the server is unreachable when a setting is changed and the user reloads before it recovers, the stale server value overlays the local edit. - **Default-flash**: on a brand-new device, defaults render for ~100–300 ms before the server response overlays the real settings. - **Dual list**: new settings must be added to both `partialize` (localStorage) and `pickSyncedSettings` (server) or they won't sync. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:07:45 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#4456
No description provided.