okami.mom/albedo
git clone https://git.nkp.pet/okami.mom/albedo
61c43ca
main
1// Package presentation formats session metadata for terminal displays. 2package presentation 3 4import ( 5"fmt" 6"regexp" 7"time" 8) 9 10var sanitizerRegex = regexp .MustCompile (`[\p{Cc}\x{202a}-\x{202e}\x{2066}-\x{2069}]` ) 11 12// SessionText replaces control characters and direction overrides in session metadata. 13func SessionText (text string )string {return sanitizerRegex .ReplaceAllString (text ," " ) } 14 15func AssistantAge (timestamp * int64 ,now time.Time )string { 16if timestamp == nil { 17return "time unknown" 18 } 19elapsedSeconds := max (0 ,now .Unix ()-* timestamp ) 20if elapsedSeconds < 60 { 21return "just now" 22 } 23if elapsedSeconds < 3600 { 24return fmt .Sprintf ("%dm ago" ,elapsedSeconds / 60 ) 25 } 26if elapsedSeconds < 86400 { 27return fmt .Sprintf ("%dh ago" ,elapsedSeconds / 3600 ) 28 } 29return fmt .Sprintf ("%dd ago" ,elapsedSeconds / 86400 ) 30}