Skip to content

Add bedtime Live Activity - #37

Draft
gsbernstein wants to merge 7 commits into
masterfrom
cursor/live-bedtime-activity-43cf
Draft

Add bedtime Live Activity#37
gsbernstein wants to merge 7 commits into
masterfrom
cursor/live-bedtime-activity-43cf

Conversation

@gsbernstein

@gsbernstein gsbernstein commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • add an ActivityKit manager with start, update, restore, and end controls
  • add a WidgetKit Live Activity extension for Lock Screen and Dynamic Island
  • anchor stored time-of-day recommendations to the next real bedtime and wake time
  • render remaining time with system format styles so the card keeps counting while the app is suspended
  • document the new Live Activity capability

Live Activity presentation

The countdown uses SystemFormatStyle.DateReference, which phrases the remaining time in natural language: Bedtime in 8 hours, Bedtime in 20 minutes, Bedtime now. It supplies its own "in …", so the heading holds only the subject. allowedFields is limited to hours and minutes so the style never reaches for "tomorrow", and thresholdField is .hour so only a gap wider than a day would fall back to an absolute date, which cannot happen for the next bedtime. The relative form always shows a single rounded unit, so this trades the minute precision of DateOffset for a calmer line.

Only system-rendered text keeps updating once the app is suspended, so the countdown cannot use TimeFormatter. The sleep-goal target beside it is app-formatted and does follow the decimal-durations setting, which is why DurationDisplayStyle travels in the activity's content state and TimeFormatter is shared by both targets.

Legibility: the card no longer tints its own background or draws indigo text over that tint. It uses the system Live Activity background with primary and secondary label colors, leaving indigo for the icon, progress bar, and keyline.

The card covers two phases. staleDate is set to bedtime, so the system re-renders into the sleeping phase at bedtime without the app running: the heading becomes Wake in … and the progress bar switches from wind-down progress to progress through the night. The bar never represented sleep data — it is purely clock progress, and its numeric label (previously a stray 0:00 before bedtime) is now hidden.

CI status

The build compiles with no errors and no new warnings. Archive export still fails for every distribution method, which is automatic signing being unable to provision the new com.burnsides.bedtime.liveactivity identifier. Apple documents the workaround in the Xcode Cloud release notes: archive and export once locally from Xcode, or register the identifier manually in Certificates, Identifiers & Profiles. Two earlier repository-side defects were fixed along the way: the extension target deviated from Apple's generated widget template (hand-written Info.plist, mismatched deployment target, CodeSignOnCopy on the embedded .appex), and the shared attributes type carried a main-actor isolated ActivityAttributes conformance that is an error in the Swift 6 language mode.

Testing

  • verified on device from a local build: the activity starts from the recommendation card and renders on the Lock Screen
  • Xcode Cloud confirms each revision compiles, including the format-style and shared-source changes
  • project file, embed phase, and shared source membership validated structurally
Open in Web Open in Cursor 

cursoragent and others added 7 commits August 7, 2026 14:06
Co-authored-by: Greg <gsbernstein@users.noreply.github.com>
Co-authored-by: Greg <gsbernstein@users.noreply.github.com>
Co-authored-by: Greg <gsbernstein@users.noreply.github.com>
Co-authored-by: Greg <gsbernstein@users.noreply.github.com>
Co-authored-by: Greg <gsbernstein@users.noreply.github.com>
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