Skip to content

Let people choose which calendars iMCP can see - #373

Merged
mattt merged 5 commits into
mattt:mainfrom
oliverames:pr/calendar-selection
Nov 29, 2026
Merged

mattt merged 5 commits into
mattt:mainfrom
oliverames:pr/calendar-selection

Conversation

@oliverames

@oliverames oliverames commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Closes #102.
Replaces #341.

What it does and why

Calendar settings now let you pick which calendars clients can see. If you have never saved a selection, every calendar stays visible, so nothing changes for existing users.

What changed

  • A "Show new calendars automatically" toggle (on by default) and a checkbox for each calendar, grouped by account.
  • calendars_list and events_fetch only return the selected calendars.
  • events_create, events_update and events_delete refuse to touch an unselected calendar. That includes falling back to an unselected default calendar and moving an event into one.
  • The selection is saved as JSON in UserDefaults.
  • A README section describes the setting.
  • Reminder lists are not covered here. The same model would work for them as a follow-up.

This is the same change as #341, cut directly from current main as three commits (model, behavior and settings UI, docs) so it merges on its own.

Review fixes

  • CalendarSelectionStore shares every calendar only when the stored key is missing. A value that is not Data, or that decodes with none of the known keys (such as {"calendars":42}), now fails closed and shares no calendars until it is set again. Tests cover the unknown-key, wrong-type, missing-key and corrupt-value cases.
  • events_update and events_delete resolve the occurrence that will actually change and check its calendar, not only the first event they resolved. A detached occurrence in a deselected calendar is refused.

Testing

  • xcodebuild -scheme iMCP -configuration Debug -destination platform=macOS build succeeds.
  • xcodebuild -scheme imcp-serverTests ... test: 324 tests, 1 skipped, 0 failures. That includes the tests in CalendarSelectionTests.
  • swift format lint --strict is clean on the changed files.
  • CI: see the checks below.
  • Real-calendar pass on a signed build with these fixes: with one calendar deselected, calendars_list left it out, events_fetch returned none of its events, and events_create, events_update and events_delete against it were refused (notShared). A create in a still-selected calendar succeeded, and the throwaway event was deleted again. That pass checked reading and the refusals; it did not re-check the Settings checkbox UI itself.

Not verified

  • The Settings checkbox UI was exercised by hand when the selection was made, but the pass drove the store through the app rather than clicking each checkbox.

@mattt

mattt commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Following up from #364: a stored selection that fails to decode falls back to sharing every calendar. Please decode with decodeIfPresent and log a failure. The tests cover the selection model but not the checks in Calendar.swift, so this also needs a pass against real calendars: deselect one, then fetch, create, update, and delete.

@oliverames

oliverames commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

@mattt Updated CalendarSelection to decode with decodeIfPresent, log decode errors, and fail closed (sharing no calendars) if stored data is corrupt instead of falling back to sharing everything, with tests for both cases.

@mattt

mattt commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Thanks for the quick turnaround, @oliverames. Three things left before I merge:

  • CalendarSelectionStore still shares every calendar when the stored value isn't Data, or when it decodes with no known keys, like {"calendars":42}. Only a missing key should get the first-run default.
  • Update and delete call require on the first event they resolve, but occurrence(ofEventWithIdentifier:startingAt:) then searches every calendar. Could you check the calendar of the occurrence that actually gets changed?
  • I'd still like the pass against real calendars: deselect one, then fetch, create, update, and delete.

oliverames pushed a commit to oliverames/iMCP that referenced this pull request Nov 20, 2026
…s calendar

Mattt's mattt#373 review:

- CalendarSelectionStore shares every calendar when the stored value is
  not Data, or when it decodes with none of the known keys ({"calendars":42}).
  Only a missing key gets the first-run default now; a present but
  unusable value shares no calendars.
- Update and delete resolved the occurrence through a predicate over every
  calendar, then required only the first event's calendar. They now check
  the calendar of the occurrence that is actually changed.

Tests cover the unknown-key, wrong-type, missing-key and corrupt-value
cases.
oliverames pushed a commit to oliverames/iMCP that referenced this pull request Nov 20, 2026
…s calendar

Mattt's mattt#373 review:

- CalendarSelectionStore shares every calendar when the stored value is
  not Data, or when it decodes with none of the known keys ({"calendars":42}).
  Only a missing key gets the first-run default now; a present but
  unusable value shares no calendars.
- Update and delete resolved the occurrence through a predicate over every
  calendar, then required only the first event's calendar. They now check
  the calendar of the occurrence that is actually changed.

Tests cover the unknown-key, wrong-type, missing-key and corrupt-value
cases.
oliverames pushed a commit to oliverames/iMCP that referenced this pull request Nov 20, 2026
@oliverames

oliverames commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks @mattt. Both findings are fixed.

The store only shares every calendar when the key is missing now. If the value isn't Data, or it decodes without any of the known keys like {"calendars":42}, it fails closed and shares nothing until it's set again. I added tests for the unknown-key, wrong-type, missing-key and corrupt cases.

Update and delete check the calendar of the occurrence that actually changes, so a detached occurrence in a deselected calendar gets refused.

I ran the real-calendar pass on a signed build with these fixes too. With one calendar deselected, calendars_list left it out, events_fetch returned none of its events, and create, update and delete against it all came back notShared. A create in a calendar I left selected worked, and I deleted the throwaway event again.

imcp-serverTests is at 191 tests with 1 skipped and no failures, and swift format lint --strict is clean.

@oliverames oliverames mentioned this pull request Nov 21, 2026
15 tasks
Oliver Ames added 5 commits November 25, 2026 07:37
…s calendar

Mattt's mattt#373 review:

- CalendarSelectionStore shares every calendar when the stored value is
  not Data, or when it decodes with none of the known keys ({"calendars":42}).
  Only a missing key gets the first-run default now; a present but
  unusable value shares no calendars.
- Update and delete resolved the occurrence through a predicate over every
  calendar, then required only the first event's calendar. They now check
  the calendar of the occurrence that is actually changed.

Tests cover the unknown-key, wrong-type, missing-key and corrupt-value
cases.
@oliverames
oliverames force-pushed the pr/calendar-selection branch from bdc2506 to 7affa97 Compare November 25, 2026 13:09
@oliverames

Copy link
Copy Markdown
Contributor Author

@mattt Rebased on main now that #384 is in. The code you reviewed hasn't changed.

oliverames pushed a commit to oliverames/iMCP that referenced this pull request Nov 25, 2026
@mattt
mattt merged commit 155c4c2 into mattt:main Nov 29, 2026
2 checks passed
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.

Calendars: Ability to select which calendars to expose to tools

2 participants