mirror of
https://github.com/wu736139669/hapi.git
synced 2026-12-05 07:07:04 +00:00
Session rows now match the web sidebar: the second line shows the last two path components, active shares get a "Shared" pill, relative ages read like the H5 list (now, 5 min ago, 10 hours ago, 2 days ago, then a date), and the list font scale reaches 60%. The running spinner is drawn from a timeline instead of ProgressView: UIKit-backed spinners stop animating when a List cell is reconfigured, which read as a spinner that often failed. Working rows also keep their spinner while a pending approval is shown, as on web. Queued-message actions no longer look dead. Cancelling a row the hub reports as `busy` because it is already indeterminate used to restore the row unchanged; it now keeps a `queueDismissed` hold (web #1839), so Cancel and Retry take effect while the durable record stays available for a late consume. Steer is hidden for flavors that cannot take it (agy needs acp, cursor needs acp) via a port of the web steering gate. via [HAPI](https://hapi.run) Co-Authored-By: HAPI <noreply@hapi.run>
55 lines
2.1 KiB
Swift
55 lines
2.1 KiB
Swift
import Foundation
|
|
import Observation
|
|
|
|
/// User-adjustable display sizes, independent of Dynamic Type.
|
|
///
|
|
/// The web sidebar exposes a global font scale and a terminal font size. iOS
|
|
/// keeps the scales app-local and applies the list scale only to the session
|
|
/// list; the code scale applies to terminal-styled output and code blocks.
|
|
@MainActor @Observable
|
|
public final class DisplayPrefs {
|
|
public static let listFontScaleKey = "settings.sessionListFontScale"
|
|
public static let codeFontSizeKey = "settings.codeFontSize"
|
|
|
|
public static let listFontScales: [Double] = [0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3]
|
|
public static let codeFontSizes: [Double] = [9, 11, 13, 15, 17]
|
|
|
|
public static let defaultListFontScale = 1.0
|
|
public static let defaultCodeFontSize = 13.0
|
|
|
|
public private(set) var listFontScale: Double
|
|
public private(set) var codeFontSize: Double
|
|
|
|
private let defaults: UserDefaults
|
|
|
|
public init(defaults: UserDefaults = .standard) {
|
|
self.defaults = defaults
|
|
let storedScale = defaults.object(forKey: Self.listFontScaleKey) as? Double
|
|
self.listFontScale = Self.validScale(storedScale) ?? Self.defaultListFontScale
|
|
let storedCode = defaults.object(forKey: Self.codeFontSizeKey) as? Double
|
|
self.codeFontSize = Self.validCodeSize(storedCode) ?? Self.defaultCodeFontSize
|
|
}
|
|
|
|
public func setListFontScale(_ value: Double) {
|
|
guard let value = Self.validScale(value) else { return }
|
|
listFontScale = value
|
|
defaults.set(value, forKey: Self.listFontScaleKey)
|
|
}
|
|
|
|
public func setCodeFontSize(_ value: Double) {
|
|
guard let value = Self.validCodeSize(value) else { return }
|
|
codeFontSize = value
|
|
defaults.set(value, forKey: Self.codeFontSizeKey)
|
|
}
|
|
|
|
private static func validScale(_ value: Double?) -> Double? {
|
|
guard let value, listFontScales.contains(value) else { return nil }
|
|
return value
|
|
}
|
|
|
|
private static func validCodeSize(_ value: Double?) -> Double? {
|
|
guard let value, codeFontSizes.contains(value) else { return nil }
|
|
return value
|
|
}
|
|
}
|