Repository navigation
Conversation
…edule reminders Centralizes the client reminder-lifecycle decision: cancel the scheduled reminder when a task is completed or has no due date, and (re)schedule only for an open task with a due date. Reuses the action_item_delete message, which the client treats as "cancel the scheduled local notification". (BasedHardware#5085)
…ng on update (BasedHardware#5085) toggle_action_item_completion now cancels the scheduled reminder (and reschedules when un-completing an item with a due date); update_action_item reconciles via the final state instead of unconditionally re-sending the reschedule whenever due_at is present; create no longer arms a reminder for an already-completed item.
Greptile SummaryThis PR fixes a bug where completing an action item never cancelled its client-scheduled reminder, and the general update endpoint actively re-armed the reminder even on already-completed items. The fix introduces a
Confidence Score: 4/5The change is safe to merge — it only adds FCM cancel/reschedule calls and never touches persistence logic, so the worst-case regression is a spurious or missing reminder notification rather than data loss. The core fix is correct and well-reasoned across all five call sites. The
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Action Item create / update / toggle] --> B{completed or due_at changed?}
B -- No --> Z[No FCM reminder traffic]
B -- Yes --> C[sync_action_item_reminder]
C --> D{completed == true OR due_at is None?}
D -- Yes --> E[send_action_item_deletion_message - Client cancels scheduled notification]
D -- No --> F[send_action_item_update_message - Client reschedules notification]
Reviews (1): Last reviewed commit: "test(backend): register action item remi..." | Re-trigger Greptile |
…nion[datetime, str]]
… service Re-fetch the action item after the write so the cancel/reschedule decision uses the authoritative value, matching update_action_item_tool, instead of the pre-update snapshot.
Fixes #5085
Summary
Completing an action item never cancelled its scheduled reminder, so users kept getting reminder notifications for tasks they'd already finished. Worse, the general update endpoint actively re-armed the reminder on a completed item. This cancels the reminder on completion and reschedules it only for open tasks with a due date.
Root cause
Action-item reminders are scheduled client-side from a data FCM message; the client cancels a scheduled reminder when it receives
action_item_deleteand (re)schedules onaction_item_update. On the backend, the cancel message was sent only on the delete paths. None of the completion paths sent it:toggle_action_item_completion(routers/action_items.py) marked the item complete and returned with no cancel.update_action_itemre-sentsend_action_item_update_messagewheneverdue_atwas present, even when the same request setcompleted=true, re-arming the reminder.utils/retrieval/tools/action_item_tools.py,utils/retrieval/tool_services/action_items.py) and the Developer API update (routers/developer.py) had the same gap.Fix
Centralize the decision in one helper,
utils/notifications.sync_action_item_reminder(...):send_action_item_deletion_message(cancel the scheduled reminder).send_action_item_update_message(reschedule).Reusing the deletion message as the cancel signal is intentional and needs no app change: the client handler treats
action_item_deleteas "cancel the scheduled local notification by id", not as a task deletion.The helper is called with the final item state from every create/update/complete path:
toggle_action_item_completion, cancel on complete; reschedule when un-completing an item that still has a future due date.update_action_item, reconcile whencompletedordue_atchanged (replaces the old unconditional re-arm); a cleared due date now cancels.create_action_itemno longer arms a reminder for an item created already-completed.Edge cases
due_atcleared → cancel any stale reminder.completed/due_at(e.g. description, sort order) send no reminder traffic (no regression / no extra FCM).Testing
New
backend/tests/unit/test_action_item_reminder_cancel_on_complete.py(registered intest.sh). It imports the realsync_action_item_reminder(under a stub finder, sinceutils.notificationspulls in firebase/db) and asserts: completed → cancel; open+due → reschedule with the ISO due date; open/no-due → cancel; completed/no-due → cancel. Plus source-inspection tests that every create/update/complete path stays wired to the helper and that the old "re-arm whenever due_at present" block is gone. Verified red→green: the whole suite fails on currentmainand passes with this change.scripts/lint_async_blockers.pyis clean.PR status check
gh prsearch for 5085 is empty (open and all states); searches forsend_action_item_deletion_message/ completion-reminder PRs return nothing;git log -Son the notification helpers shows the scheduling/dedup/batch-delete history but no prior completion-cancel fix merged or reverted. No open PR touches these paths for this bug.