Fix Google Calendar event recurrence on task creation #1539
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix: Add DTSTART to recurrence rules during task creation
Problem
When creating a task with recurrence, the recurrence field was set without
DTSTART(e.g.,FREQ=DAILY;INTERVAL=3). This caused Google Calendar sync to fail on initial creation because theconvertToGoogleRecurrence()function requiresDTSTARTto properly convert the recurrence rule.However, when editing that same task, the system would automatically add
DTSTART(e.g.,DTSTART:20260128T093000Z;FREQ=DAILY;INTERVAL=30), which then allowed Google Calendar sync to work correctly.Root Cause
During Task Creation: The recurrence field was set directly from the modal/form without
DTSTART:TaskCreationModal.buildTaskData()passed recurrence directly withoutDTSTARTTaskService.applyTaskCreationDefaults()created simple FREQ rules withoutDTSTARTDuring Task Editing:
TaskService.updateTask()automatically addedDTSTARTto recurrence rules that didn't have one by callingaddDTSTARTToRecurrenceRule()in three scenarios:Google Calendar Sync: The
convertToGoogleRecurrence()function requiresDTSTARTto be present in the recurrence rule. Without it, the conversion returnsnulland Google Calendar events are not created with recurrence.Solution
Added logic in
TaskService.createTask()to automatically addDTSTARTto recurrence rules during task creation, ensuring consistency between creation and editing flows.Changes
File:
src/services/TaskService.tscompleteTaskDataobject to detect recurrence rules withoutDTSTARTaddDTSTARTToRecurrenceRule()to addDTSTARTusing the task's scheduled date (ordateCreatedas fallback)Code Location
Impact
Benefits
✅ Consistent behavior: Tasks with recurrence now have
DTSTARTfrom creation, matching the behavior after editing✅ Google Calendar sync works immediately: The
convertToGoogleRecurrence()function can now properly parse the recurrence rule on first sync✅ No breaking changes: Existing logic in
updateTask()serves as a safety net for any edge cases✅ Backward compatible: Existing tasks without
DTSTARTwill still work correctly (the edit flow adds it)Testing Recommendations
Create a new task with recurrence:
FREQ=DAILY;INTERVAL=3recurrenceDTSTART(e.g.,DTSTART:20260128T093000Z;FREQ=DAILY;INTERVAL=3)Verify existing behavior:
DTSTARTis addedEdge cases:
dateCreated)Related