refactor: migrate settings source of truth to config.json - #115
Merged
Conversation
Move portable user preferences (theme, font, editor width, etc.) from SQLite-only storage to <vault>/.memry/config.json as the source of truth. SQLite becomes a read cache for fast IPC performance. Key changes: - VaultPreferences Zod schema + readPreferences/writePreferences helpers - SET_GENERAL_SETTINGS and SET_EDITOR_SETTINGS write config.json first, then update SQLite cache - Vault open flow migrates: if config.json has preferences, use them; if missing, seed from SQLite (one-time migration) - settingsHandler.applyUpsert now propagates merged sync data to config.json, updates SQLite cache, and broadcasts CHANGED events (fixes the synced_settings → general key gap) - Machine-local settings (startOnBoot, onboardingCompleted, etc.) stay in SQLite only 68 new/updated tests across 5 test files, all passing.
Use schema/index import for DrizzleDb type compatibility and fix editor seed object typing in migrateSettingsToConfig.
h4yfans
added a commit
that referenced
this pull request
May 6, 2026
* refactor: migrate user preferences from SQLite to config.json Move portable user preferences (theme, font, editor width, etc.) from SQLite-only storage to <vault>/.memry/config.json as the source of truth. SQLite becomes a read cache for fast IPC performance. Key changes: - VaultPreferences Zod schema + readPreferences/writePreferences helpers - SET_GENERAL_SETTINGS and SET_EDITOR_SETTINGS write config.json first, then update SQLite cache - Vault open flow migrates: if config.json has preferences, use them; if missing, seed from SQLite (one-time migration) - settingsHandler.applyUpsert now propagates merged sync data to config.json, updates SQLite cache, and broadcasts CHANGED events (fixes the synced_settings → general key gap) - Machine-local settings (startOnBoot, onboardingCompleted, etc.) stay in SQLite only 68 new/updated tests across 5 test files, all passing. * docs: add settings config.json migration changelog entry * fix: resolve type errors in settings-cache for CI typecheck Use schema/index import for DrizzleDb type compatibility and fix editor seed object typing in migrateSettingsToConfig.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Move portable user preferences from SQLite-only storage to
<vault>/.memry/config.jsonas the source of truth. SQLite becomes a read cache for fast IPC performance.Why
User preferences stored in SQLite are opaque when copying a vault to a new machine pre-sign-in. Additionally,
mergeRemote()wrote tosynced_settingskey but never propagated to thegeneralkey the UI reads — settings from other devices were invisible until app restart.How
readPreferences()/writePreferences()for config.json I/O with deep-partial mergestartOnBoot,onboardingCompletedstay SQLite-onlymigrateSettingsToConfig()— if config.json has preferences, use them; if missing, seed from SQLite (one-time backwards-compatible migration)mergeRemote(), propagates merged data to config.json, updates SQLite cache, and broadcasts CHANGED events — fixes the synced_settings→general key gappropagateMergedSettingsandbroadcastSettingsChangedgracefully handle missing vault path, database, or BrowserWindow (test environments, edge cases)Type
refactor— restructure without behavior changeTest plan
68 new tests across 5 test files:
vault-preferences.test.ts(15) — schema validation, read/write, partial merge, corruption recoverysettings-cache.test.ts(7) — SQLite cache population, migration from SQLite→config.json, machine-local field preservationsettings-handlers.test.ts(+6 = 29 total) — config.json write-through for portable/local/editor fieldssettings-handler.test.ts(6) — sync merge propagation to config.json + CHANGED broadcastapply-item.test.ts(25) — existing integration tests still passChecklist