Skip to content

fix: prevent false-positive conflict toast on first write to unbaselined keys - #77

Open
sunnyhaibin wants to merge 2 commits into
mainfrom
fix/verify-write-baseline-false-positive
Open

sunnyhaibin wants to merge 2 commits into
mainfrom
fix/verify-write-baseline-false-positive

Conversation

@sunnyhaibin

Copy link
Copy Markdown
Contributor

…ned keys

verifyWrite was treating any stale readback as a device conflict when the
key had no prior baseline entry (first-ever write, or fresh session after a
firmware update rotates the git commit and clears the cache). valuesEqual
returns false when compared against undefined, so any value from the poll
that didn't match desiredValue immediately triggered "was changed on the
device" and rolled back the UI — even though the write had succeeded.

Two fixes:
- batchPush: skip conflict detection in verifyWrite when baselineAtPushTime
  has no entry for the key; fall through to optimistic confirm and let drift
  detection surface genuine mismatches on the next poll cycle.
- +layout.svelte: after the background prefetch, backfill the driftStore
  baseline with any freshly-fetched key that isn't already there. Closes
  the root cause so the guard rarely triggers in practice.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@netlify

netlify Bot commented May 7, 2026

Copy link
Copy Markdown

Deploy Preview for sunnylink-frontend ready!

Name Link
🔨 Latest commit fe3df8d
🔍 Latest deploy log https://app.netlify.com/projects/sunnylink-frontend/deploys/6a0401589e015b0008934bc1
😎 Deploy Preview https://deploy-preview-77--sunnylink-frontend.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions

github-actions Bot commented May 7, 2026

Copy link
Copy Markdown

📊 Code Coverage Report

Metric Coverage
Statements 2.83%
Branches 2.28%
Functions 4.69%
Lines 2.64%
How to view detailed coverage
  1. Go to the Actions tab
  2. Download the test-results-pr-77 artifact
  3. Extract and open coverage/index.html in your browser

@netlify

netlify Bot commented May 7, 2026

Copy link
Copy Markdown

A new user left a comment. This user must be approved by a Netlify team owner before comments can be displayed.

Approve this user

500ms was too aggressive for uncommon keys (Ford etc.) where POST
takes 1.2–3.5s. Readback fired before the write applied, producing
false-positive "changed on device" toasts. 2.5s covers observed
round-trips with no UX cost — confirmKeys already fires optimistically.
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