Use consistent plain-language snapshot reasons

This commit is contained in:
Ian Gulliver
2026-10-23 15:06:56 -07:00
parent 8b89f14694
commit a53b293528
3 changed files with 17 additions and 2 deletions
+1 -1
View File
@@ -371,7 +371,7 @@ private struct SnapWhere: View {
HStack(spacing: 0) {
Text("snapshot #\(n)")
if let snap {
Text(" · \(snap.trigger.rawValue) · \(clockText(snap.createdAt))")
Text(" · \(snap.reason) · \(clockText(snap.createdAt))")
}
Text(" · ")
step(n - 1, "← #\(n - 1)", snaps)
+1 -1
View File
@@ -1929,7 +1929,7 @@ private struct SnapshotRow: View {
}
.font(Fonts.font(11))
.foregroundStyle(Palette.muted)
.help("\(snap.trigger.rawValue.replacingOccurrences(of: "_", with: " ")) · \(time)")
.help("\(snap.reason) · \(time)")
}
}
+15
View File
@@ -165,6 +165,21 @@ func isoText(_ date: Date) -> String {
date.formatted(Date.ISO8601FormatStyle(includingFractionalSeconds: true))
}
extension Snapshot {
var reason: String {
switch trigger {
case .message: "agent message"
case .turnEnd: "turn ended"
case .toolCall: "tool call"
case .askHuman: "question asked"
case .timer: "periodic snapshot"
case .requested: "snapshot requested"
case .answer: "before delivering an answer"
case .fork: "before forking"
}
}
}
func clockText(_ d: Date) -> String {
d.formatted(Date.VerbatimFormatStyle(format: "\(hour: .twoDigits(clock: .twentyFourHour, hourCycle: .zeroBased)):\(minute: .twoDigits):\(second: .twoDigits)", timeZone: .current, calendar: .current))
}