Skip to content

Smart alarm: phone backup follows the alarm, not the wrist-alerts master (#34) - #73

Merged
ryanbr merged 1 commit into
mainfrom
fix-alarm-backup-decouple
Jul 8, 2026
Merged

ryanbr merged 1 commit into
mainfrom
fix-alarm-backup-decouple

Conversation

@ryanbr

@ryanbr ryanbr commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Adjacent to #34 (alarm not buzzing). Not a fix for that user's corrupted strap — the strap's alarm register is frozen firmware-side and NOOP can't force it over BLE. This closes a general robustness gap it exposed: when the strap can't arm, an affected user should at least get the phone backup — but many weren't.

The gap

scheduleSmartAlarmBackupNotification is called from exactly one place — applySmartAlarm(), which already only runs when behavior.smartAlarmEnabled. Yet the backup was gated a second time on notif.masterEnabled (the wrist-alerts master — the switch for HR/strain alerts, inactivity, illness). So a user who set a smart alarm but never turned on wrist alerts got no backup scheduled at all ("backup notification NOT scheduled (wrist-alerts master is off)"). The backup was riding the wrong switch.

Change (iOS-only, one function, no BLE)

  1. Gate the backup on the alarm being enabled (its sole caller enforces that) + notification permission — drop the notif.masterEnabled guard.
  2. When permission is undetermined, request it here (the user just enabled the alarm; nothing else prompted, since wrist alerts — which used to — may be off) and schedule on grant, so the first night is covered rather than only after a later re-arm.
  3. Trigger-building factored into a local addRequests() so the already-authorized and just-granted paths schedule identically.

Re-review notes (flagging, not bugs)

  • A user who turned the master off to silence NOOP but left the alarm on will now start getting the daily backup notification. Defensible (they left an alarm set) and documented in-code, but it's a behavior change for that cohort.
  • For an existing alarm user who never granted permission, the one-time prompt appears on the next applySmartAlarm rather than at a tap. iOS dedupes it to once; a tap-triggered prompt would need a "user-initiated" flag (not minimal).

Honesty (unchanged)

Even scheduled, the backup is a plain notification — a sideloaded build has no critical-alert entitlement, so Focus/silent can mute it. The phone Clock alarm remains the real backup (SmartAlarmView already says so). WSL can't build SwiftUI; verified by inspection + the auth-state reasoning above — needs a device to confirm the prompt + fire.

File: Strand/App/AppModel.swift.

…ter (#34)

The smart-alarm phone backup notification was gated on the wrist-alerts master
(notif.masterEnabled) — the same switch that governs HR/strain alerts — even
though its only caller (applySmartAlarm) already runs solely when the alarm is
enabled. So a user who set a smart alarm but never turned on the unrelated wrist
alerts got NO backup scheduled: when the strap can't arm (e.g. a corrupted alarm
register, #34), they were left with nothing.

- Gate the backup on the alarm being enabled + notification permission, not the
  wrist-alerts master.
- When permission is undetermined (nothing else prompted, since wrist alerts —
  which used to — may be off), request it here and schedule on grant so the first
  night is covered, not only after a later re-arm.

Not a fix for #34's corrupted strap (that's firmware-side) — a general robustness
fix so an unarmable strap still leaves a phone backup. Honest limitation unchanged:
a sideloaded build has no critical-alert entitlement, so Focus/silent can still
mute it; the phone Clock alarm remains the real backup (UI already says so).
@ryanbr
ryanbr merged commit 01bf451 into main Jul 8, 2026
@ryanbr
ryanbr deleted the fix-alarm-backup-decouple branch July 14, 2026 10:49
DX23876 pushed a commit to DX23876/noop that referenced this pull request Jul 22, 2026
Smart alarm: phone backup follows the alarm, not the wrist-alerts master (#34)
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.

1 participant