From e7c7b9b5c6b531f24a379f3acff4841c5939fe55 Mon Sep 17 00:00:00 2001 From: Rune Olsen Date: Wed, 17 Jun 2026 11:54:28 +0200 Subject: [PATCH] Fix combined conversation's model to reflect sources, not the merge model primaryModel was being set to the model that performed the merge (or, in AI mode, stamped onto every synthesized message). It should instead be the most recently used model among the source conversations being combined. Co-Authored-By: Claude Sonnet 4.6 --- oAI/Services/ConversationMergeService.swift | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/oAI/Services/ConversationMergeService.swift b/oAI/Services/ConversationMergeService.swift index be26b29..ffc3569 100644 --- a/oAI/Services/ConversationMergeService.swift +++ b/oAI/Services/ConversationMergeService.swift @@ -67,6 +67,14 @@ enum ConversationMergeService { try DatabaseService.shared.loadConversation(id: id) } + // The model used in the merged conversation should reflect the most recently used + // model across the *source* conversations — never the model that performed the merge. + let latestModelId = sources + .flatMap { $0.1 } + .filter { $0.modelId != nil } + .max { $0.timestamp < $1.timestamp }? + .modelId + let mergedMessages: [Message] switch mode { case .simple: @@ -75,7 +83,12 @@ enum ConversationMergeService { mergedMessages = try await aiMerge(sources) } - let newConversation = try DatabaseService.shared.saveConversation(name: name, messages: mergedMessages) + let newConversation = try DatabaseService.shared.saveConversation( + id: UUID(), + name: name, + messages: mergedMessages, + primaryModel: latestModelId + ) if deleteOriginals { for id in conversationIds { @@ -148,13 +161,15 @@ enum ConversationMergeService { let turns = try parseTurns(from: response.content) + // modelId intentionally left nil here: these messages are a synthesized composite, + // not output from a single source model. The conversation's primaryModel (set by the + // caller from the source conversations) is what drives the model shown in the list. let base = Date() return turns.enumerated().map { index, turn in Message( role: turn.role == "user" ? .user : .assistant, content: turn.content, - timestamp: base.addingTimeInterval(TimeInterval(index)), - modelId: modelId + timestamp: base.addingTimeInterval(TimeInterval(index)) ) } }