Skip to content

notifications: add sleep-aware Quiet Time - #1833

Open
TheCodedKid wants to merge 5 commits into
coredevices:mainfrom
TheCodedKid:issue1804
Open

notifications: add sleep-aware Quiet Time#1833
TheCodedKid wants to merge 5 commits into
coredevices:mainfrom
TheCodedKid:issue1804

Conversation

@TheCodedKid

Copy link
Copy Markdown

What

Addresses request feature found here: #1804

How

  • add opt-in Sleep Aware Quiet Time during light and restful sleep
  • add an Until Wake mode that starts immediately and ends after sleep followed by waking
  • preserve manual, scheduled, calendar-aware, and sleep-aware activation as independent sources
  • expose both modes in Quiet Time settings and explain when Health Tracking is required

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)
  • QEMU Gabbro firmware build
  • visually verified Sleep Aware, Until Wake, and the Health Tracking requirement dialog
  • gitlint across all four commits

AI usage

Developed with assistance from GPT-5.6 Sol and manually reviewed.

Sorry about bulk at the end, alot of test cases

TheCodedKid and others added 4 commits August 3, 2026 18:58
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>
Copilot AI review requested due to automatic review settings August 4, 2026 02:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/fw/services/notifications/do_not_disturb.c
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@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