From 3b63d18f63805a3f283be62d801d5e14fc520d2f Mon Sep 17 00:00:00 2001 From: Kyle Pope Date: Sun, 22 Feb 2026 01:55:50 +0800 Subject: [PATCH] Fix first occurrence missing from recurring events The parent template is hidden from the calendar listing, but the recurrence service was only generating children starting from the second occurrence. Now generates a child for the parent's own start date so the first occurrence is always visible. Co-Authored-By: Claude Opus 4.6 --- backend/app/services/recurrence.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/app/services/recurrence.py b/backend/app/services/recurrence.py index cb0406d..0246d25 100644 --- a/backend/app/services/recurrence.py +++ b/backend/app/services/recurrence.py @@ -84,6 +84,11 @@ def generate_occurrences( original_start=occ_start, ) + # Always generate a child for the parent's own start date (the first occurrence). + # The parent template is hidden from list views, so without this the first date + # would have no visible event. + occurrences.append(_make_child(parent_start)) + if rule_type == "every_n_days": interval: int = int(rule.get("interval") or 1) if interval < 1: @@ -95,10 +100,10 @@ def generate_occurrences( elif rule_type == "weekly": weekday: int = int(rule.get("weekday") if rule.get("weekday") is not None else parent_start.weekday()) - # Start from the week after the parent + # Start from the next week after the parent days_ahead = (weekday - parent_start.weekday()) % 7 if days_ahead == 0: - days_ahead = 7 # skip the parent's own week + days_ahead = 7 current = parent_start + timedelta(days=days_ahead) while current < horizon: occurrences.append(_make_child(current))