Skip to content

fix(backend): cancel the task reminder when a conversation task is deleted - #15175

Merged
kodjima33 merged 1 commit into
BasedHardware:mainfrom
kduailabs:fix/conversation-task-delete-cancels-reminder
Sep 21, 2026
Merged

kodjima33 merged 1 commit into
BasedHardware:mainfrom
kduailabs:fix/conversation-task-delete-cancels-reminder

Conversation

@kduailabs

@kduailabs kduailabs commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

DELETE /v1/conversations/{conversation_id}/action-items (delete_action_item in backend/routers/conversations.py) removes one task from the conversation's structured list and mirrors the deletion into the standalone action_items collection, but never tells the client, so the task's scheduled reminder stays armed on the phone.

Impact

The mobile client schedules a local notification for a task with a due date and cancels it only when the backend sends the action_item_delete data message (app/lib/services/notifications/action_item_notification_handler.dart → handleDeletionMessage). Both swipe-delete call sites (app/lib/providers/conversation_provider.dart:1579, app/lib/pages/conversation_detail/conversation_detail_provider.dart:311) just call deleteConversationActionItem and drop the result, so nothing cancels locally either. Deleting a dated task from the conversation view therefore leaves its reminder to fire later for a task that no longer exists.

This is the same class already fixed on the sibling paths: #15041 (conversation cascade delete), #15043 (developer API delete), #14983/#14984 (checking a task off inside a conversation, the PATCH handler directly above this one), #15028/#15029 (MCP task writes).

Fix

Mirror the cancel into the same loop that mirrors the deletion: for each stored row whose description matches, after deleting it, call sync_action_item_reminder(..., completed=True, due_at=None) when the row was an open task with a due date (the exact gating #15041 uses on the cascade path). 12 lines, local import like the two other reminder call sites in this router.

Tests

Added to backend/tests/unit/test_conversation_events_bounds.py, reusing the module's fresh-import router fixture that #14984's reminder tests already use:

  • deleting an open dated task sends the cancel for the deleted row (delete_action_item + sync_action_item_reminder(user_id, action_item_id, description='', completed=True, due_at=None))
  • a completed task and a task with another description send no cancel

Verification

cd backend
python -m pytest tests/unit/test_conversation_events_bounds.py -q   # 14 passed
python -m pytest tests/unit/test_conversation_action_items_count.py tests/unit/test_action_items_router_pagination.py tests/unit/test_action_item_reminder_cancel_on_complete.py -q   # 14 passed
python -m black --check routers/conversations.py tests/unit/test_conversation_events_bounds.py   # clean

Against origin/main conversations.py the new test fails (sync_action_item_reminder called 0 times), confirming the reminder was never cancelled.

Note: the other handler registered for this method+path (action_items.py) is the known shadowed duplicate documented in .github/scripts/check_duplicate_routes.py KNOWN_DUPLICATES; the mounted handler is the one changed here.

Failure-Class: none

Line-Count-Exception: backend/routers/conversations.py | 2281 -> 2293 | mirror the reminder cancel for the deleted row in the swipe-delete handler; the loop that mirrors the deletion is the only correct place for it

Review in cubic

@kduailabs

Copy link
Copy Markdown
Contributor Author

Bounty proposal for this fix: #15176 ($25 proposed).

@aryanorastar aryanorastar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on 60c670c61603.

DELETE /v1/conversations/{id}/action-items still mirrors the standalone row and never sends the deletion data message, so a swipe-deleted dated task keeps its client-scheduled reminder. Same gating as the cascade path (#15041): open + due_at. Tests cover the cancel and the no-reminder cases.

Units, hygiene, and preflight are green on this SHA. I am not merging.

@Git-on-my-level

Copy link
Copy Markdown
Member

Verified end to end — the analysis in the description matches the code, and this completes the reminder-reconciliation coverage on the last delete path.

  • backend/routers/conversations.py — the new sync_action_item_reminder(user_id=uid, action_item_id=ai['id'], description='', completed=True, due_at=None) sits in the mirror-deletion loop right after delete_action_item, gated on due_at and not completed exactly like the conversation-cascade path (fix(backend): cancel task reminders when a conversation and its tasks are deleted #15041). With completed=True/due_at=None the helper routes to send_action_item_deletion_message, i.e. the action_item_delete FCM data message the app's handleDeletionMessage -> cancelNotification path keys off — precisely the cancel this handler was missing. Local import matches the two sibling call sites in this router (set_action_item_status, cascade delete).
  • Error containment: FCM batch failures are already swallowed inside _send_to_user (logged, returns 0), so the send cannot break the mirror loop except via a token-store raise — the same residual exposure the already-merged sibling handlers accept.
  • backend/tests/unit/test_conversation_events_bounds.py — both new tests reuse the existing fresh-import router fixture and _FakeActionItem seam, assert the cancel for an open dated task and no send for a completed row / non-matching description. DeleteActionItemRequest(description, completed) matches the model.

One non-blocking process note: the PR body declares Failure-Class: none, but by its own account this is the latest in a series of fixes for the same 'mutation path forgets to reconcile the client-scheduled reminder' class (#14983/#14984, #15041, #15043, #15028/#15029). Per the AGENTS.md repair-the-boundary rule that pattern is due a registered failure class / reusable guard so the next missed call site fails a check instead of a user's phone — good follow-up material, not a blocker for this fix.

🤖 Automated review on behalf of the maintainers.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added positive-signal Automation verified a genuine fix/quality contribution backend Backend Task (python) labels Sep 20, 2026

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5/5 confidence: real bug (deleting a dated conversation action-item never cancels its client-scheduled reminder), same class as already-merged sibling fixes (#15041/#15043/#14983/#15028), scoped 12-line change with new regression test that fails against origin/main, all CI green.

@kodjima33
kodjima33 merged commit e77ae36 into BasedHardware:main Sep 21, 2026
49 of 52 checks passed
jitendravjh added a commit to jitendravjh/omi that referenced this pull request Sep 21, 2026
…ation

Main now cancels the reminder on this path (BasedHardware#15175) but the action item vector
stays behind, so task search keeps ranking a deleted task and returns fewer
results than asked for. The standalone delete route already drops it; the
handler in action_items.py that did it for this path is the shadowed duplicate
in KNOWN_DUPLICATES.

Verified: the new test plus the reminder and vector test files pass with
test.sh; the vector assertions fail on main.

Failure-Class: none
kodjima33 pushed a commit that referenced this pull request Sep 22, 2026
…ation (#15317)

Main now cancels the reminder on this path (#15175) but the action item vector
stays behind, so task search keeps ranking a deleted task and returns fewer
results than asked for. The standalone delete route already drops it; the
handler in action_items.py that did it for this path is the shadowed duplicate
in KNOWN_DUPLICATES.

Verified: the new test plus the reminder and vector test files pass with
test.sh; the vector assertions fail on main.

Failure-Class: none
Wizard815 pushed a commit to Wizard815/omi-local that referenced this pull request Nov 25, 2026
…ation (BasedHardware#15317)

Main now cancels the reminder on this path (BasedHardware#15175) but the action item vector
stays behind, so task search keeps ranking a deleted task and returns fewer
results than asked for. The standalone delete route already drops it; the
handler in action_items.py that did it for this path is the shadowed duplicate
in KNOWN_DUPLICATES.

Verified: the new test plus the reminder and vector test files pass with
test.sh; the vector assertions fail on main.

Failure-Class: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Backend Task (python) positive-signal Automation verified a genuine fix/quality contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants