Skip to content

Comprehensive workflow reminder management for booking lifecycle events#7

Open
ShashankFC wants to merge 1 commit into
workflow-queue-basefrom
workflow-queue-enhanced
Open

Comprehensive workflow reminder management for booking lifecycle events#7
ShashankFC wants to merge 1 commit into
workflow-queue-basefrom
workflow-queue-enhanced

Conversation

@ShashankFC

@ShashankFC ShashankFC commented Jan 22, 2026

Copy link
Copy Markdown

Test 6nn

Summary by CodeRabbit

  • New Features

    • Enhanced phone number verification flow in workflow settings with improved code entry and verification interface.
  • Bug Fixes

    • Improved reminder cancellation and cleanup during booking cancellations and rescheduling operations.
    • Better tracking and management of cancelled reminders in workflows.

✏️ Tip: You can customize this high-level summary in your review settings.

nn---n*Replicated from [ai-code-review-evaluation/cal.com-coderabbit#6](https://github.com/ai-code-review-evaluation/cal.com-coderabbit/pull/6)*

Note

Medium Risk
Touches booking lifecycle and workflow reminder cancellation logic plus a Prisma migration; incorrect handling could leave reminders sending after cancellations/reschedules or delete the wrong reminder records.

Overview
Booking cancellation/rescheduling now cancels associated workflow reminders instead of directly deleting reminder rows, with updated calls across booking handlers and TRPC booking/workflow routes to pass reminder IDs and handle missing referenceIds.

Introduces a new WorkflowReminder.cancelled flag (with migration) and updates email/SMS reminder managers: email cancellations can either mark reminders as cancelled, immediately cancel SendGrid batches, or delete DB rows when unscheduled; SMS cancellations now cancel in Twilio when possible and always delete the reminder row.

Adds cron-side cleanup in scheduleEmailReminders to actively cancel and delete SendGrid scheduled sends for reminders marked cancelled and due soon, and updates the workflow UI’s SMS number verification section flow/visibility logic.

Written by Cursor Bugbot for commit 2ebfcf4. Configure here.

…re still sent (#7232)

* small UI fix

* fix cancelling scheduled emails

* improve comments

* delete reminders for rescheduled bookings

* add migration file

* cancel rescheduled bookings immediately

* remove immediate delete for request reschedule

---------

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
@ShashankFC

Copy link
Copy Markdown
Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

},
});
return;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Email reminder DB records orphaned during rescheduling

Medium Severity

When immediateDelete is true and referenceId is non-null, deleteScheduledEmailReminder cancels the SendGrid scheduled send but neither deletes the WorkflowReminder DB record nor marks it as cancelled. In handleNewBooking.ts, this is called during rescheduling where the old booking is only status-changed (not deleted), so no cascade delete cleans up these records. This leaves orphaned WorkflowReminder rows in the database. The other callers using immediateDelete (workflow/step deletion in workflows.tsx) are safe because cascade deletes handle cleanup, but the reschedule path has no such cascade.

Additional Locations (1)

Fix in Cursor Fix in Web

await Promise.all(workflowRemindersToDelete);
} catch (error) {
console.log(`Error cancelling scheduled Emails: ${error}`);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Single SendGrid failure blocks all cancelled reminder processing

Medium Severity

The for...of loop cancelling SendGrid scheduled sends shares a single try/catch with the Promise.all for DB deletes. If any one SendGrid cancellation request fails, the entire block exits to catch—reminders already successfully cancelled on SendGrid won't have their DB records deleted, and remaining reminders won't be processed at all. On subsequent cron runs, already-cancelled reminders are retried on SendGrid, likely failing again (not idempotent), creating a persistent blockage.

Fix in Cursor Fix in Web

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.

2 participants