Repository navigation
Add configurable macOS glucose notifications - #1
Merged
Merged
Conversation
Add a Notifications submenu that lets the user opt in to macOS alerts for low, high and very high glucose, rapid rise/fall (fast trend arrows) and no new data for a chosen number of minutes. - Thresholds: defaults (70/180/250 mg/dL) or custom values entered in the account's unit; custom values affect notifications only, not the menu bar colors. - Repeat: once per excursion or every 10/15/30/60 minutes while out of range, with a 5 mg/dL hysteresis band so readings hovering on a threshold don't re-alert. - Rapid change fires once per episode with a 15-minute cooldown; the no-data alert ignores time the Mac spent asleep. - Sound toggle and a test notification item. Alert rules and prefs (~/.glucobar/notifications.json) live in macos_frontend/notifications.py and are unit-tested. Delivery uses UNUserNotificationCenter via the new pyobjc-framework-UserNotifications dependency, falling back to logging when not running from Gluco.app. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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
Adds opt-in macOS notifications for glucose events, configured from a new Notifications ▸ submenu:
Notifications are off by default. Turning them on requests macOS permission; if the user denies it, the toggle reverts and a dialog points to System Settings.
Why
Gluco only showed glucose passively in the menu bar. Users asked to be alerted when glucose crosses thresholds they care about.
How
macos_frontend/notifications.py: alert rules (AlertEngine), prefs persisted to~/.glucobar/notifications.json, unit conversion and threshold parsing/validation. Pure Python, no AppKit.macos_frontend/notifier.py: delivery viaUNUserNotificationCenter. Each category (range / rapid / signal) uses a fixed request identifier, so a reminder replaces the previous banner instead of stacking.macos_frontend/notifications_menu.pyandmacos_frontend/thresholds_dialog.py: the submenu and the custom-threshold dialog.app.py: runs the alert check after each 30s poll.CurrentReadingnow carriestrend.pyobjc-framework-UserNotifications, added to the py2app package list.Reviewer notes
status == "ok". While data is stale the no-data rule takes over, and the range state is kept so recovery doesn't re-alert.time.monotonic) past the limit, so waking the Mac doesn't fire it before the daemon has fetched. It uses a last-known sensor timestamp that survives a daemon restart (e.g. fromOfflineRestartPolicy) that comes back with no reading.com.glucobar.frontend. From plainpython,UNUserNotificationCenteraborts the process, so alerts are only logged there.Testing
pytest tests/: 132 passed, including the newtests/test_notifications.py(zones and repeats, escalation, reminders, rapid-change cooldown, no-data alert after sleep, unit parsing, prefs sanitizing).ruff check .: clean.scripts/build_portable_app.shbuilds, andUserNotificationsis present in the bundle.🤖 Generated with Claude Code