From 70a5c2a3d9223722ceed05ded0b18c68b709410b Mon Sep 17 00:00:00 2001 From: LembkeM <26285953+LembkeM@users.noreply.github.com> Date: Thu, 26 Nov 2026 14:07:29 +0100 Subject: [PATCH 1/2] #1897: new mail works out only its own topics' conversations Each piece of new mail had the conversations of every message worked out again: about 150-200 ms at 100,000 messages, at each piece of a new account's first download. A conversation is of one account and one topic, so only the topics a change touched are worked out again now. A frame after a message came, at 326,000 messages: 57-86 ms, was 365-440. The first build over the mailbox, once at opening, takes a little longer (530-670 ms, was 290-460). A property test checks that the conversations brought in step are those of a build over every message. Human-reviewed, AI-assisted, nobody's mailbox harmed. --- crates/engine/src/conversations.rs | 235 ++++++++++++++++++----- crates/engine/src/conversations_tests.rs | 164 ++++++++++++++++ crates/engine/src/lib.rs | 2 + crates/model/src/thread_index.rs | 18 ++ docs/gaps.md | 2 +- docs/log.d/ROADMAP/progress/1897.md | 1 + docs/log.d/ROADMAP/revisions/1897.md | 1 + docs/log.d/docs/gaps/revisions/1897.md | 1 + packaging/release-notes.d/fixes/1897.md | 1 + 9 files changed, 374 insertions(+), 51 deletions(-) create mode 100644 crates/engine/src/conversations_tests.rs create mode 100644 docs/log.d/ROADMAP/progress/1897.md create mode 100644 docs/log.d/ROADMAP/revisions/1897.md create mode 100644 docs/log.d/docs/gaps/revisions/1897.md create mode 100644 packaging/release-notes.d/fixes/1897.md diff --git a/crates/engine/src/conversations.rs b/crates/engine/src/conversations.rs index 83c0cea589..06d843c975 100644 --- a/crates/engine/src/conversations.rs +++ b/crates/engine/src/conversations.rs @@ -14,9 +14,13 @@ //! is the same, and only one that isn't has its hash worked out again, and is pointed at as it is //! now, so that it isn't hashed again at the next check and what it was is let go of. So a flag, //! a category, a move or a read mark keeps the conversations (a pass of pointer comparisons over -//! a few hundred chunks, and over the messages of the few that changed), and a changed subject or -//! header, a server's answer about its conversation, or a message more or less, has them worked -//! out again. +//! a few hundred chunks, and over the messages of the few that changed). A changed subject or +//! header, a server's answer about its conversation, or a message more or less has only its +//! topics worked out again (#1897): a conversation is of one account and one topic +//! ([`ThreadIndex::rejoin`]), and with each message is kept its topic, and with each topic its +//! messages. So a new account's first download, a piece at a time, doesn't go over every message +//! of the mailbox at each piece. A change past [`most_changed`] (another mailbox opened in its +//! place) has them worked out over every message. //! //! The check is made at the first ask after a command begins and after it ends. Within one //! command, an ask, then a change of what groups a message, then another ask would get the first @@ -24,6 +28,7 @@ //! anything), and one that would must call [`Session::threads_may_change`] between the two. use std::collections::hash_map::DefaultHasher; +use std::collections::{HashMap, HashSet}; use std::hash::{Hash, Hasher}; use std::sync::{Arc, Mutex, PoisonError, Weak}; @@ -35,6 +40,9 @@ use crate::Session; /// The conversations kept ([`Session::threads`]). pub(crate) type ThreadsCache = Mutex>; +/// A topic of an account ([`Message::topic_key`]), shared by the messages of it that are kept. +type Topic = Arc<(Id, String)>; + pub(crate) struct Kept { /// The revision and the count of messages they were last checked at; `None` once the mailbox /// may have changed since ([`Session::threads_may_change`]). @@ -42,23 +50,30 @@ pub(crate) struct Kept { threads: Arc, /// Of each chunk of the map of messages, in the map's order. seen: Vec, - /// How many messages were hashed again in checks (for tests). + /// The ids of the messages of each topic, smallest first: the topics a change touches are + /// worked out again, and only those (#1897). + topics: HashMap>, + /// How many messages the checks hashed again (for tests). rehashed: u64, + /// How many times they were worked out over every message (for tests). + built: u64, } /// What is kept of one chunk of the map of messages: the chunk as it was seen, and of each of -/// its messages, in order of id, its id, a weak pointer to it and the hash of what groups it. +/// its messages, in order of id, what was seen of it. struct SeenChunk { key: Id, chunk: Weak, - messages: Vec<(Id, Weak, u64)>, + messages: Vec, } -impl SeenChunk { - fn of(key: Id, chunk: &Arc) -> SeenChunk { - let messages = chunk.iter().map(|(id, m)| (*id, Arc::downgrade(m), grouping_hash(m))).collect(); - SeenChunk { key, chunk: Arc::downgrade(chunk), messages } - } +/// What was seen of one message: a weak pointer to it, the hash of what groups it, and its topic +/// (none, without a subject: a conversation of its own). +struct Seen { + id: Id, + message: Weak, + hash: u64, + topic: Option, } /// The hash of what [`ThreadIndex::build`] reads of `m`. @@ -84,49 +99,161 @@ pub(crate) fn same_grouping(a: &Message, b: &Message) -> bool { && server(a) == server(b) } -/// Whether `kept` is of the messages of `mailbox`, as far as conversations go; a chunk or a -/// message found the same is pointed at as it is now. -fn still_of(kept: &mut Kept, mailbox: &Mailbox) -> bool { - let chunks = mailbox.messages.chunks(); - if kept.seen.len() != chunks.len() { - return false; +/// The topic of `m`, the one kept when there is one (so each is kept once). +fn topic_of(topics: &HashMap>, m: &Message) -> Option { + let key = m.topic_key(); + if key.is_empty() { + return None; } - let mut rehashed = 0u64; - let same = kept.seen.iter_mut().zip(chunks).all(|(seen, (key, chunk))| { - if seen.key != *key { - return false; + let key = (m.account, key); + Some(topics.get_key_value(&key).map_or_else(|| Arc::new(key), |(topic, _)| topic.clone())) +} + +fn seen(topics: &HashMap>, id: Id, m: &Arc) -> Seen { + Seen { id, message: Arc::downgrade(m), hash: grouping_hash(m), topic: topic_of(topics, m) } +} + +/// What is kept of `mailbox`, with its conversations worked out over every message. +fn kept_of(mailbox: &Mailbox, at: Option<(u64, usize)>, built: u64) -> Kept { + // Each topic with its messages, each message's topic found once. + let mut by_topic: HashMap<(Id, String), (Topic, Vec, Vec<&Message>)> = HashMap::new(); + let mut seen_chunks = Vec::with_capacity(mailbox.messages.chunks().len()); + for (key, chunk) in mailbox.messages.chunks() { + let mut messages = Vec::with_capacity(chunk.len()); + for (id, m) in chunk.iter() { + let name = m.topic_key(); + let topic = (!name.is_empty()).then(|| { + let (topic, ids, of_it) = by_topic.entry((m.account, name)).or_insert_with_key(|k| (Arc::new(k.clone()), Vec::new(), Vec::new())); + ids.push(*id); + of_it.push(m.as_ref()); + topic.clone() + }); + messages.push(Seen { id: *id, message: Arc::downgrade(m), hash: grouping_hash(m), topic }); } - if std::ptr::eq(seen.chunk.as_ptr(), Arc::as_ptr(chunk)) { - return true; + seen_chunks.push(SeenChunk { key: *key, chunk: Arc::downgrade(chunk), messages }); + } + let mut topics = HashMap::with_capacity(by_topic.len()); + let mut lists = Vec::with_capacity(by_topic.len()); + for (topic, ids, of_it) in by_topic.into_values() { + topics.insert(topic, ids); + lists.push(of_it); + } + let mut threads = ThreadIndex::default(); + threads.rejoin(&[], &lists); + Kept { at, threads: Arc::new(threads), seen: seen_chunks, topics, rehashed: 0, built: built.saturating_add(1) } +} + +/// Most messages a change may touch for its topics alone to be worked out again: past it (a +/// mailbox opened in place of another, a whole folder brought in at once) working them all out +/// is no slower. +fn most_changed(mailbox: &Mailbox) -> usize { + (mailbox.messages.len() / 4).max(1024) +} + +/// Bring `kept` in step with `mailbox`: a chunk that is the same `Arc` holds the same messages +/// and isn't looked into; in one that isn't, a message that is the same `Arc` is the same, and +/// only one that isn't has its hash worked out again, and is pointed at as it is now. The topics +/// of the messages that came, went or group otherwise are worked out again. Whether it could be +/// (`false` past [`most_changed`]: `kept` is then to be built afresh), and whether anything about +/// the conversations changed. +fn bring_in_step(kept: &mut Kept, mailbox: &Mailbox) -> Option { + let most = most_changed(mailbox); + let mut gone: Vec<(Id, Topic)> = Vec::new(); + let mut came: Vec<(Id, Topic)> = Vec::new(); + let mut changed = 0usize; + let mut rehashed = 0u64; + let mut old = std::mem::take(&mut kept.seen).into_iter().peekable(); + let mut now_seen = Vec::with_capacity(mailbox.messages.chunks().len()); + let went = |was: Seen, gone: &mut Vec<(Id, Topic)>, changed: &mut usize| { + *changed = changed.saturating_add(1); + if let Some(topic) = was.topic { + gone.push((was.id, topic)); } - if seen.messages.len() != chunk.len() { - return false; + }; + for (key, chunk) in mailbox.messages.chunks() { + while let Some(before) = old.next_if(|c| c.key < *key) { + for was in before.messages { + went(was, &mut gone, &mut changed); + } } - let same = seen.messages.iter_mut().zip(chunk.iter()).all(|((was_id, was, hash), (id, now))| { - if was_id != id { - return false; + let before = old.next_if(|c| c.key == *key); + let before = match before { + Some(same) if std::ptr::eq(same.chunk.as_ptr(), Arc::as_ptr(chunk)) => { + now_seen.push(same); + continue; + } + other => other, + }; + let mut was = before.map(|c| c.messages).unwrap_or_default().into_iter().peekable(); + let mut messages = Vec::with_capacity(chunk.len()); + for (id, now) in chunk.iter() { + while let Some(left) = was.next_if(|w| w.id < *id) { + went(left, &mut gone, &mut changed); } - if std::ptr::eq(was.as_ptr(), Arc::as_ptr(now)) { - return true; + match was.next_if(|w| w.id == *id) { + Some(same) if std::ptr::eq(same.message.as_ptr(), Arc::as_ptr(now)) => messages.push(same), + Some(same) => { + rehashed = rehashed.saturating_add(1); + let hash = grouping_hash(now); + if hash == same.hash { + messages.push(Seen { message: Arc::downgrade(now), ..same }); + } else { + went(same, &mut gone, &mut changed); + let one = seen(&kept.topics, *id, now); + came.extend(one.topic.clone().map(|topic| (*id, topic))); + messages.push(one); + } + } + None => { + changed = changed.saturating_add(1); + let one = seen(&kept.topics, *id, now); + came.extend(one.topic.clone().map(|topic| (*id, topic))); + messages.push(one); + } } - rehashed = rehashed.saturating_add(1); - let same = grouping_hash(now) == *hash; - if same { - *was = Arc::downgrade(now); + if changed > most { + return None; } - same - }); - if same { - seen.chunk = Arc::downgrade(chunk); } - same - }); + for left in was { + went(left, &mut gone, &mut changed); + } + now_seen.push(SeenChunk { key: *key, chunk: Arc::downgrade(chunk), messages }); + } + for before in old { + for was in before.messages { + went(was, &mut gone, &mut changed); + } + } + if changed > most { + return None; + } + kept.seen = now_seen; kept.rehashed = kept.rehashed.saturating_add(rehashed); - same -} - -fn seen_of(mailbox: &Mailbox) -> Vec { - mailbox.messages.chunks().iter().map(|(key, chunk)| SeenChunk::of(*key, chunk)).collect() + if gone.is_empty() && came.is_empty() { + return Some(false); + } + // The topics touched, and every id they had. + let touched: HashSet = gone.iter().chain(&came).map(|(_, topic)| topic.clone()).collect(); + let was: Vec = touched.iter().filter_map(|topic| kept.topics.get(topic)).flatten().copied().collect(); + for (id, topic) in gone { + if let Some(ids) = kept.topics.get_mut(&topic) + && let Ok(at) = ids.binary_search(&id) + { + ids.remove(at); + } + } + for (id, topic) in came { + let ids = kept.topics.entry(topic).or_default(); + if let Err(at) = ids.binary_search(&id) { + ids.insert(at, id); + } + } + kept.topics.retain(|_, ids| !ids.is_empty()); + let topics: Vec> = + touched.iter().filter_map(|topic| kept.topics.get(topic)).map(|ids| ids.iter().filter_map(|id| mailbox.message(*id)).collect()).collect(); + Arc::make_mut(&mut kept.threads).rejoin(&was, &topics); + Some(true) } impl Session { @@ -140,17 +267,20 @@ impl Session { pub fn threads(&self) -> Arc { let key = self.threads_key(); let mut cache = self.threads_cache.lock().unwrap_or_else(PoisonError::into_inner); + let mut built = 0; if let Some(kept) = cache.as_mut() { if kept.at == Some(key) { return kept.threads.clone(); } - if still_of(kept, &self.mailbox) { + if bring_in_step(kept, &self.mailbox).is_some() { kept.at = Some(key); return kept.threads.clone(); } + built = kept.built; } - let threads = Arc::new(ThreadIndex::build(self.mailbox.messages.values().map(|m| m.as_ref()))); - *cache = Some(Kept { at: Some(key), threads: threads.clone(), seen: seen_of(&self.mailbox), rehashed: 0 }); + let kept = kept_of(&self.mailbox, Some(key), built); + let threads = kept.threads.clone(); + *cache = Some(kept); threads } @@ -187,7 +317,7 @@ impl Session { /// Whether the conversations of `before` are those of `after`, as [`Session::threads`] checks. #[cfg(test)] pub(crate) fn grouping_kept(before: &Mailbox, after: &Mailbox) -> bool { - still_of(&mut Kept { at: None, threads: Arc::default(), seen: seen_of(before), rehashed: 0 }, after) + bring_in_step(&mut kept_of(before, None, 0), after) == Some(false) } #[cfg(test)] @@ -202,8 +332,13 @@ impl Session { && kept.seen.iter().zip(chunks).all(|(seen, (_, chunk))| { std::ptr::eq(seen.chunk.as_ptr(), Arc::as_ptr(chunk)) && seen.messages.len() == chunk.len() - && seen.messages.iter().zip(chunk.iter()).all(|((_, was, _), (_, now))| std::ptr::eq(was.as_ptr(), Arc::as_ptr(now))) + && seen.messages.iter().zip(chunk.iter()).all(|(was, (_, now))| std::ptr::eq(was.message.as_ptr(), Arc::as_ptr(now))) }); (kept.rehashed, current) } + + /// How many times the conversations were worked out over every message (#1897). + pub(crate) fn threads_built(&self) -> u64 { + self.threads_cache.lock().unwrap_or_else(PoisonError::into_inner).as_ref().map_or(0, |kept| kept.built) + } } diff --git a/crates/engine/src/conversations_tests.rs b/crates/engine/src/conversations_tests.rs new file mode 100644 index 0000000000..5a828189bd --- /dev/null +++ b/crates/engine/src/conversations_tests.rs @@ -0,0 +1,164 @@ +// SPDX-FileCopyrightText: MailCraft contributors +// SPDX-License-Identifier: MIT OR Apache-2.0 +//! #1897: the conversations kept are brought in step with a change by working out again only +//! the topics it touched, and they come out as a build over every message does. + +use mailcraft_model::sync::ServerMessage; +use mailcraft_model::{FolderKind, Id, Mailbox, Message, ThreadIndex}; +use proptest::prelude::*; + +use crate::Session; + +const SUBJECTS: [&str; 5] = ["Invoice for October", "RE: Invoice for October", "Plans", "Fw: plans", ""]; + +/// A change to the mailbox, by a message's place among those there are (wrapped around). +#[derive(Clone, Debug)] +enum Change { + Add { other: bool, subject: usize, own: u8, answers: Option, thread: Option }, + Remove(usize), + Subject(usize, usize), + Answers(usize, Option), + Thread(usize, Option), + Read(usize), +} + +fn change() -> impl Strategy { + let id = || prop::option::of(0u8..12); + prop_oneof![ + 4 => (any::(), 0..SUBJECTS.len(), 0u8..12, id(), id()) + .prop_map(|(other, subject, own, answers, thread)| Change::Add { other, subject, own, answers, thread }), + 2 => any::().prop_map(Change::Remove), + 1 => (any::(), 0..SUBJECTS.len()).prop_map(|(at, subject)| Change::Subject(at, subject)), + 1 => (any::(), id()).prop_map(|(at, answers)| Change::Answers(at, answers)), + 1 => (any::(), id()).prop_map(|(at, thread)| Change::Thread(at, thread)), + 1 => any::().prop_map(Change::Read), + ] +} + +fn message_id(n: u8) -> String { + format!("m{n}@example.org") +} + +/// Two accounts, and enough messages in them to fill more than one chunk of the map of messages. +fn mailbox() -> (Session, [Id; 2]) { + let mut s = Session::new(Mailbox::with_local_account("Avery", "avery@example.org")); + let other = s.run("account.add", &serde_json::json!({"email": "avery@mail.example", "incoming": {"host": "imap.mail.example"}})).unwrap(); + let other = other["id"].as_u64().unwrap(); + let first = s.mailbox.accounts[0].id; + let inboxes = [s.mailbox.folder_of_kind(first, FolderKind::Inbox).unwrap(), s.mailbox.folder_of_kind(other, FolderKind::Inbox).unwrap()]; + for n in 0..1_100u32 { + let m = Message { + folder: inboxes[(n % 2) as usize], + subject: format!("Topic {}", n % 40), + message_id: format!("base{n}@example.org"), + in_reply_to: if n % 3 == 0 { format!("base{}@example.org", n.saturating_sub(40)) } else { String::new() }, + ..Default::default() + }; + s.mailbox.add_message(m).unwrap(); + } + s.mailbox_changed(); + (s, inboxes) +} + +fn pick(s: &Session, at: usize) -> Option { + let ids: Vec = s.mailbox.messages.keys().copied().collect(); + ids.get(at % ids.len().max(1)).copied() +} + +fn apply(s: &mut Session, inboxes: [Id; 2], change: &Change) { + let mb = &mut s.mailbox; + match change { + Change::Add { other, subject, own, answers, thread } => { + let m = Message { + folder: inboxes[usize::from(*other)], + subject: SUBJECTS[*subject].into(), + message_id: message_id(*own), + in_reply_to: answers.map(message_id).unwrap_or_default(), + server: thread.map(|t| ServerMessage { thread: format!("AAQkconv{t}"), ..Default::default() }), + ..Default::default() + }; + mb.add_message(m).unwrap(); + } + Change::Remove(at) => { + if let Some(id) = pick(s, *at) { + s.mailbox.remove_message(id).unwrap(); + } + } + Change::Subject(at, subject) => { + if let Some(id) = pick(s, *at) { + s.mailbox.message_mut(id).unwrap().subject = SUBJECTS[*subject].into(); + } + } + Change::Answers(at, answers) => { + if let Some(id) = pick(s, *at) { + s.mailbox.message_mut(id).unwrap().in_reply_to = answers.map(message_id).unwrap_or_default(); + } + } + Change::Thread(at, thread) => { + if let Some(id) = pick(s, *at) { + s.mailbox.message_mut(id).unwrap().server = thread.map(|t| ServerMessage { thread: format!("AAQkconv{t}"), ..Default::default() }); + } + } + Change::Read(at) => { + if let Some(id) = pick(s, *at) { + let m = s.mailbox.message_mut(id).unwrap(); + m.read = !m.read; + } + } + } + s.mailbox_changed(); +} + +/// Every message's conversation, as `threads` has it. +fn conversations(s: &Session, threads: &ThreadIndex) -> Vec<(Id, Id, Vec)> { + s.mailbox.messages.keys().map(|id| (*id, threads.key(*id).0, threads.members(*id))).collect() +} + +proptest! { + #![proptest_config(ProptestConfig { cases: 48, ..ProptestConfig::default() })] + + #[test] + fn conversations_brought_in_step_are_those_built_afresh(changes in prop::collection::vec(change(), 1..40), every in 1usize..6) { + let (mut s, inboxes) = mailbox(); + let _ = s.threads(); + for (n, change) in changes.iter().enumerate() { + apply(&mut s, inboxes, change); + // Asked after some of the changes, not each: several come together, as a frame takes + // in several pieces. + if n % every == 0 { + let kept = s.threads(); + let afresh = ThreadIndex::build(s.mailbox.messages.values().map(|m| m.as_ref())); + prop_assert_eq!(conversations(&s, &kept), conversations(&s, &afresh), "after {:?}", &changes[..=n]); + } + } + let kept = s.threads(); + let afresh = ThreadIndex::build(s.mailbox.messages.values().map(|m| m.as_ref())); + prop_assert_eq!(conversations(&s, &kept), conversations(&s, &afresh)); + // Brought in step each time: built over every message only once. + prop_assert_eq!(s.threads_built(), 1); + } +} + +/// New mail of one account, a piece at a time, doesn't have every message of the mailbox worked +/// out again: only its topics are (#1897). +#[test] +fn new_mail_works_out_its_own_topics_only() { + let (mut s, inboxes) = mailbox(); + let _ = s.threads(); + for n in 0..200u8 { + apply(&mut s, inboxes, &Change::Add { other: true, subject: usize::from(n % 4), own: n % 12, answers: Some(n % 7), thread: None }); + let _ = s.threads(); + } + assert_eq!(s.threads_built(), 1); + // A mailbox opened in place of this one is worked out afresh. + let mut other = s.mailbox.clone(); + for id in other.messages.keys().copied().collect::>() { + other.message_mut(id).unwrap().subject = "Everything".into(); + } + s.mailbox = other; + s.mailbox_changed(); + let threads = s.threads(); + assert_eq!(s.threads_built(), 2); + let afresh = ThreadIndex::build(s.mailbox.messages.values().map(|m| m.as_ref())); + assert_eq!(conversations(&s, &threads), conversations(&s, &afresh)); +} diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index e04b09331c..4941f49483 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -437,6 +437,8 @@ mod category_rows_tests; #[cfg(test)] mod composing_tests; #[cfg(test)] +mod conversations_tests; +#[cfg(test)] mod counts_tests; #[cfg(test)] mod draft_in_thread_tests; diff --git a/crates/model/src/thread_index.rs b/crates/model/src/thread_index.rs index a4091adba3..34109459f0 100644 --- a/crates/model/src/thread_index.rs +++ b/crates/model/src/thread_index.rs @@ -162,6 +162,24 @@ impl ThreadIndex { index } + /// Work the conversations of some of the topics out again (#1897): `was`, every id those + /// topics had when they were last worked out, and `topics`, the messages of each now, in + /// order of id. What it gives is what [`ThreadIndex::build`] would give of the mailbox as it + /// is now, as long as every topic that changed is among them: a conversation is of one + /// account and one topic, so the others stand as they are. (All of `was` goes first: a + /// message whose subject changed was of one of them and is of another.) + pub fn rejoin(&mut self, was: &[Id], topics: &[Vec<&Message>]) { + for id in was { + self.work = self.work.saturating_add(1); + if let Some(key) = self.keys.remove(id) { + self.members.remove(&key); + } + } + for same in topics.iter().filter(|same| same.len() > 1) { + self.join(same); + } + } + /// Link the messages `same`, all of one account and one topic, into their conversations. fn join(&mut self, same: &[&Message]) { let mut sets = Sets::new(same.len()); diff --git a/docs/gaps.md b/docs/gaps.md index 7db172a437..3fc8fe8ccb 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -23,7 +23,7 @@ this code base. | 5 | **Microsoft Graph is used for a little; JMAP in the browser build only; no CalDAV or CardDAV, and Exchange servers for mail only.** For accounts that sign in with Microsoft, Graph sends mail, brings the contacts down (read-only) and keeps the account's calendars both ways: appointments, repeating series, meetings (invitations, updates and cancellations sent by the server after the owner's yes), answers to invitations and categories. What is still missing is in [calendar-parity.md](calendar-parity.md): Find a Time over several days, shared calendars, and none of it has met the real service beyond one mailbox. Other providers have no server calendar or contacts, but a calendar on the web can be subscribed to (an `.ics` address, https or webcal, read-only under Other Calendars and refreshed every hour: Internet Calendars, #209); shared mailboxes are read through Graph for any work or school Microsoft account (#70: read through Graph, searched, counted on their own and put among the Favorites; what is changed in them goes up to their own address, deleted mail to their own Deleted Items, and undo with it; mail moves and copies between a shared mailbox and its owner's mailbox or another of his shared mailboxes, made in the destination at its own address and the original removed only once the copy is there; mail written in them is from their address, kept in their own Drafts and sent through them, once the owner has allowed sending from shared mailboxes; each with signatures of its own; their calendars are read once ticked, with the owner's permission asked for by itself and free/busy-only ones drawn as blocks, but not changed from here yet), and the browser build connects only to JMAP servers: the mailboxes, the newest messages and their marks come down, the marks, moves between the server's folders and deletions made here go up, and mail is sent through the server (#1074: an alias with an identity of its own on the server isn't sent from, and who got a blind copy isn't kept after sending), and its contacts are kept in step both ways where the server offers them (#1068, #1076: every address book, shared ones with the rights they give, only the fields changed sent; groups and photos not read); what is changed in folders doesn't go up yet (it can't open the sockets IMAP and SMTP need; [jmap.md](jmap.md)); an Exchange server account (an organisation's own Exchange Server, Grommunio or SmarterMail, reached through Exchange Web Services, #252) (what has been seen on Grommunio, and what has not: [exchange-servers.md](exchange-servers.md)) is a kind of account anyone can add, for its mail only (its calendar and contacts are not kept in step yet), and reads its mail down, and takes up what is changed in it, drafts and sent mail (Send/Receive brings its folders and messages as headers and a preview, then whole messages within Mail to keep offline, from the sync states the server gave; Basic over TLS or NTLMv2 on one held connection, one certificate trusted by its fingerprint; added from Add Account's explicit Exchange server choice: the address and a password, and Server settings for the server's address and the user name; nothing is sent until Connect; the server is found by Autodiscover or taken as typed, the owner is asked (naming the host whole) before the sign-in goes to a host outside their mail domain, and inside it to any host but its Autodiscover host and the hosts its SRV record names (the domain's own name is often a web site, AU3-V1), a mailbox in Microsoft 365 is offered as a Microsoft account with no password sent, the account is tried with one request for its Inbox before it is added, a certificate the system doesn't trust is shown and trusted for that account by its fingerprint only on the owner's tick (asked again from File › Info when it changes, never for an expired or wrong-name one), the password is remembered with the system's credential store when the owner lets it be, and File › Info shows the server, the user name, how it signed in and the trusted certificate, with Forget): Kerberos and modern sign-in are not built, Autodiscover can't sign in with NTLM (a server that wants it is set up by typing its address), a message moved on the server comes as a new one, and one over about 12 MB is not downloaded whole. The DAV foundation has collection/resource snapshots, preserving iCalendar/vCard document edits and a bounded XML reader (`mailcraft-dav`, #376); it does not discover servers, upload changes or sync calendars and contacts. | B | `crates/net/src/graph.rs`, `crates/engine/src/cmd/remote.rs`, `crates/dav` | Anyone who runs meetings from here; everyone not on Microsoft; everyone on the web build | 50–100 | [ROADMAP.md](../ROADMAP.md#after-beta) | | 6 | **HTML mail is close, not exact.** Tables, colours, alignment, sizes, lists, quotes and pictures are shown, adjusted for the dark theme, with nothing run; pictures on the web come only when the owner asks for them, and are kept on this computer for 30 days (`apps/mailcraft/src/picture_cache.rs`); pictures written into the message (`data:`) are shown as attached ones are (#533), and a reply or forward carries them in the original, each as a part of its own as Outlook sends them (#602); a message's `