Skip to content

#1072: a JMAP account's calendars and events are shown - #1124

Draft
nextxch wants to merge 4 commits into
UCSLabs:mainfrom
nextxch:pr/1072-calendars-read
Draft

nextxch wants to merge 4 commits into
UCSLabs:mainfrom
nextxch:pr/1072-calendars-read

Conversation

@nextxch

@nextxch nextxch commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Builds on #1015 (the desktop app reads JMAP accounts) and on #1123 (#1068, a JMAP account's contacts come down), neither of which is on main yet: the branch is main with #1015 merged in, the contacts commit, and the one commit of this pull request on top. It is a draft until those two are on main; then it is brought up to date and only its own commit is left.

Closes #1072.

What changes for the person using MailCraft

A JMAP account's calendars and their events are shown in the desktop app, where the server offers JMAP for Calendars:

  • the calendars the account subscribes to and may read, each with its name and colour, one of them its main calendar (the one the server says is the default, else the first in the server's order);
  • their events from a month back to a year ahead: subject, place, notes, start and end with the time zone, whole-day events, show-as, private, categories, the reminder, and the people invited with what they answered;
  • they are read by themselves after the account's contacts (after the account's first Send/Receive and after each one you ask for, otherwise every quarter of an hour while Send/Receive runs by itself), and also when the calendar comes to the front and the last reading is more than two minutes old;
  • an event the server no longer has in that stretch goes from here, but only after that calendar's whole list could be read;
  • a server that offers no calendars for the account says so once and is not asked again in that session, unless you ask for the account's Send/Receive.

They are read only. Every such calendar is one you can't change here: a command that would change an event in one is refused with the reason ("Changes made here are not sent back yet"), and an event made without saying where never goes into a JMAP account's calendar.

What it leaves out

