feat(sleep): manual entry + HR-led fallback; fix(wear) + v25 features - #32
Merged
Conversation
Sleep rescue (Approaches 1 & 2) for nights auto-detection misses: - sleep_override table (db v19->v20): durable manual/confirmed windows, stored separately from derived output so they survive finalization AND algo bumps. - thread override + HR-led fallback + sleep_source through calendarDays -> prepareDerivationPayload -> prepareSleepSessionCandidate -> engine. - finalization override: force re-derive an overridden day even when locked; skip the auto cache for it; no-raw clobber guard keeps a good manual result once raw is pruned (>14d). - app_state setSleepOverride / confirmSleep / clearSleepOverride. - Sleep screen: manual-entry card (no-sleep night), fallback confirm banner, manual badge (edit / use auto), and an edit affordance on auto nights. Wear fix: - worn-time / coverage / on-off segments were defined as hr>0, but PPG only locks on a still wrist with good contact (~sleep), so a 24h-worn day showed ~7-8h. Wear is now RECORD presence with gap detection. Fixed in the worn_min scalar, _wearBlock, and the repo fallback. kAlgoVersion 26 -> 28 so affected days restage.
abdulsaheel
force-pushed
the
feat/sleep-rescue-and-wear-fix
branch
from
June 30, 2026 18:15
267ac3a to
14829be
Compare
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.
Lands the sleep-detection rescue + wear-time fix. Also carries the two v25 commits (irregular-rhythm screen, HRR, BRV, auto-workout, coach read-only SQL) that this work was built on and that weren't yet on main.
Sleep rescue (Approaches 1 & 2)
For nights auto-detection misses (restless sleeper, loose band, gaps):
sleep_overridetable (db v20), durable across finalization + algo bumps. User-given window is staged via analytics'forcedWindowpath. Force re-derives even a locked day; no-raw clobber guard.sleep_source(auto / auto_fallback / manual / confirmed) threaded to the UI: manual-entry card, confirm banner, edit affordance.Wear fix
Worn-time/coverage was defined as
hr>0— but PPG only locks on a still wrist with good contact (~sleep), so a 24 h-worn day showed ~7-8 h. Now record presence (gap-detected) in theworn_minscalar,_wearBlock, and the repo fallback.kAlgoVersion26 → 28.Tests
flutter test --concurrency=1→ 102 passing;flutter analyzeclean (only pre-existing infos). Pairs with analytics PR #14.🤖 Generated with Claude Code