feat(sessions): keep every session, record review details, name and stamp the PDF
Sessions are now the unit of the product instead of an implicit capture run. - Nothing is deleted by default: the fixed 10-session cap is gone. An age limit (Never / 7 / 14 / 30 / 90 / 180 / 365 days) is chosen in Settings > Sessions and applied on launch, after archiving, and by "Clean up now". Sent PDFs are never touched. - Each session carries review details: lane, deployed version, commit, reviewer (pre-filled with the Mac user) and a free note. They persist in session.json and are inherited by the next session, so a review run is typed once. - PDF file names are Redline-<yyyyMMdd-HHmm>-<LANE>-<SHORTID>.pdf, and every page carries a two-line reference footer (tool, build time, session / lane, deployed build, commit, reviewer, note). The PDF document info carries the same values in Author and Keywords. - Verification: 159 tests, a headless panel self-test, and a LaunchServices-driven end-to-end run that types and clicks the real panel.
This commit is contained in:
@@ -3,7 +3,11 @@ import Foundation
|
||||
public enum DubaiTime {
|
||||
private static let stampFormatter = LockedDateFormatter(dateFormat: "d MMM yyyy, HH:mm 'Dubai'")
|
||||
private static let fileStampFormatter = LockedDateFormatter(dateFormat: "yyyyMMdd-HHmmss")
|
||||
private static let fileMinuteStampFormatter = LockedDateFormatter(dateFormat: "yyyyMMdd-HHmm")
|
||||
private static let checkTimeFormatter = LockedDateFormatter(dateFormat: "HH:mm 'Dubai'")
|
||||
private static let shortStampFormatter = LockedDateFormatter(dateFormat: "d MMM yyyy, HH:mm")
|
||||
private static let dayStampFormatter = LockedDateFormatter(dateFormat: "d MMM yyyy")
|
||||
private static let keywordStampFormatter = LockedDateFormatter(dateFormat: "yyyy-MM-dd HH:mm 'Dubai'")
|
||||
|
||||
public static func stamp(_ date: Date) -> String {
|
||||
stampFormatter.string(from: date)
|
||||
@@ -13,6 +17,28 @@ public enum DubaiTime {
|
||||
fileStampFormatter.string(from: date)
|
||||
}
|
||||
|
||||
/// `yyyyMMdd-HHmm` — used in PDF file names where minutes are the useful detail.
|
||||
public static func fileMinuteStamp(_ date: Date) -> String {
|
||||
fileMinuteStampFormatter.string(from: date)
|
||||
}
|
||||
|
||||
/// "31 Oct 2026, 10:31" — compact session-list timestamp (the timezone is stated
|
||||
/// once in the list header, not on every row).
|
||||
public static func shortStamp(_ date: Date) -> String {
|
||||
shortStampFormatter.string(from: date)
|
||||
}
|
||||
|
||||
/// "31 Oct 2026" — for day-granular expiry notices.
|
||||
public static func dayStamp(_ date: Date) -> String {
|
||||
dayStampFormatter.string(from: date)
|
||||
}
|
||||
|
||||
/// "2026-10-31 11:00 Dubai" — for PDF keywords, where a comma would be read as a
|
||||
/// keyword separator by the PDF format itself.
|
||||
public static func keywordStamp(_ date: Date) -> String {
|
||||
keywordStampFormatter.string(from: date)
|
||||
}
|
||||
|
||||
public static func checkTime(_ date: Date) -> String {
|
||||
checkTimeFormatter.string(from: date)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
import Foundation
|
||||
|
||||
/// How long Redline keeps a past session's captured screenshots.
|
||||
///
|
||||
/// The default is `.never`: every session is saved and nothing is deleted unless the
|
||||
/// user picks an age limit in Settings. Session folders are the only thing an age
|
||||
/// policy ever removes — a PDF that was already sent stays in the folder it went to.
|
||||
public enum SessionRetention: Sendable, Equatable, Hashable {
|
||||
case never
|
||||
case days(Int)
|
||||
|
||||
/// The one list Settings offers, in display order. `nil` day counts never expire.
|
||||
public static let presets: [SessionRetention] = [
|
||||
.never, .days(7), .days(14), .days(30), .days(90), .days(180), .days(365),
|
||||
]
|
||||
|
||||
public var dayCount: Int? {
|
||||
switch self {
|
||||
case .never: return nil
|
||||
case .days(let count): return count
|
||||
}
|
||||
}
|
||||
|
||||
/// "Never (default)", "7 days", "30 days", "1 year".
|
||||
public var displayName: String {
|
||||
switch self {
|
||||
case .never: return "Never (default)"
|
||||
case .days(365): return "1 year"
|
||||
case .days(let count): return "\(count) days"
|
||||
}
|
||||
}
|
||||
|
||||
/// Caption for the Settings row and the panel footer: what actually happens.
|
||||
public var policyDescription: String {
|
||||
switch self {
|
||||
case .never: return "All sessions kept."
|
||||
case .days(365): return "Sessions older than 1 year are deleted."
|
||||
case .days(let count): return "Sessions older than \(count) days are deleted."
|
||||
}
|
||||
}
|
||||
|
||||
/// Sessions created before this instant are expired; nil means nothing expires.
|
||||
public func cutoff(now: Date = Date()) -> Date? {
|
||||
guard let dayCount else { return nil }
|
||||
return Calendar(identifier: .gregorian).date(byAdding: .day, value: -dayCount, to: now)
|
||||
}
|
||||
}
|
||||
|
||||
/// Persistence for the age limit, backed by UserDefaults.
|
||||
///
|
||||
/// Stored as a day count; 0 (or no stored value at all) means `never`. A stored value
|
||||
/// is only ever written by `save`, so an absent key is the honest "user never chose"
|
||||
/// state, not a hidden default.
|
||||
public enum RetentionSettings {
|
||||
public static let defaultsKey = "ai.flowmaster.shotdeck.sessionRetentionDays"
|
||||
|
||||
public static func load(defaults: UserDefaults = .standard) -> SessionRetention {
|
||||
guard let stored = defaults.object(forKey: defaultsKey) as? Int else { return .never }
|
||||
return stored > 0 ? .days(stored) : .never
|
||||
}
|
||||
|
||||
public static func save(_ value: SessionRetention, defaults: UserDefaults = .standard) {
|
||||
guard let dayCount = value.dayCount else {
|
||||
defaults.removeObject(forKey: defaultsKey)
|
||||
return
|
||||
}
|
||||
defaults.set(dayCount, forKey: defaultsKey)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user