Repository navigation
fix: compose and draft audit — account names, trash counts, thread grouping, draft window damage, blind replies, draft editing - #98
Conversation
Two problems, one cause: the flag was applied by deleting tools rather than by gating the sending path. 1. The guard in manage_drafts(action="send") never fired. compose.py did `from apple_mail_mcp.server import READ_ONLY`, binding the value False at import, while __main__ assigns server.READ_ONLY afterwards. The module now reads the flag through the server module at call time. 2. --read-only removed compose_email and reply_to_email outright, even though their "draft" and "open" modes never deliver anything. Those two are also the only tools in the compose surface that accept attachments, so read-only mode left no supported way to attach a file to a draft. They now stay registered and refuse mode="send" themselves. forward_email has no non-sending mode and is still removed. Adds regression coverage for both, including one test that fails if the flag is ever bound at import time again.
…wurf bearbeiten Claude-Session: https://claude.ai/code/session_01DKjXwP6sh7k12HAZWMuyoT
|
This review was written by Claude (AI assistant) on Patrick's behalf. Thanks @herbeckrobin, this is a thorough audit and a lot of it is good. 166 tests pass. As one PR, though, it's hard to review and merge safely: it bundles 7 unrelated fixes, conflicts with #91, #92, #94 and #104, and #99 then rewrites its reply design again. Could you split it? These four look good and would land quickly as small standalone PRs:
Note: The reply/draft rewrite is the part that needs the most care. We'd like it as one reply/compose PR built against epic #80 (id-first targeting, verified drafts), coordinated with #91/#92 which already add draft verification. Specific concerns are in the #99 review, several of which start here:
|
Six fixes to the compose/draft surface, each reproduced against a live Mail.app before the fix and covered by a regression test. Commit subjects are in German (the fork's working language); the code, comments and tests are English.
What is in here
|were cut in half.list_accounts,list_account_addressesandget_mailbox_unread_countsused|as their field delimiter, so an account literally namedRobin Herbeck | Full Stack Developercame back as two unusable fragments and every follow-up call failed with "account not found".manage_trashreported deletions that never happened. It counteddeletecalls, but Mail'sdeleteis a no-op on a message already in Trash. It now measures the mailbox before and after. It also iterated a message list forward while deleting from it, which shifts the list and skips every second message (-1728on the next index); the loop runs backwards now.save_email_attachmenthad nomailboxparameter, so an attachment outside INBOX was unreachable.get_email_threadmatched on the subject string, which merges unrelated conversations that happen to share one. It followsMessage-Id/In-Reply-To/Referencesnow.compose_email(mode="draft")closed the wrong window. The message is created withvisible:falseand owns no window, soclose window 1 saving yesclosed — and silently saved as a draft — whatever the user had open, while the attachment of the intended draft was lost. It closes its own message object now.In-Reply-Toheaders and no text. It now polls for focus and aborts with an explanation rather than typing into a foreign app.manage_draftscould not edit a draft. Mail cannot modify a stored draft in place, soaction="update"rebuilds it: existing attachments are extracted to disk and re-attached, the old version is deleted only after the replacement is confirmed to exist, and if an attachment cannot be extracted the draft is left untouched rather than rebuilt without it.Relationship to #95
The first commit here is the one from #95 (
--read-onlyblocking delivery instead of removing the compose tools). Everything after it depends on it, so it could not be left out. If #95 is merged first this branch rebases down to the six remaining commits; if you would rather take this one, #95 can be closed as contained.Verification
python -m pytest tests/ -qandpython scripts/check_versions.pyboth pass. Every fix has a regression test that fails against the previous code.https://claude.ai/code/session_01BxRqpRbe7bC31Sj6yuJ8ic