From 44d62143a83af8acbd1c1d14653d39da37e5de4a Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Tue, 11 Aug 2026 12:41:14 +0200 Subject: feat(sent): add a Sent view, flat and by recipient Adds a `sent` key to [account.*] naming that account's sent folder, and a Sent button beside the saved queries that composes its query from every account carrying one. An account without the key is omitted silently, as a real account may keep no sent mail locally. With no account selected the button spans all of them; selecting one narrows it through the existing scope wrap rather than a second path. Composed at run time rather than shipped as a [queries] entry. A saved query is one fixed string: it cannot narrow to the selected account, and it goes stale the moment an account is added or a provider renames a folder. The design and the measurements behind it are in docs/superpowers/specs/2026-08-11-sent-mail-design.md. Three things there are worth repeating here. The composed path is QUOTED, and that is load-bearing. A real provider nests its sent folder under a bracketed parent, and "[" and "]" are Xapian syntax: unquoted, the query parses rather than matches and returns nothing while looking entirely plausible. Composition happens in one place so there is one chance to get it right, and a bracketed path is pinned in a test. Recipients are opt-in per query, which is a performance contract rather than a preference. notmuch_message_get_header(m, "To") is not served from the index, it reads the message file: folding every thread of a 4411-thread inbox took 38.2 seconds against 251 ms for the 601-thread sent view. The worker skips the walk entirely unless asked, and the refresh path carries the same flag so a background sync cannot blank the column mid-read. Always folding is mutation-tested: the data would be right and only the cost wrong, which nothing else here would notice. The messages reached through the thread are owned by it and freed with it, so recipientsOf() holds them raw and finishes while the thread is alive, exactly as walkReplies does. An NmMessage wrapper there is a double-free. Sent mail is presented flat, and the pane follows. A message you sent otherwise drags in the replies you received, so a view labelled Sent shows conversations rather than what you sent. ThreadListModel::setFlatMode() makes hasChildren() and ReplyCountRole answer differently and changes nothing else; runQuery() sets it on EVERY run, so any other query restores the tree on its way through and the flag cannot outlive the button that set it. The pane needed its own fix for the same reason: the single-message path depends on a field only filled when a thread is expanded, which never happens in a flat list, so loadThread() gained matchedOnly and drops the messages that did not match instead of rendering them as stubs. Recipients replace the sender through the existing SendersRole rather than a new one, so the delegate needs no branch and cannot disagree with the model about which name a row shows. It falls back to the sender when a To header is absent or unparseable, since a blank where a name belongs reads as a rendering fault. Address parsing uses GMime: a display name may contain a comma, so "Rossi, Mario" , info@example.net is two addresses and splitting reports three. internet_address_list_parse returns NULL for an empty string, which is a crash if unguarded. Backlog item 63. --- README.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'README.md') diff --git a/README.md b/README.md index 17146d5..6dcbb66 100644 --- a/README.md +++ b/README.md @@ -165,6 +165,7 @@ name = Your Name address = you@example.org maildir = work-mail ; relative to notmuch's database.path drafts = Drafts ; recorded for v2; unused today +sent = Sent ; optional; enables the Sent button for this account label = W ; optional chip text; defaults to the key color = #2f6fa8 ; optional chip colour; generated when unset channel = work ; optional mbsync channel; defaults to the key @@ -203,6 +204,44 @@ The button text is the key you write here, so these names are yours to choose. `Important = tag:flagged` and `Flagged = tag:flagged` run the same query and differ only in what the button says. +### Sent mail + +A **Sent** button appears beside the saved queries once at least one account +carries a `sent` key naming its sent folder, relative to that account's +`maildir`: + +```ini +[account.work] +maildir = work-mail +sent = Sent + +[account.webmail] +maildir = webmail +sent = [Provider]/Posta inviata ; nested and localised folders are fine + +[account.list-only] +maildir = list-only +; no sent key: this account is simply left out of the Sent view +``` + +The button composes its query from those keys every time you press it, rather +than storing one, so adding an account or correcting a folder name is a config +edit and nothing else. With no account selected it shows every configured +account's sent mail; selecting one narrows it to that account. An account +without the key is omitted silently, since keeping no sent mail locally is a +legitimate setup rather than a mistake. + +Sent mail is presented differently from the rest, because it reads differently: + +- **A flat list, not threads.** A message you sent otherwise drags in the + replies you received, and a view labelled Sent then shows conversations. +- **Cards name the recipients**, not the sender, which is you on every row. +- **Selecting one opens what you sent**, rather than the whole conversation it + started. + +This applies only to the Sent button. The same query typed into the bar by hand +behaves like any other query, threads and all. + ## The query bar The bar at the top takes a notmuch query and shows the matching threads. -- cgit v1.2.3