Skip to content

Fix first-sync merge clobbering real cloud data with fresh device defaults - #112

Merged
timh-dev merged 1 commit into
mainfrom
v3/fix-sync-clobber-on-signin
Aug 10, 2026
Merged

Fix first-sync merge clobbering real cloud data with fresh device defaults#112
timh-dev merged 1 commit into
mainfrom
v3/fix-sync-clobber-on-signin

Conversation

@timh-dev

Copy link
Copy Markdown
Owner

Summary

  • On a device's very first sync, syncSettingsFromCloud's three-way merge fell back to {} for base/local, so every untouched key looked "changed" relative to nothing — turning normal cloud data into a false same-key conflict resolved by timestamp recency.
  • A brand-new device's first local write (e.g. getOrRequestLocation in src/lib/geolocation.ts silently 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.).
  • Fixes it by falling back to the app's normalized default settings (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 on main, none in changed files.

🤖 Generated with Claude Code

@vercel

vercel Bot commented Aug 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
startup-page-iebp Ready Ready Preview Aug 10, 2026 11:38am

…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>
@timh-dev
timh-dev merged commit b7d4628 into main Aug 10, 2026
6 checks passed
@timh-dev
timh-dev deleted the v3/fix-sync-clobber-on-signin branch August 10, 2026 11:51
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.

1 participant