Persistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More
TypeScript aiai-agentsai-memoryanthropicartificial-intelligencechromadbclaudeclaude-agent-sdkclaude-agentsclaude-codeclaude-code-pluginclaude-skillsembeddingslong-term-memorymem0memory-engineopenmemoryragsqlitesupermemory
import Foundation
/// How the chat list says when the newest message arrived. Today is a clock
/// time, so two chats from the same hour are not both "2 hours ago". The list
/// itself is newest first; this label is what makes that readable.
public enum ChatActivityLabel {
public static func text(for date: Date, now: Date, calendar: Calendar = .current, locale: Locale = .current) -> String {
var calendar = calendar
calendar.locale = locale
let days = calendar.dateComponents(
[.day], from: calendar.startOfDay(for: date), to: calendar.startOfDay(for: now)
).day ?? 0
if days == 0 { return format(date, time: .short, date: .none, calendar: calendar, locale: locale) }
if days == 1 { return "Yesterday" }
if (2..<7).contains(days) { return format(date, template: "EEE", calendar: calendar, locale: locale) }
return format(date, template: "MMM d", calendar: calendar, locale: locale)
}
private static func format(_ date: Date, time: DateFormatter.Style, date dateStyle: DateFormatter.Style, calendar: Calendar, locale: Locale) -> String {
let formatter = DateFormatter()
formatter.calendar = calendar
formatter.locale = locale
formatter.timeZone = calendar.timeZone
formatter.timeStyle = time
formatter.dateStyle = dateStyle
return formatter.string(from: date)
}
private static func format(_ date: Date, template: String, calendar: Calendar, locale: Locale) -> String {
let formatter = DateFormatter()
formatter.calendar = calendar
formatter.locale = locale
formatter.timeZone = calendar.timeZone
formatter.setLocalizedDateFormatFromTemplate(template)
return formatter.string(from: date)
}
}