Files
OSGKeyboard/OSGKeyboardShared/Models/FlowInactivityDuration.swift
T
Rocky cdf833935a feat: harden Flow cold-start/force-quit and polish macOS dictation UX
Fix cold-start overlay recursion that overflowed the main-thread stack when
recording began while the ready overlay was still up; also remove temporary
on-screen Flow DEBUG panels after the orange-mic investigation, and land the
macOS overlay/catalog/layout polish plus related Flow recovery hardening.
2026-07-10 12:39:41 +08:00

52 lines
1.8 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// FlowInactivityDuration.swift
// OSGKeyboard · Shared
//
// User-selectable Flow session inactivity timeout. The timer resets after
// each completed utterance (and on session start).
import Foundation
public enum FlowInactivityDuration: String, CaseIterable, Identifiable, Sendable, Codable {
case tenMinutes = "10m"
case thirtyMinutes = "30m"
case threeHours = "3h"
case twelveHours = "12h"
case twentyFourHours = "24h"
public var id: String { rawValue }
/// 30 minutes, not hours: competitors cap sessions at 560 min for a
/// reason — a very long TTL keeps advertising "session active" long after
/// the host process is likely suspended or dead, amplifying every stale-
/// state bug into hours of confusing UI. Users can still opt into longer
/// windows explicitly.
public static let `default`: FlowInactivityDuration = .thirtyMinutes
public var timeInterval: TimeInterval {
switch self {
case .tenMinutes: return 10 * 60
case .thirtyMinutes: return 30 * 60
case .threeHours: return 3 * 60 * 60
case .twelveHours: return 12 * 60 * 60
case .twentyFourHours: return 24 * 60 * 60
}
}
public var labelKey: String {
switch self {
case .tenMinutes: return "settings.flow.inactivity.10m"
case .thirtyMinutes: return "settings.flow.inactivity.30m"
case .threeHours: return "settings.flow.inactivity.3h"
case .twelveHours: return "settings.flow.inactivity.12h"
case .twentyFourHours: return "settings.flow.inactivity.24h"
}
}
public static func fromStored(_ raw: String?) -> FlowInactivityDuration {
guard let raw, let value = FlowInactivityDuration(rawValue: raw) else {
return .default
}
return value
}
}