fix(ui): refresh stale screens after data changes (coach edit, goals, metric detail)#88
Merged
Merged
Conversation
… metric detail) Three reactivity gaps where a write didn't reach the UI until an unrelated sync or relaunch: - Coach editing a *today* workout used `applyUpdatesNow`, which set the session fields directly and never bumped the change token or routed through `ActivityService.applyEdit` — so Today/Activity showed the old duration/distance/calories and the daily rollup was computed off stale fields. Route type/time through the edit service and notify(), matching the confirmed-edit path in `PendingActionExecutor`. - Editing a daily Goal persisted the `UserGoal` but never bumped the token, and goal targets aren't in Today's data signature, so the rings kept filling against the old goal. notify() after save. - MetricDetailView only reloaded on the period segment; a sync completing while it was open left its chart + Latest/Avg/Min/Max tiles stale. Observe `PulseDataChange.token` and reload.
…s; drop redundant coach-edit notify
saksham2001
approved these changes
Jul 15, 2026
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.
Three independent reactivity gaps where a write didn't reach the UI until an unrelated sync or an app relaunch. Found via a code audit; all hit connected-ring users.
1. Coach editing today's workout left Today/Activity stale + corrupted aggregates
ActionTools.applyUpdatesNow(the immediate path for a today-dated session) setsession.type/startedAt/endedAt/distancedirectly and calledsave()— but never bumped the change token and never routed throughActivityService.applyEdit. So after "make today's run 45 min" the workout card updated while Today/Activity kept the old duration/distance/calories, and the daily rollup was computed off stale fields. Now mirrors the confirmed-edit path inPendingActionExecutor(route type/time throughapplyEdit, apply a user-stated distance after, thennotify()).2. Goal edits didn't re-fill Today's rings until a sync/relaunch
GoalsSettingsView.save()persisted theUserGoalbut never bumped the token, and goal targets aren't part ofTodayStore's signature — so the rings kept filling against the old goal. AddedPulseDataChange.shared.notify()after save.3. MetricDetailView went stale on a sync while open
Its only data trigger was
.task(id: period)into@State. A background sync completing while the detail was open left its chart + Latest/Avg/Min/Max tiles showing pre-sync numbers (disagreeing with the dashboard behind it). Now observesPulseDataChange.tokenand reloads, matching Today/Vitals.Builds green.