notifications: add sleep-aware Quiet Time - #1833
Open
TheCodedKid wants to merge 5 commits into
Open
Conversation
Emit an internal activity event whenever confirmed sleep state changes so services can react without polling or coupling to activity internals. Refs coredevices#1804 Co-Authored-By: GPT-5.6 Sol <noreply@openai.com> Signed-off-by: Samuel Raumin <samuel.raumin@gmail.com>
Treat confirmed light and restful sleep as an opt-in Quiet Time source. Persist and sync the setting, consume activity transitions, and keep a manual override in effect until the current sleep episode ends. Refs coredevices#1804 Co-Authored-By: GPT-5.6 Sol <noreply@openai.com> Signed-off-by: Samuel Raumin <samuel.raumin@gmail.com>
Expose Sleep Aware alongside the existing automatic Quiet Time modes. When Health Tracking is disabled, explain the requirement instead of storing a setting that cannot take effect. Refs coredevices#1804 Co-Authored-By: GPT-5.6 Sol <noreply@openai.com> Signed-off-by: Samuel Raumin <samuel.raumin@gmail.com>
Add a persisted temporary Quiet Time source that starts immediately and ends only after confirmed sleep followed by wake. Expose it in settings, retain it through tracking interruptions, and preserve unrelated Quiet Time sources when waking clears it. Refs coredevices#1804 Co-Authored-By: GPT-5.6 Sol <noreply@openai.com> Signed-off-by: Samuel Raumin <samuel.raumin@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR adds new Quiet Time (Do Not Disturb) activation modes that integrate with Activity sleep detection, allowing Quiet Time to be enabled automatically during sleep (“Sleep Aware”) or enabled immediately until sleep is observed and the user wakes (“Until Wake”). It extends the firmware’s DND service, preference persistence/sync, event propagation, settings UI, and unit tests to support these modes while keeping other DND sources (manual/scheduled/calendar-aware) independent.
Changes:
- Add Sleep Aware DND and Until Wake DND modes to the DND service, including persistence of state and activity-event handling.
- Wire sleep state changes into the system event loop and emit a new activity event on sleep state transitions.
- Expose both modes in Quiet Time settings UI and expand unit tests to cover the new behaviors.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/fw/services/test_do_not_disturb.c | Adds unit tests and fakes for sleep-aware and until-wake DND behavior and preference persistence. |
| tests/fw/services/activity/test_activity.c | Extends health/activity tests to assert sleep-state-change activity events are emitted. |
| src/fw/shell/normal/shell_event_loop.c | Dispatches activity events to the DND service so it can react to sleep/tracking changes. |
| src/fw/services/notifications/do_not_disturb.c | Implements sleep-aware and until-wake logic, activity event handling, and new override/persistence behavior. |
| src/fw/services/notifications/do_not_disturb_toggle.c | Ensures the manual DND action toggle disables Until Wake when ending Quiet Time. |
| src/fw/services/notifications/alerts_preferences.c | Persists new DND preferences (sleep-enabled and until-wake state) and reloads sleep-enabled on settings sync. |
| src/fw/services/blob_db/settings_blob_db.c | Adds dndSleepEnabled to the list of syncable notification preferences. |
| src/fw/services/activity/activity_sessions.c | Emits a new activity event when sleep state changes. |
| src/fw/kernel/events.h | Adds PebbleActivityEvent_SleepStateChanged and a sleep_state field to PebbleActivityEvent. |
| src/fw/apps/system/settings/quiet_time.c | Adds UI entries/toggles for Sleep Aware and Until Wake, including health-tracking gating. |
| include/pbl/services/notifications/do_not_disturb.h | Exposes new DND APIs and activity event handler declaration. |
| include/pbl/services/notifications/alerts_preferences_private.h | Adds private preference APIs and DndUntilWakeState enum for Until Wake persistence. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@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.
What
Addresses request feature found here: #1804
How
Sleep Aware is persisted and synchronized with notification preferences. Manually ending it during sleep overrides it only for the current sleep timeframe.
Until Wake stores whether sleep has been observed, survives restarts and temporary tracking interruptions, and does not clear unrelated Quiet Time sources when waking.
Testing
nix develop -c ./pbl test -M '.*services/activity/test_activity[.]c' --show_output --no_images(24 tests pass)nix develop -c ./pbl test -M '.*services/test_do_not_disturb[.]c' --show_output --no_images(17 tests pass)gitlintacross all four commitsAI usage
Developed with assistance from GPT-5.6 Sol and manually reviewed.
Sorry about bulk at the end, alot of test cases