You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Apple Watch sync: a set's identity across watch edits (four edge cases from #1139) #1162
Suggested labels:bug, mobile · Suggested milestone: v1.4.6: Wear OS & Health Connect (I can't set these myself: my account has no triage rights on this repo.)
Why
The set-type menu on the Apple Watch (#1139) lets you mark, add and remove sets from the wrist while the phone keeps its own copy of the workout. CodeRabbit found four edge cases where the two copies can briefly disagree. None loses a logged set, and each is rare. But they all come from the same root: the watch and the phone name a set by its position, and positions move when sets are added or removed. Fixing them properly means giving sets a stable identity across the sync, which is too big for a review fix on #1139. This issue keeps them together so #1139 can merge.
The four cases
A tick after a refused Remove can land on a shifted row. If the phone refuses a removal from the watch, a tick queued after it is applied by position and can mark the neighbouring set. The code already says so (lean: comment in lib/watch-sync.js, setDone after a refused structural event). (comment)
Any phone update ends the 4 s Undo early.SessionStore.apply(json:) sends a held removal as soon as any valid snapshot arrives, on purpose: Undo would otherwise overwrite a newer snapshot. An echo of your own tick can therefore hide Undo after a second. (comment)
A mark made before a tick can vanish for one sync. When an older snapshot lands, the tick is merged before the pending edits replay, so a mark captured before the tick is dropped until the next snapshot. Nothing is lost: the phone applies both in watch order. (comment)
What a fix looks like
A stable id per set row, carried in snapshots and events (the phone already has one per logged set in history).
Ticks, marks, Undo and pending keys keyed by that id instead of exId#index, with a one-time migration of stored keys.
Undo that drops the held removal from the current state instead of restoring the old state.
Until then, (3) could be avoided by turning off Warm-up and Remove in the watch menu for an exercise that appears twice.
Activity
Watch sync: one rest for phone and watches (restAt stamps, rest event…
Watch sync: a done set edited on the phone carries the edit's time, s…
docs/WATCH_SYNC.md: protocol 2 (one rest by its stamp, the rest event…
Wear OS protocol 2: one rest by its stamp (restAt kept on disk, follo…