v0.29.0 73d6864

usage.go RawHistoryFolder

1package tui
2
3import (
4	"fmt"
5
6	"github.com/bnema/zut/packages/provider"
7)
8
9// UsageStatsParams describes cumulative usage shown by compact status surfaces.
10type UsageStatsParams struct {
11	Usage        provider.Usage
12	Subscription bool
13}
14
15// UsageStatsParts returns compact, provider-neutral token and cost labels.
16func UsageStatsParts(p UsageStatsParams) []string {
17	var parts []string
18	if p.Usage.InputTokens > 0 {
19		parts = append(parts, fmt.Sprintf("↑%s", formatTokens(p.Usage.InputTokens)))
20	}
21	if p.Usage.OutputTokens > 0 {
22		parts = append(parts, fmt.Sprintf("↓%s", formatTokens(p.Usage.OutputTokens)))
23	}
24	if p.Usage.CacheReadTokens > 0 {
25		parts = append(parts, fmt.Sprintf("R%s/", formatTokens(p.Usage.CacheReadTokens)))
26	}
27	if ratio, ok := p.Usage.CacheHitRatio(); ok {
28		parts = append(parts, fmt.Sprintf("C%.1f%%", ratio*100))
29	}
30	if p.Usage.CacheWriteTokens > 0 {
31		parts = append(parts, fmt.Sprintf("W%s", formatTokens(p.Usage.CacheWriteTokens)))
32	}
33	if p.Usage.CostUSD > 0 || p.Subscription {
34		cost := fmt.Sprintf("$%.3f", p.Usage.CostUSD)
35		if p.Subscription {
36			cost += " (sub)"
37		}
38		parts = append(parts, cost)
39	}
40	return parts
41}
42
43// ContextUsageText returns the latest request's context utilization without
44// styling so callers can safely measure, truncate, and color the whole line.
45func ContextUsageText(used, max int) string {
46	label, _ := contextUsage(Theme{}, used, max)
47	return label
48}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 476

↑↓ moveenter openesc close