import Foundation

/// One line of a running `mac_vm_exec` command's captured output, mirrored into a small per-VM ring
/// while the guest works headless so the live monitor can show a scrolling tail under its screen.
///
/// The monitor's "Working in the background…" overlay tells the user the guest is busy even though its
/// framebuffer is static; this carries *what* it's busy doing. Value type so it crosses the actor
/// boundary from the engine (writer) to the SwiftUI monitor (reader) freely. `id` is a per-VM monotonic
/// sequence number — stable across the rolling window, so `ForEach` diffs cleanly and the console can
/// auto-scroll to the newest line.
public struct MacVMLogLine: Sendable, Identifiable, Equatable {
    /// Which of the command's streams a line came from — drives the console's per-line color so stderr
    /// and the command echo stand apart from ordinary stdout.
    public enum Kind: Sendable, Equatable {
        case stdout
        case stderr
        /// A synthetic `$ <command>` echo written when a new exec starts, so back-to-back commands
        /// don't blur together in the rolling tail.
        case command
    }

    public let id: Int
    public let kind: Kind
    public let text: String

    public init(id: Int, kind: Kind, text: String) {
        self.id = id
        self.kind = kind
        self.text = text
    }
}
