Repository navigation
reply_to_email: target the reply's own window by id, never window 1 (#157) - #160
Conversation
…157) Snapshot Mail's window ids before `reply`, take the single new id as the reply's window, raise it before the Cmd+V paste, and in draft mode close that window (saving yes) instead of `window 1`. If the reply's window can't be identified, raise before pasting so nothing is pasted, saved or sent. `save replyMessage` is only a fallback when closing by id fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CoqrHX93Cthp6tq6oPot7k
…tified Say the body wasn't pasted and nothing was sent (an empty reply window may remain and be autosaved), and drop the account-name hint for this error. From the second review of #160. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CoqrHX93Cthp6tq6oPot7k
|
Posted by Claude (AI maintainer agent) on Patrick's behalf. Merging. This fixes #157: It's safe because send and open modes close no window. The send still runs only after the capture check, and the error path keeps the temp-file cleanup and clipboard restore. An independent second reviewer reached MERGE. I then applied two of its wording notes: the error no longer claims "nothing saved", since Mail may autosave the empty reply window, and the error drops the misleading account-name hint. Its remaining note: if the user opens another Mail window in the instant before the reply's window appears, that window could be taken as the reply's. This is very unlikely, because Checks: CI green. Locally 353 passed, 1 skipped on fastmcp 4.2.6 and on 3.1.0. Versions agree. The new tests fail on the old code. Not yet exercised on a real Mail, so it's worth a manual check before tagging. Generated by Claude Code |
… 2026-12-02 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CoqrHX93Cthp6tq6oPot7k
Posted by Claude (AI maintainer agent) on Patrick's behalf.
Fixes #157 (part of #80).
Problem.
reply_to_email(mode="draft")saved the reply withclose window 1 saving yesafter a fixed delay.window 1is whichever Mail window is in front. When Mail wasn't frontmost, or a viewer window was raised, it closed the wrong window and left the reply open, empty and unsaved (reported on Exchange in #99).Change (
tools/compose.py,reply_to_emailonly):reply, note the ids of Mail's open windows. After it, poll up to ~5 s for new ones. Exactly one new window is taken as the reply's (replyWindowID).set index of window id replyWindowID to 1) before activating Mail and again just before Cmd+V, so the paste lands in the reply.window id replyWindowID saving yes.save replyMessageruns only if that close fails, with a note saying so. Send and open modes close no window.Why close by id rather than
savefirst: closing the reply's own window withsaving yesis how this tool already saved reply drafts whenwindow 1happened to be the reply. Callingsaveon a windowed reply and then closing it hasn't been checked on a real Mail and could leave two draft versions. Sosaveis only the fallback.Not verified on a real Mail (CI and this run are Linux with mocked AppleScript). Worth a quick manual check on macOS: reply in draft mode with Mail in the background and a second viewer window in front.
Tests: 7 new tests in
ReplyWindowTargetingTests. 6 of them fail without the fix. They check that no mode referenceswindow 1, the order snapshot → reply → capture → raise → paste, that the error stops before paste and send, that draft mode closes by id after the paste withsaveonly in theon errorbranch, and that an unidentified-window error isn't reported as saved or verified. Suite: 352 passed, 1 skipped on fastmcp 4.2.6 / mcp 2.3.0 and on 3.1.0 / 1.30.0.check_versions.pyOK.Generated by Claude Code