Fix first-sync merge clobbering real cloud data with fresh device defaults - #112
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…r real cloud data
syncSettingsFromCloud's three-way merge fell back to {} for base/local when a
device had never synced before, so every untouched key looked "changed"
relative to nothing. If cloud also had a value for that key (always true for
real data), it read as a same-key conflict resolved by timestamp — and a
brand-new device's very first local write (e.g. geolocation silently saving
default settings + coords the moment a widget mounts) always has a fresher
"now" timestamp than data synced earlier from another device, so the empty
local defaults would win and get pushed back up over the real cloud data.
Falls back to the app's normalized default settings instead of {}, so an
untouched key reads as unchanged regardless of write timestamp and cloud
wins cleanly with no false conflict, while genuine local-only customizations
still merge in correctly.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
syncSettingsFromCloud's three-way merge fell back to{}forbase/local, so every untouched key looked "changed" relative to nothing — turning normal cloud data into a false same-key conflict resolved by timestamp recency.getOrRequestLocationinsrc/lib/geolocation.tssilently saving default settings + coordinates the moment a weather/air-quality/solar-graph widget mounts) always carries a fresher "now" timestamp than data synced earlier from another device, so the empty local defaults would win the tiebreak and get pushed back up, overwriting the user's real cloud data (bookmarks, vault items, widgets, etc.).seedSettings) instead of{}, so an untouched key correctly reads as unchanged no matter its write timestamp. Cloud wins cleanly with no false conflict, while genuine local-only customizations (e.g. real work done signed-out before this sign-in) still merge in properly.Test plan
vitest run— 204 tests pass, including a new regression test that reproduces the exact scenario (fresh device, newer-but-default local write vs. older-but-real cloud data) and asserts the fix.tsc --noEmit— same 65 pre-existing errors as onmain, none in changed files.🤖 Generated with Claude Code