Skip to content

Deleting a medication also cancels a snoozed dose's alarm - #25

Merged
SusieeTheLinuxUser merged 1 commit into
masterfrom
fix/cancel-snoozed-alarm
Nov 6, 2026
Merged

SusieeTheLinuxUser merged 1 commit into
masterfrom
fix/cancel-snoozed-alarm

Conversation

@SusieeTheLinuxUser

@SusieeTheLinuxUser SusieeTheLinuxUser commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

Found in a read-only bug hunt (Kimi K3 via OpenRouter); I checked it against the code.

Bug
Snooze (AlarmActivity) re-arms the native alarm 10 minutes out under the same dose id, but the dose's scheduled_at stays at its original, now past, time. cancelFutureAlarmsFor (called when a medication is deleted) only looked at pending doses from now on, so it skipped the snoozed one.

Example: dose rings at 09:00, Snooze (re-armed for 09:10), delete the medication at 09:05. At 09:10 the alarm still rings with the deleted medication's name. Tapping Taken is silently dropped (the dose row is gone), and BootReceiver re-arms it if the phone restarts in that window.

Fix
Start the lookup a day back. Cancelling a dose that isn't armed is a no-op, and a day covers any realistic snooze chain without walking all of the history.

Not changed: _reconcileOrphanedDoses has the same blind spot when a time is edited out while its dose is snoozed. Widening that one would delete past pending doses (history), so it needs a different fix; left for now.

Tested

  • flutter analyze: no issues. flutter test: 35 passed.
  • No unit test: the scheduler's database paths aren't covered by tests in this repo (no DB in the test setup). Not reproduced on a device.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Future alarm cancellation now also covers doses scheduled earlier today, including snoozed doses.

Snooze re-arms the native alarm 10 minutes out but leaves the dose's
scheduled time in the past, and the cancel on delete only looked at doses
still in the future. So a dose snoozed just before deleting its medication
still rang for a medication that no longer exists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-06T18:42:55.227396Z
We couldn’t complete this review. Comment @codex review to try again.
b1993d0 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

cancelFutureAlarmsFor now searches pending doses starting one day before the current time. The query still ends at the existing three-day horizon.

Changes: Alarm cancellation

Layer / File(s) Summary
Expand cancellation query window
lib/services/scheduler.dart
cancelFutureAlarmsFor now queries doses from one day before the current time through the existing horizon.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: claude

Merge Risk: Minimal · up to b1993

Deleting a medication now also cancels alarms for doses that were snoozed after their scheduled time. The change is small and no merge-blocking risk is evident. Snoozes beyond one day past the scheduled time remain an unaddressed edge case.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly describes the main change: canceling a snoozed dose's alarm when its medication is deleted.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 0 files. (1 skipped: 1 unsupported.)

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2a64b3e1-3df2-4bae-889e-33cf9c930b5d
Commits

Reviewing files that changed from the base of the PR and between 8230c08 and b1993d0.

Files selected for processing: 1

  • lib/services/scheduler.dart

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

@SusieeTheLinuxUser
SusieeTheLinuxUser merged commit ddd3425 into master Nov 6, 2026
2 checks passed
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