import CottonKit import CottonValues import Foundation /// What Keep is doing. Two steps, because the first one takes time: the capture /// is linear PCM and a meeting is filed as an AAC `.m4a` encoded from it. enum MeetingKeepStage: Equatable, Sendable { /// The capture is being encoded (`MeetingAudioDelivery`). case finishing /// `meetings.create` is in flight. case filing } /// The sentences and the labels — apart from the view, so what is SAID is /// testable without drawing anything. enum MeetingRecoveryWords { /// What the Keep verb reads while it is working. The two words are the two /// waits, and they are the record sheet's own ("finishing…", "filing…"), /// because Keep does exactly what Stop does. static func keepLabel(_ busy: MeetingKeepStage?) -> String { switch busy { case .none: return ShellLines.line("capture", "recovery.keep") case .finishing: return ShellLines.line("capture", "recovery.finishing") case .filing: return ShellLines.line("capture", "recovery.keeping") } } /// What happened, with the time it happened at. /// /// The time and not the date: a recording nobody saved is found on the next /// launch, which is almost always the same day, and "6:14 pm" is what a /// person recognises. A marker whose stamp will not parse says so instead /// of printing an empty clock. static func headline( _ offer: MeetingRecoveryOffer, calendar: Calendar = .current ) -> String { guard let at = CottonDate.instant(offer.marker.startedAt) else { return ShellLines.line("capture", "recovery.not_saved") } return ShellLines.line("capture", "recovery.not_saved_at", ["time": DateFormats.houseTime(at, calendar: calendar)]) } /// How long it ran, and — when it matters — that it was interrupted. /// /// **The interrupted case is said, not hidden**, and since 16 Sep 2026 it /// is said less grimly: the capture is linear PCM, which a killed process /// leaves readable and with its true length, so what is missing from a /// recording nothing closed is the moment the writer was still holding — /// not the recording. It is still not a whole recording, and the slip says /// so rather than implying the end of the meeting is in there. Offering it while /// implying a transcript is on its way is not. static func detail(_ offer: MeetingRecoveryOffer) -> String { // **The OFFER's length, not the marker's.** The marker's figure is // banked at transitions and is stale for a recording that was killed // while it ran; the offer has already asked the file // (`MeetingRecovery.length(of:probing:)`). It is the same number the // meeting is then created with, so the slip and the row agree. // // And it is `MeetingFacts.durationLabel` — the app's one length // spelling, which says seconds under a minute, because "About 0 min of // it was captured" reads as "there is nothing here" over a file there // is something in. let length = offer.durationMs.flatMap { MeetingFacts.durationLabel(Double($0) / 1000) } let ran = length.map { ShellLines.line("capture", "recovery.captured_about", ["length": $0]) } ?? ShellLines.line("capture", "recovery.captured_some") guard !offer.isPlayable else { return ShellLines.line("capture", "recovery.playable", ["ran": ran]) } return ShellLines.line("capture", "recovery.cut_short", ["ran": ran]) } }