diff --git a/clients/macos/vellum-assistant/Features/MainWindow/ConversationRestorer.swift b/clients/macos/vellum-assistant/Features/MainWindow/ConversationRestorer.swift index 947d9803ceb..c091d6dce2f 100644 --- a/clients/macos/vellum-assistant/Features/MainWindow/ConversationRestorer.swift +++ b/clients/macos/vellum-assistant/Features/MainWindow/ConversationRestorer.swift @@ -546,7 +546,7 @@ final class ConversationRestorer { } // serverOffset is set by fetchConversationList before merging foreground + - // background, so it reflects foreground-only count for correct pagination. + // background, so it reflects the foreground-only DB cursor for correct pagination. log.info("Restored \(restoredConversations.count) conversations from daemon (hasMore: \(response.hasMore ?? false))") delegate.restoreLastActiveConversation() } @@ -692,10 +692,12 @@ final class ConversationRestorer { let uniqueBackground = (background?.conversations ?? []).filter { seenIds.insert($0.id).inserted } - // Set serverOffset from foreground count BEFORE merging. - // loadMoreConversations pages the foreground endpoint only, - // so the offset must not include merged background rows. - self.delegate?.serverOffset = foreground.conversations.count + // Set serverOffset to the foreground DB cursor BEFORE + // merging. loadMoreConversations pages the foreground + // endpoint only, so the offset must not include merged + // background rows; nextOffset is the DB cursor (see + // fetchAllConversationPages), not the inflated row count. + self.delegate?.serverOffset = foreground.nextOffset ?? foreground.conversations.count let merged = ConversationListResponse( type: foreground.type, conversations: foreground.conversations + uniqueBackground, @@ -735,6 +737,7 @@ final class ConversationRestorer { let pageSize = Self.conversationListPageSize var accumulated: [ConversationListResponseItem] = [] var firstPage: ConversationListResponse? + var nextOffset = 0 for page in 0..