calendar: add EXDATE support for cancelling single occurrences of recurring events

event delete on a recurring event previously deleted the entire .ics file,
killing the whole series. Now requires --date (adds EXDATE) or --all (deletes
series) for recurring events, refusing to act without either flag.
This commit is contained in:
Yanxin Lu
2026-03-26 09:19:02 -07:00
parent d2bc01f16c
commit e1f1c0f334
4 changed files with 147 additions and 16 deletions

View File

@@ -382,7 +382,60 @@ $SKILL_DIR/scripts/calendar.sh event list --search "Delete Me"
- [ ] Other events are untouched
- [ ] `vdirsyncer sync` ran after delete
## 18. Regression: Existing Invite Commands
## 18. Event Delete: Cancel Single Occurrence (EXDATE)
Test that `--date` cancels one occurrence of a recurring event without deleting the series.
```bash
# Create a recurring event (weekly on Saturday, 4 weeks)
NEXT_SAT=$(python3 -c "from datetime import date,timedelta; d=date.today(); d+=timedelta((5-d.weekday())%7 or 7); print(d)")
$SKILL_DIR/scripts/calendar.sh send \
--to "mail@luyx.org" \
--subject "EXDATE Test (Sat)" \
--summary "EXDATE Test (Sat)" \
--start "${NEXT_SAT}T10:00:00" \
--end "${NEXT_SAT}T11:00:00" \
--rrule "FREQ=WEEKLY;COUNT=4;BYDAY=SA"
# Verify it exists
$SKILL_DIR/scripts/calendar.sh event list --search "EXDATE Test"
# Cancel just the first occurrence
$SKILL_DIR/scripts/calendar.sh event delete --match "EXDATE Test" --date "$NEXT_SAT"
# Verify: .ics file still exists (not deleted)
ls ~/.openclaw/workspace/calendars/home/ | grep -i exdate
```
**Verify:**
- [ ] `event delete --match ... --date ...` prints "Cancelled ... (added EXDATE, series continues)"
- [ ] `.ics` file still exists in calendar dir
- [ ] `khal list` no longer shows the cancelled date but shows subsequent Saturdays
## 19. Event Delete: Recurring Without --date or --all (Safety Guard)
```bash
# Try to delete the recurring event without --date or --all — should FAIL
$SKILL_DIR/scripts/calendar.sh event delete --match "EXDATE Test"
```
**Verify:**
- [ ] Script exits with error
- [ ] Error message explains the two options: `--date` or `--all`
## 20. Event Delete: Recurring With --all
```bash
# Delete the entire series
$SKILL_DIR/scripts/calendar.sh event delete --match "EXDATE Test" --all
```
**Verify:**
- [ ] .ics file is removed
- [ ] `event list --search "EXDATE Test"` shows nothing
## 21. Regression: Existing Invite Commands (was #18)
Verify new features didn't break VEVENT flow.
@@ -441,3 +494,4 @@ todo list
| Recurring events on wrong day | DTSTART was not aligned with BYDAY. Delete the event and resend with correct `--start` |
| SMTP rate limit / EOF error | Too many sends too fast. Wait 10+ seconds between sends (Migadu limit) |
| Events disappeared after cleanup | **Never use `rm *.ics`** on calendar dirs. Use `event delete --match` instead |
| Recurring series deleted when cancelling one date | Use `--date YYYY-MM-DD` to add EXDATE, not bare `event delete` (which requires `--all` for recurring) |