Exclude incomplete current day from sleep bank before wake time#25
Draft
gsbernstein wants to merge 1 commit into
Draft
Exclude incomplete current day from sleep bank before wake time#25gsbernstein wants to merge 1 commit into
gsbernstein wants to merge 1 commit into
Conversation
When the calendar day has no sleep data yet and it is still before the user's wake time, anchor sleep bank and insight lookback windows to end of yesterday. This prevents the window from shifting at midnight and incorrectly extending the ahead/behind day count. Co-authored-by: Greg <gsbernstein@users.noreply.github.com>
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.
Problem
Right after midnight, the sleep bank lookback window shifts to include the new calendar day. If that day has no sleep data yet and it's still before the user's wake time, the window drops an older day and can incorrectly extend insight messaging — e.g. "ahead over the last 5 days" instead of 4.
Fix
Add
SleepWindow.effectiveSleepBankEndDate, which anchors the sleep bank end to end of yesterday when:calculateSleepBankand the sleep insights engine now use this effective end date, keeping lookback windows stable until the user has actually woken up for the day.Notes
This branch is based on the sleep bank insights work (
cursor/sleep-bank-insights-023c) since that's where the "ahead over the last N days" messaging lives. Cannot be built or tested in the Cloud Agent environment (macOS/Xcode only).