Conversation
ianneub
marked this pull request as draft
September 24, 2026 23:19
ianneub
force-pushed
the
ian/bug/legacy-prefs-clobber
branch
from
September 24, 2026 23:20
c579c80 to
c0ca4ad
Compare
DesktopSharedPreferencesStore only replaced the async prefs backend. The legacy SharedPreferences API (used by the legacy->async migration in SharedPreferencesService.init() and by emoji_picker_flutter to save recent emojis) went to the stock Linux/Windows backend, which rewrites the whole shared file from a per-isolate snapshot taken at startup. One emoji pick could revert or wipe every setting written since then, including serverAddress and finishedSetup, and the next launch cleared the database and returned to setup. register() now also installs a legacy SharedPreferencesStorePlatform adapter that reads and writes through the same lock + atomic-write store. _mutate/_atomicWrite now report whether the file was written, so legacy writes return false on failure like the stock backends did. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AyxJz1fsojfXbxJUBBsivy
ianneub
force-pushed
the
ian/bug/legacy-prefs-clobber
branch
from
September 24, 2026 23:36
c0ca4ad to
157f21b
Compare
ianneub
marked this pull request as ready for review
September 24, 2026 23:37
jjoelj
approved these changes
Sep 29, 2026
This branch has not been deployed
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.
Fixes #3286
Problem
DesktopSharedPreferencesStorereplaced only the async prefs backend. The legacySharedPreferencesAPI, whichemoji_picker_flutterstill uses to save recent emojis, went to the stock Linux/Windows backend. That backend rewrites the whole sharedshared_preferences.jsonfrom a snapshot taken when the isolate started. One emoji pick could revert or wipe every setting written since then, includingserverAddressandfinishedSetup. On the next launch the app then cleared the database and returned to setup.Solution
DesktopSharedPreferencesStore.register()now also installs_DesktopLegacySharedPreferencesStore, a smallSharedPreferencesStorePlatformadapter that reuses the store's existing_readFile/_mutate. Legacy calls re-read the file, and legacy writes go through the existing lock + atomic write +.bakpath. Legacy keys stay as they are (flutter.-prefixed, same file), so the legacy→async migration and existing data are unaffected._mutate/_atomicWritenow report whether the file was written, so legacy writes returnfalseon failure like the stock backends. Also updatedsettings/CLAUDE.md.Testing (Linux, Flutter 3.44.6)
flutter testrepro (not committed; the repo has no test suite). It seeds the prefs file, callsregister()andSharedPreferences.getInstance(), writeslastOpenedChatviaSharedPreferencesAsync, then callslegacy.setString('recent', '[]'). On this branch it also checksremove,setStringList,clear, the deprecated*WithPrefixmethods, and that a forced write failure returnsfalsewithout touching the file:master@ e2eaced: file ends as[serverAddress, finishedSetup, flutter.recent], solastOpenedChatis lost ❌[serverAddress, finishedSetup, lastOpenedChat, flutter.recent]✅flutter build linux --release, run against a copy of a real profile (146 keys) and a real server. The app starts with setup intact and syncs. After opening a chat and picking an emoji,flutter.recentupdated,lastOpenedChatkept its new value, and no keys were lost.flutter analyzeonlib/services/backend/settings/: no issues.🤖 Generated with Claude Code
https://claude.ai/code/session_01AyxJz1fsojfXbxJUBBsivy