From 67b3d28084576ca87d9b80c267e3a88cf8b113c9 Mon Sep 17 00:00:00 2001 From: mattt Date: Wed, 2 Sep 2026 11:58:17 -0700 Subject: [PATCH] Bump Madrid to 0.5.0 and adopt FetchRequest Madrid 0.4.0 deprecated fetchMessages(with:in:limit:), and the project treats warnings as errors, so any bump past 0.1.0 failed the build at the call in Messages.swift. Move that call to fetch(_:) with an equivalent predicate, and pin 0.5.0, which reads the write-ahead log and exposes Message.chatID for the follow-up Messages PRs. --- App/Services/Messages.swift | 17 +++++++++++++---- iMCP.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/swiftpm/Package.resolved | 4 ++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/App/Services/Messages.swift b/App/Services/Messages.swift index 7a517bef..16841022 100644 --- a/App/Services/Messages.swift +++ b/App/Services/Messages.swift @@ -128,11 +128,20 @@ final class MessageService: NSObject, Service, NSOpenSavePanelDelegate { log.debug( "Fetching messages with date range: \(String(describing: dateRange)), limit: \(limit ?? -1)" ) - for message in try db.fetchMessages( - with: Set(handles), - in: dateRange, + // Match the old fetchMessages(with:in:limit:) semantics: + // no participant filter when no handles matched. + var predicates: [MessagePredicate] = [] + if !handles.isEmpty { + predicates.append(.participantHandles(Set(handles))) + } + if let dateRange { + predicates.append(.dateRange(dateRange)) + } + let request = FetchRequest( + predicate: .and(predicates), limit: max(limit ?? defaultLimit, 1024) - ) { + ) + for message in try db.fetch(request) { guard messages.count < (limit ?? defaultLimit) else { break } guard !message.text.isEmpty else { continue } diff --git a/iMCP.xcodeproj/project.pbxproj b/iMCP.xcodeproj/project.pbxproj index 45b1bea1..ddf809b3 100644 --- a/iMCP.xcodeproj/project.pbxproj +++ b/iMCP.xcodeproj/project.pbxproj @@ -717,7 +717,7 @@ repositoryURL = "https://github.com/loopwork-ai/madrid"; requirement = { kind = upToNextMajorVersion; - minimumVersion = 0.1.0; + minimumVersion = 0.5.0; }; }; F825BDBD2D9AD00E0063ADD7 /* XCRemoteSwiftPackageReference "swift-service-lifecycle" */ = { diff --git a/iMCP.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/iMCP.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 0e03dd92..631b6854 100644 --- a/iMCP.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/iMCP.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -24,8 +24,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/loopwork-ai/madrid", "state" : { - "revision" : "9d9fdb20424483fb592e5a026d9d0816cd5c43eb", - "version" : "0.1.0" + "revision" : "11ec80cb67700e47948f90cef6de38bce4dbfb12", + "version" : "0.5.0" } }, {