What goes where

  • crates/jmap: calendars.rs (sync_calendar, failed_calendar: whose calendars, Calendar/get, then for each calendar CalendarEvent/query and CalendarEvent/get, what "complete" means for the list and for each calendar) and calendars/event.rs (one JSCalendar event, RFC 8984, made into an event within bounds: its times from utcStart/utcEnd or from its own clock and zone, durations, whole days). The events of a calendar are listed and read by reader.rs (Calls::read_all), the code the contacts are read by: calendars.rs only says what is asked (Run::events: the filter, expandRecurrences, the properties, the caps). reader.rs gets one thing for it: an object that can not be read (Made::Unreadable, an event whose time can not be told) counts as not answered for. Nothing of the contacts' files changes.
  • crates/model: the contract JmapCalendarRequest (the stretch) and JmapCalendarResult (the list, one download for each calendar that could be read), with Debug that prints counts only.
  • crates/engine: cmd/remote.rs: a JMAP account's main calendar is never the default place for a new event, and writable refuses one of its calendars with the reason. The list and the events are taken in by the code that takes a Microsoft account's.
  • crates/ui-egui: jmap_calendar.rs (what is asked for calendars, never beside the account's contacts, the coming to the front, and how an answer is taken in; when a job is due, the back-off and the stale-answer checks are jmap_side_job.rs's, as for the contacts), calendar_sync.rs (the stretch is the one a Microsoft account's wide reading uses; the Microsoft calendar runs never take a JMAP account), hooks in jmap_mail.rs, lib.rs, unconfirmed.rs, and SideJob::reading in jmap_side_job.rs.
  • apps/mailcraft: jmap_runner.rs gets run_calendar beside run_contacts, through the same on_thread and signed_in, on M6 (#1014): the desktop app reads JMAP accounts #1015's Transport, Stop and credentials; main.rs hands it to the window.
  • PRIVACY.md (the JMAP row says that the calendars are read, when, the stretch, and that nothing is written), README.md, ROADMAP.md (M6), docs/jmap.md, docs/gaps.md (gap 5), docs/architecture.md, each table row as a fragment under docs/log.d/, and the release note packaging/release-notes.d/new/1072.md. One new text in the .po template (the refusal), not translated yet.

Caps on what a server sends

  • The calendars: an answer held to 4 MiB, 1,000 entries looked at, 100 kept (MAX_REMOTE_CALENDARS), a name cut at 1,024 bytes; the window takes in the events of 64 calendars of an answer.
  • The stretch: five years at the most, whatever a request says, and never past the year 9999.
  • A calendar's list: 500 ids to a page, 400 pages and 20,000 events at the most (MAX_EVENTS); a page that brings nothing new ends the list; what is no JMAP id is not asked for; a page is held to 1 MiB.
  • The events: 200 to a request, or as many as the server takes in a get, for the 20 properties that are read and no others; an answer is held to 8 MiB; a call that fails or is too large is halved, 64 times a calendar at the most, until the event that breaks it is found; after three calls failing one after the other the rest of that calendar is left, and after three calendars in a row for which the server could not be had the rest of the run is.
  • An event: 200 entries of a map looked at, 50 categories kept, a line cut at 1,024 bytes at a character's edge, the notes at 32 KiB, a duration of 40,000 days at the most, every instant held to the years 1 to 9999; an event whose start can't be told is counted as not read and the calendar is then not complete.
  • The window keeps 20 problems of a job, believes a busy server for an hour at the most, and waits one minute after a job that came to nothing, twice as long after each one more, half an hour at the most.

The credential is where it was: in memory, handed over with the job. A line about a failure names no calendar and no event and is scrubbed of the secret, the account's address, the session's address and any word with an @ in it; the log names the account's id and counts only.

How it was checked

  • cargo xtask ci: all 12 steps pass (fmt, test, assets, spdx, test-files, workflows, layers, wasm, deny, i18n, release-notes, docs-log; cargo-deny is not installed here and its step says skipped), and cargo clippy --locked --workspace --all-targets --exclude mailcraft -- -D warnings and cargo clippy --locked -p mailcraft --bin mailcraft -- -D warnings beside it. 7,564 tests pass, 0 fail, 21 ignored.
  • New tests, all against scripted servers or the in-process stand-in, with example.org names: 25 in mailcraft-jmap (calendars/tests.rs, three of them property tests: any JSON as an event, any text as a duration, any answers; and one test of reader/tests.rs widened to what can not be read), 12 in mailcraft-ui-egui (jmap_calendar_tests.rs), 1 in mailcraft-engine, and in the desktop app one new test and four of the contacts' tests widened to the calendars (jmap_runner_tests.rs).
  • The same code was also run by the author against a real JMAP server in a container on loopback, outside the repository: the calendars read passes there.

What a reviewer should look at first

  1. crates/jmap/src/calendars.rs: Run::calendars (which calendars are kept, and which is the main one), Run::events (what is asked for a calendar's events; the list and the reading themselves are Calls::read_all in crates/jmap/src/reader.rs, shared with the contacts), and what makes a download complete, since the engine removes what a complete answer lacks.
  2. crates/jmap/src/calendars/event.rs: times (how start and end are worked out, and when an event is given up as unreadable) and duration.
  3. crates/engine/src/cmd/remote.rs: the two places that keep a JMAP account's calendars read-only here.
  4. crates/ui-egui/src/jmap_calendar.rs: jmap_calendar_due and the taking in of an answer (the job's state and timing are crates/ui-egui/src/jmap_side_job.rs, shared with the contacts).
  5. PRIVACY.md: the JMAP row.

Notes

  • An event with no time zone of its own (a floating one) that the server gives no utcStart for is read as if its wall-clock time were UTC. Servers that answer utcStart are not affected. Say if you would rather have it read in the computer's own zone.

  • PRIVACY.md is one of the documents a change to which is the owners' call (CONTRIBUTING.md): the row is changed here because the program now asks the server for something it did not ask before. Say if you would rather word it yourselves.

  • cargo xtask ci passes

  • "Allow edits by maintainers" is ticked (the box beside Create pull request)

  • I have signed the CLA, or will by commenting on this pull request

Human-reviewed, AI-assisted, nobody's mailbox harmed.

The desktop app gets the host the browser build has for a JMAP account:
apps/mailcraft/src/jmap_runner.rs runs mailcraft-jmap's Send/Receive and
its whole-message fetch over mailcraft_net::https, each job on a thread of
its own, the pieces streamed to the window. main.rs sets Services::jmap and
Services::jmap_fetch; the window already takes JMAP accounts into
Send/Receive once its host runs them.

- mailcraft-net: an answer's Content-Type is kept (a JMAP answer must be
  JSON; one too long to be a media type is none); https::send_with gives an
  exchange a time limit of the caller's (at most 10 min); is_too_slow and
  is_too_long are public.
- Each request kind has its own time limit (session 30 s, API 2 min,
  download 5 min). Stop is heard before each request and latched per job; a
  job never sets the window's shared flag. A Retry-After date is handed to
  the client as seconds, and ignored while the clock is plainly not set.
- The credential stays in memory: the read of the credential store leaves
  JMAP accounts out, so a password kept under an install's old name is no
  longer moved to a JMAP account with that address (it was written to the
  store, though never used to send).
- docs/jmap.md, the architecture table, README, gap 5, M6's row; fragments
  for the logs and the release notes.

Tests: jmap_runner_tests.rs runs the real transport over loopback sockets
against the JMAP stand-in (a whole run, Basic and Bearer, refusals, no
secret and Stop sending nothing, an unreachable server, plain http refused,
messages fetched whole, time limits, the stop latch, Retry-After); a net
test for Content-Type; the_old_name_never_moves_to_a_jmap_account fails
without its fix. cargo xtask ci passes (all 13 steps, deny included).

Human-reviewed, AI-assisted, nobody's mailbox harmed.
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
Pre-merge checks: Inconclusive 2

Failed Failed checks: 2 inconclusive

Check name Status Explanation Resolution
Title check Pending This assessment has not completed. The check will be retried on the next pre-merge check run.
Description check Pending This assessment has not completed. The check will be retried on the next pre-merge check run.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Every author has signed the CLA. Thank you.

@nextxch

nextxch commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

I have read the MailCraft CLA and I agree to it.

… until it is on main

README.md: both sides changed the Servers and Files lines. Kept main's
lines (nothing is sent yet; a .pst file's calendar, tasks, notes and
journal come in) and UCSLabs#1015's word that JMAP is on the desktop too.

ROADMAP.md: both sides changed the M6 row. Kept main's row (the marks,
moves and deletions go up, UCSLabs#1074 part 1) and UCSLabs#1015's word that JMAP
reads mail in the desktop app too.

docs/architecture.md, docs/gaps.md, docs/jmap.md: both sides changed the
sentences that say where a JMAP account is read. Kept main's word that
what is changed in its mail goes up and UCSLabs#1015's that the desktop app is
a host too; the desktop app runs the same `sync_mail`, so the changes go
up from there as well.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
@nextxch
nextxch force-pushed the pr/1072-calendars-read branch from a7782a0 to 515f073 Compare November 13, 2026 06:34
Builds on UCSLabs#1015, the desktop app's JMAP runner. Read only: nothing of
a contact goes up (that is UCSLabs#1076).

- mailcraft-jmap: sync_contacts reads the account's contacts (JMAP for
  Contacts, RFC 9610; cards in JSContact, RFC 9553) where the server
  offers them: ContactCard/query a page at a time, ContactCard/get 200
  to a request, a call that fails halved until the card that breaks it
  is found, 20,000 contacts at the most, every map, list and text of a
  card bounded. A card's picture is not read, and nothing in a card is
  fetched. reader.rs holds what the readers of one kind of data share:
  whose data is read, a request of one call, and the reading itself
  (Calls::read_all: the list page by page, the get in chunks and its
  halving), with tests of its own; contacts.rs says what is asked for
  contacts and what a card becomes.
- mailcraft-model: JmapContactsRequest and JmapContactsResult; a JMAP
  account keeps contacts.
- mailcraft-engine: a JMAP account's download is merged as a Microsoft
  account's is (a test; no change to the code).
- mailcraft-ui-egui: the contacts are a job of their own, after the
  account's Send/Receive and every quarter of an hour, one at a time,
  with the credential the Send/Receive went with. jmap_side_job.rs
  holds what such a job is whatever it reads (when one is due, the wait
  after one that came to nothing, whose an answer is); jmap_contacts.rs
  what is asked for contacts and how they are taken in.
- mailcraft (desktop): run_contacts on top of UCSLabs#1015's runner, through
  on_thread and signed_in, which any such job goes through.
- PRIVACY.md, README.md, ROADMAP.md, docs/jmap.md, docs/gaps.md,
  docs/architecture.md with their fragments, and the release note.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
Builds on UCSLabs#1015 and on UCSLabs#1068. Read only: nothing of a calendar or an
event goes up, and a repeating event comes as its occurrences in the
stretch; the series as one repeating event, and writing, are UCSLabs#1090.

- mailcraft-jmap: sync_calendar reads the calendars the account
  subscribes to and may read (JMAP for Calendars; events in
  JSCalendar, RFC 8984) where the server offers them, and for each the
  events of the stretch: CalendarEvent/query a page at a time with what
  repeats expanded by the server, CalendarEvent/get 200 to a request
  for the properties that are read and no others, a call that fails
  halved until the event that breaks it is found, every map, list and
  text of an event bounded. The list and the halving are reader.rs's,
  as for the contacts (Calls::read_all); it learns of an object that
  can not be read (an event whose time can not be told), which counts
  as not answered for.
- mailcraft-model: JmapCalendarRequest and JmapCalendarResult.
- mailcraft-engine: a JMAP account's calendar is never where an event
  made without saying where goes, and a change to one is refused with
  the reason.
- mailcraft-ui-egui: the calendars are a job of their own, on
  jmap_side_job.rs as the contacts' is, after the contacts' and when
  the calendar comes to the front, a month back and a year ahead.
- mailcraft (desktop): run_calendar beside run_contacts on UCSLabs#1015's
  runner, through the same on_thread and signed_in.
- PRIVACY.md, README.md, ROADMAP.md, docs/jmap.md, docs/gaps.md,
  docs/architecture.md with their fragments, and the release note.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
@nextxch
nextxch force-pushed the pr/1072-calendars-read branch from 515f073 to c35b511 Compare November 13, 2026 07:46
@sonarqubecloud

Copy link
Copy Markdown

@nextxch

nextxch commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@benandez, with #1942 the contacts of a JMAP account run through the engine and the jmap crate rather than through the desktop runner of #1015, which this draft was built on. #1072 (the calendars and events of a JMAP account, read only) is still open. Before I rebuild this draft along the lines of #1942 (JMAP for Calendars, RFC 8620 plus the calendars draft), I would like to ask: is that the shape you want, or do you already have the calendars planned yourselves? I would rather not do the same work twice.

Human-reviewed, AI-assisted, nobody's mailbox harmed.

@benandez

benandez commented Dec 1, 2026

Copy link
Copy Markdown
Member

@nextxch, sorry for the slow answer. Yes, please rebuild it along the lines of #1942: from current main, through the engine and the jmap crate, not the #1015 runner. #1072 stays yours.

Please write it from RFC 8620 and the JMAP for Calendars draft alone. Our clean-room rule (CONTRIBUTING.md) means nothing can be taken or adapted from other MailCraft trees, whatever their licence. A fresh pull request, or a force-push onto this one, are both fine. Once it builds on main on its own we'll review it straight away.

Human-reviewed, AI-assisted, nobody's mailbox harmed.

@nextxch

nextxch commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

@benandez, thanks. Rebuilt from current main along the lines of #1942, from RFC 8620, draft-ietf-jmap-calendars-35 and RFC 8984 alone: #2228. Closing this one in favour of it.

Human-reviewed, AI-assisted, nobody's mailbox harmed.

This branch has not been deployed

No deployments
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.

JMAP accounts: show the server's calendars and events (JMAP for Calendars, read-only)

4 participants