{{ message }}
Repository navigation
feat(sleep): Bedtime tracking works without the quiet-hours schedule (#126) - #128
Merged
Merged
Conversation
…126) "Track Bedtime / DND mode" was read only while "Sleep quiet hours" was on, so a night without Bedtime fell back to the clock schedule and lost every ring minute past its end, permanently (trimmed minutes are never imported). The two are now independent switches: - Bedtime only: trim to the Bedtime/DND windows a record overlaps; a record that overlaps none is kept whole. - Schedule only, and both: unchanged. - Neither: no trimming. QuietHoursPrefs.resolveKeptMinutes is the pure resolution the import gate calls; SleepGapBridge.forWindows follows the same source order, so Bedtime alone also bridges gaps inside its window. Upgrade: Bedtime=on with the schedule off was reachable (the row hid but kept its value) and meant no trimming. A one-time migration clears it, so nobody starts trimming on upgrade.
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.

Fixes #126.
"Track Bedtime / DND mode" only worked as part of "Sleep quiet hours". A night without Bedtime fell back to the clock schedule and cut the night at its end, and trimmed minutes are never imported. The two are now independent.
"Bedtime on" means the toggle is on and Notification access is granted, as before.
Overlap, not "the day has a window". The night-window lookup spans 48 h, so a DND meeting the next afternoon would count as the night having a Bedtime window and drop the whole night. A record is trimmed only by windows it actually overlaps.
Changes
QuietHoursPrefs.resolveKeptMinutes: pure resolution of the four cases.nightWindows/effectiveEndmoved here fromSleepGapBridgeso import and bridging share them.SleepGapBridge: bridges when either source is on; uses the clock only when the schedule is on.EventPersistenceSubscriber: always resolves throughkeptMinutesForRecord, which keeps the whole record when nothing is on.Migration
Bedtime on with the schedule off was reachable before (turn both on, then the schedule off) and meant no trimming. Under the new rules it would start trimming on the next sync, so a one-time migration (
independentBedtime.v1) clears the Bedtime flag in that state. Every other state is unchanged.Tests
./gradlew --no-daemon testDebugUnitTest: 1537 pass. NewQuietHoursPrefsTestcases use the #126 night across all four combinations, the next-afternoon DND case, and the migration table;SleepGapsTestchecks the bridge and the import pick the same source.Not checked on a device; the settings layout is checked only by compilation.
🤖 Generated with Claude Code