← Back to PRs

#10470: Fix: iMessage real-time delivery via imsg watch

by saurav470 open 2026-02-06 15:00 View on GitHub →
channel: imessage size: S
Fixes #6775 — iMessage messages not delivered in real-time to agent **Root cause:** The gateway relies on `imsg rpc` and `watch.subscribe` for real-time delivery. On some environments (e.g. macOS 25.2, imsg v0.4.0), the RPC process does not emit `method: "message"` when new messages are stored, so the agent only sees messages when manually running `imsg history`. **Approach:** Keep RPC watch as the primary path. Add an optional history-polling fallback so delivery works even when watch does not push: - New config: `channels.imessage.pollIntervalMs` (optional, number, default `0`). When &gt; 0, the monitor runs a loop that calls RPC `chats.list` and then `imsg history --chat-id &lt;id&gt; --limit 5 --json` per chat at the given interval. - All inbound messages (from watch or poll) go through the same handler. A bounded `InboundMessageDeduper` (by chat + message id) ensures each message is delivered at most once. - Docs: gateway configuration and iMessage channel docs updated with `pollIntervalMs` and when to use it. **How to use:** If the agent does not receive iMessages in real time, set e.g. `channels.imessage.pollIntervalMs: 5000` and restart the gateway. Messages will be delivered within the chosen interval; real-time delivery continues to work when the RPC watch pushes. <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> - Adds an optional `channels.imessage.pollIntervalMs` config to enable periodic `imsg history` polling as a fallback when `watch.subscribe` does not emit real-time inbound message events. - Introduces a bounded inbound message deduper so watch- and poll-sourced messages are delivered at most once. - Updates iMessage and gateway configuration docs to describe the new polling fallback. - PR also adds a new PR template file that appears unrelated to this change set. <h3>Confidence Score: 4/5</h3> <!-- greptile_other_comments_section --> <sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub> **Context used:** - Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8)) - Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13)) <!-- /greptile_comment -->

Most Similar PRs