Files
oai-swift/oAI/Models/Conversation.swift
T
rune 92e393ab03 Fix Swift 6 actor-isolation warnings in model inits and services
- Message, Conversation, EmailLog: add nonisolated to inits — plain value
  types have no actor isolation, but the macOS 27 SDK was inferring it
- EncryptionService: replace lazy var encryptionKey (which mutates self and
  gets inferred as @MainActor) with an eagerly-initialized let in init()
- FileLogger: add nonisolated to shared, write, and minimumLevel so they
  are callable from nonisolated AppLogger methods without warnings
- LogLevel.<: add nonisolated to the Comparable conformance method

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-16 14:59:07 +02:00

60 lines
1.6 KiB
Swift

//
// Conversation.swift
// oAI
//
// Model for saved conversations
//
// SPDX-License-Identifier: AGPL-3.0-or-later
// Copyright (C) 2026 Rune Olsen
//
// This file is part of oAI.
//
// oAI is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// oAI is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
// Public License for more details.
//
// You should have received a copy of the GNU Affero General Public
// License along with oAI. If not, see <https://www.gnu.org/licenses/>.
import Foundation
struct Conversation: Identifiable, Codable {
let id: UUID
var name: String
var messages: [Message]
let createdAt: Date
var updatedAt: Date
var primaryModel: String? // Primary model used in this conversation
nonisolated init(
id: UUID = UUID(),
name: String,
messages: [Message] = [],
createdAt: Date = Date(),
updatedAt: Date = Date(),
primaryModel: String? = nil
) {
self.id = id
self.name = name
self.messages = messages
self.createdAt = createdAt
self.updatedAt = updatedAt
self.primaryModel = primaryModel
}
var messageCount: Int {
messages.count
}
var lastMessageDate: Date {
messages.last?.timestamp ?? updatedAt
}
}