Skip to content

Draft: FYI mail reaches push-tier sessions with their next wake message - #225

Draft
pinjun99 wants to merge 1 commit into
reason-machines:mainfrom
pinjun99:fix/fyi-mail-push-sessions-222
Draft

pinjun99 wants to merge 1 commit into
reason-machines:mainfrom
pinjun99:fix/fyi-mail-push-sessions-222

Conversation

@pinjun99

Copy link
Copy Markdown

Refs #222

A draft so you can pick the approach. This implements option (b) from the issue, plus the notice fix. If you'd rather have (a) or another route, I'm happy to switch.

Why (b)

  • DESIGN.md says FYI mail "waits for its next natural pause". A pushed wake message is already a pause the session takes, so FYI mail can ride along with it without waking the session by itself.
  • check_inbox stays hidden from pushed sessions, so they don't pay tokens for a tool they don't otherwise need.
  • No Claude Code hooks are added. That's option (c), which I left alone.

What changed

  • src/daemon/mail.rs (deliver): when wake mail goes out through a push channel (Claude socket, command or Claude direct), the session's pending FYI mail is added to the same delivery.
    • Mail is marked read only when the session confirms delivery, as today.
    • FYI already in flight isn't sent twice, and a failed handoff retries it together with its wake mail.
    • FYI alone still never starts a push.
  • src/mcp.rs / src/render.rs: finish() now records whether the last tools/list included check_inbox. The unread notice says "Call check_inbox to read." only when that tool was listed. Otherwise it says FYI mail comes with the next pushed wake message.
  • DESIGN.md: two sentences updated to match.

Limitation

A push-tier session that gets only FYI mail and never any wake mail still won't see it until the next wake message arrives. With (b) that's by design. If that case matters, (a) or a timed flush would cover it.

Tests

  • New daemon::mail::tests::pushed_wake_mail_carries_fyi_once_and_only_counts_it_read_after_handoff. It covers the send, re-register and stop-waiting handover paths, no duplicate FYI, a retry after a failed push, and read only after Delivered. It fails with the deliver change reverted.
  • New render::tests::unread_notices_name_check_inbox_only_when_listed, and a new integration test tests/mcp_unread.rs that runs the MCP server and checks the notice against the tool list, including before the first listing.
  • One existing test was updated: it expected FYI to stay behind after a pushed wake message.
  • cargo fmt --check: clean. cargo clippy --all-targets --locked -- -D warnings: clean.
  • cargo test --locked: 343 + 5 + 2 + 1 passed, 0 failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant