import Foundation import Observation public struct Toast: Identifiable, Equatable { public let id = UUID() public var title: String /// A path or reference, shown in mono under the title. public var detail: String? } /// Short confirmations in a corner. They may sit over an overlay; they are not one. @Observable @MainActor public final class ToastStore { public static let lifetime: Duration = .milliseconds(2300) public private(set) var toasts: [Toast] = [] public init() {} public func show(_ title: String, detail: String? = nil) { let toast = Toast(title: title, detail: detail) toasts.append(toast) Task { [weak self] in try? await Task.sleep(for: Self.lifetime) self?.toasts.removeAll { $0.id == toast.id } } } }