Repository navigation
Add read status to messages_fetch - #195
Merged
Merged
Conversation
iMCP has been pinned to Madrid 0.1.0. Madrid has since shipped 0.2.0, 0.3.0, and 0.4.0. This bumps the pin to 0.4.0 with no behaviour change, so that later work can use APIs added in those releases (notably `Message.readAt` / `Message.isRead` from 0.3.0, for mattt#154). The version requirement was already `upToNextMajorVersion` from 0.1.0, which 0.4.0 satisfies, so this is mechanically a re-resolve. The declared minimum is raised alongside the lockfile to keep the two in agreement. Source compatibility was verified by compiling iMCP's Madrid call sites (`Database()`, `Database(path:)`, `fetchParticipant(matching:)`, `fetchMessages(with:in:limit:)`, and the `Message` properties read in `messages_fetch`) against 0.4.0. They compile unchanged. Behaviour was checked against 0.1.0 for the two cases that could have differed, and matches in both: - With no participants, 0.1.0 skipped the participant condition. In 0.4.0 the deprecated `fetchMessages` shim likewise omits the predicate for an empty set, and `.and([])` compiles to an absent WHERE clause rather than a false one. - Message ordering was `ORDER BY m.date DESC` in 0.1.0, and the 0.4.0 default sort is `[.date(.descending), .id(.descending)]` — the same order, with an added tiebreak. Co-Authored-By: Claude Opus 5 <[email protected]>
Closes mattt#154. Adds an optional `isRead` filter to `messages_fetch`, and reports read status on every message it returns: - `isRead` (input, optional): if true, fetch read messages; if false, unread incoming; if omitted, fetch all. - `isRead` (output): present on every message. - `dateRead` (output): ISO 8601, omitted when the message is unread. The tri-state input mirrors `reminders_fetch`'s `completed` parameter rather than introducing a single-purpose `unreadOnly` flag, so the same parameter also expresses "only messages I have read". Filtering for unread excludes outgoing messages. Read receipts populate a read date on messages you sent, so without that guard "unread" would also report your own messages the recipient has not read yet. Read status is derived from Madrid's `Message.readAt`, which is the read timestamp `chat.db` records rather than a dedicated unread flag. A message marked read without a recorded timestamp therefore counts as unread, so this is a superset of genuinely-unread and may not match the Messages app badge exactly. Known limitation: `messages_fetch` fetches `max(limit, 1024)` candidates and filters them down to `limit`, so the filter only sees the most recent 1024 messages. A large *read* backlog can push unread messages outside that window. Filtering in SQL instead would remove the limitation, but Madrid has no read-status predicate to compose; mattt/Madrid#17 proposes one. The tool's schema would not change if the filtering later moves into the query. Co-Authored-By: Claude Opus 5 <[email protected]>
sebpretzer
force-pushed
the
unread-message-filtering
branch
from
August 30, 2026 02:16
9c7fcc3 to
8a30483
Compare
Closed
# Conflicts: # iMCP.xcodeproj/project.pbxproj # iMCP.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
Owner
|
Thanks for this, @sebpretzer, and sorry for the wait. This mirrors the Madrid API nicely. I merged main in to pick up the Madrid 0.5.0 bump. Merging now. |
toonvl
added a commit
to toonvl/iMCP
that referenced
this pull request
Sep 2, 2026
Brings in the six upstream commits behind #2: the SIGTRAP continuation fix (mattt#151), the Bonjour browser cleanup (mattt#199), the approval setup-timeout exemption (mattt#200), the events_fetch date-only fix (mattt#175), Madrid 0.5.0 with FetchRequest<Message> (mattt#201), and message read status (mattt#195). Three files conflicted, all because upstream shipped its own version of a fix this fork already carried: - CLI/main.swift: took upstream. Its mattt#199 supersedes our inline browser.cancel() (our closed upstream PR mattt#196) by extracting BonjourDiscovery.discoverEndpoint, which cancels on every exit path and comes with tests. - App/Extensions/Foundation+Extensions.swift: took upstream. Its `count > 10` guard on the timezone-suffix regex is equivalent to our `!isDateOnlyISO8601String(...)`; staying identical to upstream is worth more than the marginal precision. - App/Services/Calendar.swift: kept ours. Upstream only annotates `identifier` on the events_fetch and events_create returns, which our private encode(_:) helper already does alongside organizedByMe, organizer, isRecurring and coordinates. Co-Authored-By: Claude Opus 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hey @mattt, just wanted to follow-up on unread message filtering.
This PR adds an optional
isReadfilter tomessages_fetch. I try to mirror the patterns you use in Madrid and for other iMCP endpoints. Closes #153 and closes #154Let me know if I should adjust this in any way.
Thanks!