Add sleep bank insights with auto-selected windows#14
Draft
gsbernstein wants to merge 9 commits into
Draft
Conversation
38dd056 to
2772211
Compare
81ca0fc to
91f1cbe
Compare
Introduces SleepInsightsEngine that scans 3–14 day lookbacks, picks congratulation and motivator windows, and builds narrative copy with human-readable catch-up fractions. Shows a Sleep Insight card below the sleep balance card and omits duplicate recommendation footer text when the insight covers uncatchable debt. Co-authored-by: Greg <gsbernstein@users.noreply.github.com>
Introduce a shared CardHeader component with a fixed-width, center-aligned icon column and uniform spacing so titles line up across Sleep Balance, Sleep Insight, Tonight's Recommendation, and all other dashboard cards. Co-authored-by: Greg <gsbernstein@users.noreply.github.com>
0612bae to
d9dcb7e
Compare
Local minima excluded longer flattering spans when adding a day improved the balance. Congratulations now uses the longest lookback still ahead. 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.
Summary
Adds a Sleep Insight card that automatically finds flattering and motivating sleep-bank lookback windows, so users don't have to hunt for the range that makes them look best.
Bedtime-limit and min-sleep changes are in a separate PR (#20).
How it works
For each lookback from 3–14 days, the engine computes cumulative sleep balance (same formula as the sleep bank card). Then:
UI
SleepInsightsCardbelowSleepBankCardwhen insight data is availableFiles
SleepInsights.swift,SleepInsightsCard.swift,ProgressFractionFormatter.swift— newContentView.swift,ViewModel.swift,SleepData.swift,BedtimeRecommendationCard.swift— wired up