Skip to content

Add sleep bank insights with auto-selected windows#14

Draft
gsbernstein wants to merge 9 commits into
masterfrom
cursor/sleep-bank-insights-023c
Draft

Add sleep bank insights with auto-selected windows#14
gsbernstein wants to merge 9 commits into
masterfrom
cursor/sleep-bank-insights-023c

Conversation

@gsbernstein

@gsbernstein gsbernstein commented Jun 27, 2026

Copy link
Copy Markdown
Owner

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:

  1. Congratulations — pick the longest duration with a non-negative balance.
  2. Motivator — prefers the worst catchable behind lookback; falls back to the shortest behind window when debt is too large for one night.
  3. Narrative — combined, ahead-only, or behind-only copy. Uncatchable debt uses human-readable fractions: "you can reasonably add 1 hour 15 minutes, getting you about 1/5 of the way there."

UI

  • New SleepInsightsCard below SleepBankCard when insight data is available
  • Tonight's Recommendation omits the duplicate uncatchable-debt footer (insight card covers it)

Files

  • SleepInsights.swift, SleepInsightsCard.swift, ProgressFractionFormatter.swift — new
  • ContentView.swift, ViewModel.swift, SleepData.swift, BedtimeRecommendationCard.swift — wired up
Open in Web Open in Cursor 

@cursor cursor Bot force-pushed the cursor/sleep-bank-insights-023c branch from 38dd056 to 2772211 Compare June 30, 2026 20:51
@gsbernstein gsbernstein force-pushed the cursor/sleep-bank-insights-023c branch 3 times, most recently from 81ca0fc to 91f1cbe Compare July 5, 2026 21:22
cursoragent and others added 3 commits July 5, 2026 14:24
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>
@gsbernstein gsbernstein force-pushed the cursor/sleep-bank-insights-023c branch from 0612bae to d9dcb7e Compare July 5, 2026 21:24
@gsbernstein gsbernstein changed the title Add sleep bank insights with auto-selected flattering windows Add sleep bank insights with auto-selected windows Jul 6, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants