Repository navigation
Conversation
# Conflicts: # README.md # scripts/smoke.ts # src/tools/list-events.test.ts # src/tools/list-events.ts
test: whole-day regression guards from the PR #100 review
dominik1001
left a comment
There was a problem hiding this comment.
Thanks for this. The core fix works: list-events now reports whole-day events as plain dates with the last day included. A few things need to change before it can go in.
Rebase onto main. The branch has a merge conflict with main. main also now has src/tools/whole-day.test.ts (#118), which drives create-event, list-events and update-event through a real MCP client. Four of its tests are marked test.fails for known whole-day bugs. Three of them still fail with this PR applied, and the fourth (passing list-events dates straight back to update-event) now fails with Invalid ISO datetime at start. When a fix makes one of them pass, its .fails marker has to come off.
update-event still moves whole-day events a day earlier (src/tools/update-event.ts, not part of this diff). The local-midnight Date from ts-caldav is corrected only where list-events displays it. In update-event it still goes unchanged through ...existing into client.updateEvent, and ts-caldav writes whole-day dates as toISOString().split("T")[0]. So in Berlin, changing only the summary of an event on DTSTART;VALUE=DATE:20260825 stores it as 20260824, while list-events now shows the right date. The conversion should live in one place that both tools use (or be fixed upstream in ts-caldav), not in a list-events-only wholeDaySpan.
Inline comments cover the rest.
| }, | ||
| returns: | ||
| "A list of events that fall within the given timeframe, each containing `uid`, `summary`, `start`, `end`, and optionally `description` and `location`", | ||
| "A list of events that fall within the given timeframe, each containing `uid`, `summary`, `start`, `end`, and optionally `description` and `location`. A whole-day event carries `wholeDay: true`, and its `start` and `end` are plain calendar dates (`YYYY-MM-DD`); `end` names the last day the event covers, not the exclusive DTEND, so it is the day create-event and update-event take as their own `end`. Those two require a full ISO 8601 datetime, so add a time and an offset before passing such a date back. Every other event gives `start` and `end` as ISO 8601 instants.", |
There was a problem hiding this comment.
This guidance moves events a day earlier. "Add a time and an offset" doesn't work, because ts-caldav takes the whole-day date as the UTC day (toISOString().split("T")[0]). A caller in Berlin who turns 2026-08-25 into 2026-08-25T00:00:00+02:00 gets 2026-08-24T22:00:00Z, so DTSTART becomes 20260824. The guidance needs to say T00:00:00Z (or noon), or better, create-event/update-event should accept the plain date list-events returns. #118's create-event stores the day named in a date with an offset covers this.
| }, | ||
| returns: | ||
| "A list of events that fall within the given timeframe, each containing `uid`, `summary`, `start`, `end`, and optionally `description` and `location`", | ||
| "A list of events that fall within the given timeframe, each containing `uid`, `summary`, `start`, `end`, and optionally `description` and `location`. A whole-day event carries `wholeDay: true`, and its `start` and `end` are plain calendar dates (`YYYY-MM-DD`); `end` names the last day the event covers, not the exclusive DTEND, so it is the day create-event and update-event take as their own `end`. Those two require a full ISO 8601 datetime, so add a time and an offset before passing such a date back. Every other event gives `start` and `end` as ISO 8601 instants.", |
There was a problem hiding this comment.
The calling model never sees this text. returns isn't passed to registerTool. Only description and inputSchema reach the MCP client, and returns is read only by scripts/gen-tool-docs.ts for the README. The model gets "start":"2026-08-25","end":"2026-08-29","wholeDay":true with no explanation. It may read end as exclusive (as in iCal) and shorten the event by a day, or pass the bare date to update-event, which rejects it. The explanation of the output format belongs in description. #118's the list-events description the client sees explains whole-day dates checks this.
| lastDay.setDate(lastDay.getDate() - 1); | ||
| const start = localDate(event.start); | ||
| const end = localDate(lastDay); | ||
| return { start, end: end < start ? start : end, wholeDay: true }; |
There was a problem hiding this comment.
This compares strings, which only works for 4-digit years, and localDate doesn't pad getFullYear() (year 999 gives "999-…"). The clamp also quietly turns an event whose DTEND is before its DTSTART into a valid one-day event, which hides the bad data. Padding the year and comparing dates would avoid the first problem. I'd let the second one surface rather than clamp it.
| ), | ||
| ) as Array<{ uid: string; start: string; end: string; wholeDay?: boolean }>; | ||
| const foundWholeDay = wholeDayListed.find((e) => e.uid === wholeDayUid); | ||
| if (!foundWholeDay) |
There was a problem hiding this comment.
If this check or the one below throws, the delete-event call further down never runs, so the test event stays on the real calendar. That adds one more event with every failing run. Wrapping the section in try/finally, as the other smoke blocks on main do, fixes that.
| // looked shifted. The dates must come back as plain dates, with `end` naming | ||
| // the last day. Input stays in UTC on purpose: preserving a non-UTC offset | ||
| // through create-event is a separate fix. | ||
| const wholeDayStart = new Date(Date.now() + 3 * 24 * 60 * 60 * 1000) |
There was a problem hiding this comment.
Nit: this works out the date with millisecond arithmetic right next to the new addDays helper. addDays(new Date().toISOString().slice(0, 10), 3) would keep all the smoke date maths on one path.
| // exactly the condition under test: in UTC the bug cannot appear at all, and | ||
| // the instants below are what a Berlin machine gets back for | ||
| // DTSTART;VALUE=DATE:20260825 and friends. | ||
| beforeAll(() => { |
There was a problem hiding this comment.
main now pins TZ: "Europe/Berlin" for every test in vitest.config.ts, so after the rebase these hooks only repeat that setting. Worse, if the global zone ever changes to test another one, this block quietly switches back to Berlin for these tests only. Please remove beforeAll/afterAll and the comment along with them.
Drives create-event, list-events and update-event through an in-memory MCP client against a fake calendar that reads and writes VALUE=DATE the way ts-caldav 0.4.4 does. The four known bugs are marked test.fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
list-events returned the local-midnight Date ical.js builds from a VALUE=DATE, which serialises to the previous day east of UTC. A whole-day event now reports wholeDay: true with plain YYYY-MM-DD start and end; end is the last covered day (inclusive), the same day create-event and update-event take as their own end. Both write tools now accept that plain date for a whole-day event, so the dates round-trip unchanged. A plain date on a timed event is rejected instead of silently meaning midnight UTC. The format is explained in the list-events description, since returns never reaches the client.
d3f27d9 to
46cc6a7
Compare
|
Thanks, I agree with all points. I rebuilt the branch on current
The format is explained in the Both remaining
|
list-eventsreturns theDatethat ical.js builds from aVALUE=DATE. Thatdate carries no time and no zone, but the
Datesits at local midnight, soserialising it to JSON puts the event on the previous day in every zone east of
UTC:
Anything reading the date out of that string, a calling model included, is off
by one. I chased this as a
create-eventbug for a while, because a holidaythat was stored correctly came back looking like it had been created a day
early.
A whole-day event now reports
wholeDay: truewithstartandendas plaincalendar dates.
DTENDis exclusive, soendnames the day before it: the lastday the event covers, which is the day
create-eventalready takes as its ownend. The write schemas still want a full ISO datetime, and thereturnstextsays so. Timed events are untouched.
Before and after, for a holiday from 25 to 29 August:
The dates are read off the local calendar fields rather than derived from the
difference between the two instants, so a daylight saving change inside the span
cannot add or lose a day.
Tests cover a multi-day span, a single day, a missing
DTEND, a span across theOctober clock change, and a timed event that must keep its instant.
TZispinned to
Europe/Berlininside that block, because in UTC the bug cannot occurat all. The smoke harness now round-trips a three-day whole-day event and checks
both dates; its input stays in UTC so it does not depend on #91.
Related, all independent of each other: #91 is the same class of problem on the
create side, #95 on the update side, this one is the read side. It touches the
same
mapas #94, so if that lands first I will rebase.