import Foundation

/// One message the user queued while a turn was in flight, retained as a discrete item so both
/// composers (Mac and the iOS remote) can show and cancel each queued message individually
/// (rather than as one merged blob). Purely transient live state — like `Session.queuedMessage`,
/// never persisted; it resets on reload. The queue still *sends* as a single combined turn (see
/// `SessionController`), but is tracked per-message for display. Lives in NucleicProtocol so it
/// can ride along on the wire `SessionSummary` to the phone.
public struct QueuedMessage: Sendable, Codable, Equatable, Identifiable {
    public let id: UUID
    /// The user's original text, *before* attachment path references are folded in — what the
    /// composer refills when this item is cancelled for editing.
    public var text: String
    /// Files attached to this queued message, already materialized into the working tree (so the
    /// held turn can reference them). Kept so the queued item can show attachment chips and, on
    /// the Mac, restore real chips — not raw `- path` text — when it's cancelled.
    public var attachments: [QueuedAttachment]

    public init(id: UUID = UUID(), text: String, attachments: [QueuedAttachment] = []) {
        self.id = id
        self.text = text
        self.attachments = attachments
    }
}

/// An attachment on a queued message. The bytes already live on disk under the host's working
/// tree (materialized when the message was queued); this just carries enough to render the chip
/// and, on the Mac, reconstruct a composer attachment on cancel. The phone shows the name only —
/// it can't read the host's working tree, so it renders a generic file chip without a thumbnail.
public struct QueuedAttachment: Sendable, Codable, Equatable, Identifiable {
    public let id: UUID
    /// Original display name, e.g. `screenshot.png`.
    public var filename: String
    /// Path to the materialized file, relative to the working-tree root.
    public var relativePath: String

    public init(id: UUID = UUID(), filename: String, relativePath: String) {
        self.id = id
        self.filename = filename
        self.relativePath = relativePath
    }
}
