aboutsummaryrefslogtreecommitdiffstats
path: root/assets/hooks/post-new
AgeCommit message (Collapse)AuthorFilesLines
3 hoursfix(hooks): keep inbox on mail that was sent AND receivedDanilo M.1-11/+114
notmuch deduplicates by Message-ID, so mail the user sends to another of their own accounts is one message with two files: the sender's Sent copy and the recipient's Inbox copy. The carve-out matched on a file's path and tagged the message, so matching the Sent copy stripped inbox from the copy that had genuinely arrived and the mail was missing from the account that received it. sent_only() keeps a message only when EVERY file is inside a sent folder, which is what the docstring already claimed the predicate did. It is a loop because no query can express it: measured against a two-file message, `not path:` does not exclude it, and `count --output=files` reports every file of every matching message rather than the files that matched. Both read as if they worked, and are wrong for the same reason, that a notmuch term is a predicate over a message while this distinction is between its files. The root comes from database.mail_root rather than database.path, since this index is split and no message file is under the index directory. A test fixture with the index outside the mail root covers it; the ordinary layout cannot, because both keys return the same string there. Both mutations fail: all->any loses inbox on the self-addressed message, mail_root->path silently stops stripping anything. Verified read-only against the live index, tagging nothing: of 807 messages matching a sent path, 780 are still stripped and 27 are spared, every one of them two files with one in another account's inbox. No arrival is affected. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HFuRPtzFrSxCQjFk6tq7gD
9 hourschore(hooks): log how many messages the sent carve-out matchedDanilo M.1-1/+26
Item 164 diagnostics. A `notmuch tag` that matches nothing succeeds, so the carve-out logged "applied over N folder(s)" whether it stripped `inbox` from four messages or from none. A draft kept `inbox` on a pass whose log claimed the carve-out had run, and that line could not tell the two cases apart. Count before tagging, since the tag is what makes the count zero, and report it alongside the folder count. Nothing branches on the value: a failed count yields `?` rather than failing the sync, because the tag reports its own status separately. This does not fix item 164, whose trigger is still unreproduced. It makes the next occurrence self-explaining: `0 message(s)` means the message was never in tag:new scope, and a non-zero count means the tag ran over it and something re-added the tag afterwards. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UUQS6n3cmsFrsjCNmwNtf8
47 hoursfeat(hooks): own the notmuch hooks, and keep sent mail out of the inboxDanilo M.1-0/+188
The post-new hook and its rule store move here from the companion mailctl project, which is being retired. Nothing else was shared between the two, so this is a plain move: mailrules.py is stdlib-only and post-new imports only it. With that in hand, the hook learns the one thing it could not know before. notmuch's new.tags applies `inbox` to every file it indexes, and it cannot tell an arrival from the copy this application files into a sent folder after a send, so sent mail turned up in the inbox view and in any hand-typed tag:inbox search. Drafts arrived the same way, through the composer's autosave. 786 messages were affected on the developer's own index. qtmaildirconf.py reads the sent and drafts folders out of qtmaildir.conf, so adding an account fixes itself. Reading the application's own config is not the cross-repo coupling it would have been last week: this repo owns the hook now. Three properties are load-bearing: - it is NOT a relaxation of PROTECTED_REMOVALS, which is about a rule removing `inbox` from mail whose provenance the hook cannot judge. Here the provenance is the file's own path, and `inbox` was never true of it. - only `inbox`. maildir.synchronize_flags is true, so removing `unread` would rewrite Maildir filenames and reach the server on the next mbsync. - an empty folder list means NOTHING, never an empty query, which notmuch reads as "match everything". A system with no qtmaildir config must be left alone rather than have every new message stripped. Trash is deliberately not in the list: Delete leaves `inbox` on a trashed message so Restore can put it back where it came from. The three Python suites run under ctest rather than beside it as scripts someone remembers to run, since this code tags real mail unattended on every sync. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q2koFevoSxTLhfexJTZWQd