fix(today/vitals): apply Settings visibility + chart-detail changes immediately - #70
Merged
saksham2001 merged 2 commits intoJul 12, 2026
Conversation
…mmediately TodayStore/VitalsStore rebuild only when a cheap currentSignature() changes, but the signature omitted the per-scope visibility (hiddenMetrics/todayHiddenMetrics) and chart-detail (resolution/todayResolution) prefs. So toggling a tile off/on or changing 'Chart detail' in Settings (VitalsSettingsView) persisted to UserDefaults but never changed the signature — refreshIfNeeded() no-op'd on tab return, and the grid/charts kept the old layout until an unrelated event (a ring sync or profile edit) happened to bump the signature. Fold the scoped prefs into each store's signature. Returning to the tab already calls refreshIfNeeded (isActive -> updateProfile), so with the prefs in the signature that return now detects the change and rebuilds. Scoped per store so a Today change doesn't needlessly rebuild Vitals.
saksham2001
approved these changes
Jul 12, 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.
Bug
Today/Vitals didn't reflect a change made in Settings → Visible tiles / Chart detail (
VitalsSettingsView) until an unrelated event later forced a rebuild.TodayStore/VitalsStorerebuild only when a cheapcurrentSignature()changes (refreshIfNeeded()guardssig != signature). But the signature was built from measurements, activity, sleep, device, calibration, andprofile.updatedAt— it omitted the per-scope visibility (hiddenMetrics/todayHiddenMetrics) and chart-detail (resolution/todayResolution) prefs. AndMetricPrefsStore.setHidden/setResolutiononly persist to UserDefaults (noPulseDataChangebump).Failure
Settings → toggle a tile off → return to Today/Vitals → the tab-activation path calls
refreshIfNeeded(), but the recomputed signature is identical (prefs aren't in it) →guardreturns → no rebuild. The tile stays until an unrelated ring sync / profile edit changes the signature and the deferred rebuild finally reads the new prefs. (The read path itself is correct —computeVisible/metricRangedo read the prefs; the defect is that a pref change never triggers a rebuild.)Fix
Fold the scoped prefs into each store's signature:
todayHiddenMetrics(sorted) +todayResolutionhiddenMetrics(sorted) +resolutionReturning to the tab already calls
refreshIfNeeded(isActive → updateProfile), so with the prefs in the signature that same return now detects the change and rebuilds. No new observation plumbing; scoped so a Today change doesn't rebuild Vitals. (Note: bumpingPulseDataChangein the setters alone would NOT fix it —refreshIfNeededis signature-gated, so the signature must change regardless.)Medium severity — user-visible "my setting didn't apply" papercut on a shipping feature; no crash, data intact. Builds clean.