usageStatus formats the session's cumulative token usage for the status line. Empty when no calls have been made or no UsageFunc was wired.
()
| 1163 | // usageStatus formats the session's cumulative token usage for the status |
| 1164 | // line. Empty when no calls have been made or no UsageFunc was wired. |
| 1165 | func (m harness) usageStatus() string { |
| 1166 | if m.usageFunc == nil { |
| 1167 | return "" |
| 1168 | } |
| 1169 | u, cost := m.usageFunc() |
| 1170 | if u.InputTokens == 0 && u.OutputTokens == 0 { |
| 1171 | return "" |
| 1172 | } |
| 1173 | parts := []string{ |
| 1174 | fmt.Sprintf("%s in", formatThousands(u.InputTokens)), |
| 1175 | fmt.Sprintf("%s out", formatThousands(u.OutputTokens)), |
| 1176 | } |
| 1177 | if u.CacheCreationTokens > 0 || u.CacheReadTokens > 0 { |
| 1178 | parts = append(parts, fmt.Sprintf("cache %s/%s", |
| 1179 | formatThousands(u.CacheCreationTokens), |
| 1180 | formatThousands(u.CacheReadTokens))) |
| 1181 | } |
| 1182 | if cost >= 0 { |
| 1183 | parts = append(parts, fmt.Sprintf("~$%.4f", cost)) |
| 1184 | } |
| 1185 | return strings.Join(parts, " · ") |
| 1186 | } |
| 1187 | |
| 1188 | // formatThousands inserts thousands separators into a non-negative int. |
| 1189 | // Mirrors the helper in commands.go; lives here too to avoid a UI → main |
no test coverage detected