From 72812c0ac053a1a841f3864c9e4cce5cb6dab04a Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Tue, 11 Aug 2026 19:02:59 +0200 Subject: feat(placeholder): count sent mail and drafts on the blank pane Item 67. The pane counted unread, flagged and inbox from three fixed tag: queries. Sent and drafts cannot join that list as tags: tag:draft counts 0 against a real database and no draft-ish tag exists in it at all, so a tag-based line would be a permanent zero that reads as working code. Both are composed from each account's folder keys instead, the same way the Sent view already composes its query. The drafts key was parsed and documented as unused in v1. Composing drafts is still v2; counting them is not, so Account::draftsQuery() and Config::allDraftsQuery() now mirror the sent pair. The shared body moved into folderQuery() and joinAccountQueries(), so the load-bearing quoting (a provider nests both folders under a bracketed parent, and [ and ] are Xapian syntax) and the bare-"or" guard exist once rather than once per folder type. The fixed array is gone rather than extended. It held queries and labels in two lists indexed in parallel, which is a hazard that grows with the list: an entry inserted in one and not the other prints a real number against the wrong name and looks entirely plausible. placeholderLines() carries each query beside the callable that labels it, so the two cannot drift, and the count reply stays paired by position as the worker requires. A line is omitted when no account configures that folder rather than shown as 0, following item 63: a missing folder is a real configuration, and "0 sent" claims the user has sent nothing. Measured against the real config: 4 sent terms over 601 threads, 5 drafts terms over 3, the extra drafts term coming from the one account that configures drafts and no sent, which is what proves the two are collected independently. Four tests here and four in test_config, mutation-checked at three points: dropping the drafts line, an off-by-one in the label pairing, and removing the -1 guard for an uncountable query. Each mutation fails a test. --- src/config.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/config.h') diff --git a/src/config.h b/src/config.h index e3c5b6e..4092141 100644 --- a/src/config.h +++ b/src/config.h @@ -34,7 +34,13 @@ struct Account QString name; QString address; QString maildir; ///< Relative to notmuch's database.path. - QString drafts; ///< Unused in v1; send is v2. + /// The account's drafts folder, relative to maildir. Optional, exactly as + /// `sent` is, and absent more often: an account that composes elsewhere + /// keeps no local drafts folder at all. + /// + /// Composing drafts is v2. Reading them is not: the placeholder pane + /// counts them (item 67), which is why this is no longer unused. + QString drafts; /// The account's sent folder, relative to maildir. Optional and empty for /// an account that has none, which is a real case rather than a @@ -81,6 +87,13 @@ struct Account /// selector wraps whatever query runs, so a Sent view under one account /// intersects to that account's sent mail and cannot leak another's. QString sentQuery() const; + + /// Matches this account's drafts, or empty when `drafts` is unset. + /// + /// Separate from sentQuery() rather than one parameterised helper: the two + /// keys are independent, and one real account configures `drafts` with no + /// `sent` at all. + QString draftsQuery() const; }; struct SavedQuery @@ -145,6 +158,13 @@ public: /// open-coded at the call site. QString allSentQuery() const; + /// Matches every configured account's drafts, or empty when none has one. + /// + /// Joins only the NON-EMPTY draftsQuery() results, for the same reason + /// allSentQuery() does: notmuch accepts a bare "or" without complaint and + /// silently answers a different question. + QString allDraftsQuery() const; + /// A QDateTime::toString() pattern for the date on a card, or empty for the /// system locale's short format. /// -- cgit v1.2.3