mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
cb51cf7d3e
* feat(apps): adopt the system-notice family in Apple chat (OpenClawChatUI) Decode internal_system provenance and __openclaw history markers, classify once into message/notice/divider rows (web-parity kinds), render minimal hairline notice/divider SwiftUI rows, preserve metadata through history reconciliation, live transport, and the transcript cache, and align the transcript exporter with visible classification instead of leaking raw [System] prompts. * fix(apps): satisfy OpenClawKit periphery gate Remove the dead visibleMessages projection (rows path replaced its consumers) and annotate the provenance test-fixture initializer with the repo-standard periphery:ignore rationale. * fix(apps): refresh native i18n inventory after periphery cleanup
24 lines
845 B
Swift
24 lines
845 B
Swift
import Foundation
|
|
|
|
enum ChatCompactTokenCountFormatter {
|
|
static func string(_ tokens: Double) -> String {
|
|
if tokens >= 1_000_000 {
|
|
return "\(self.oneDecimal(tokens / 1_000_000))M"
|
|
}
|
|
if tokens >= 1000 {
|
|
let thousands = self.oneDecimal(tokens / 1000)
|
|
if Double(thousands) ?? 0 >= 1000 {
|
|
return "\(self.oneDecimal(tokens / 1_000_000))M"
|
|
}
|
|
return "\(thousands)k"
|
|
}
|
|
return String(Int(tokens))
|
|
}
|
|
|
|
private static func oneDecimal(_ value: Double) -> String {
|
|
let rounded = (value * 10).rounded(.toNearestOrAwayFromZero) / 10
|
|
let formatted = String(format: "%.1f", locale: Locale(identifier: "en_US_POSIX"), rounded)
|
|
return formatted.hasSuffix(".0") ? String(formatted.dropLast(2)) : formatted
|
|
}
|
|
}
|