main 4509ec7

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	Compact      bool // main status bar; detailed surfaces retain billing labels and precision
14}
15
16// UsageStatsParts returns compact, provider-neutral token and cost labels.
17func UsageStatsParts(p UsageStatsParams) []string {
18	var parts []string
19	if p.Usage.InputTokens > 0 {
20		parts = append(parts, fmt.Sprintf("↑%s", formatTokens(p.Usage.InputTokens)))
21	}
22	if p.Usage.OutputTokens > 0 {
23		parts = append(parts, fmt.Sprintf("↓%s", formatTokens(p.Usage.OutputTokens)))
24	}
25	if p.Usage.CacheReadTokens > 0 {
26		read := "R" + formatTokens(p.Usage.CacheReadTokens)
27		if !p.Compact {
28			read += "/"
29		}
30		parts = append(parts, read)
31	}
32	if ratio, ok := p.Usage.CacheHitRatio(); ok {
33		precision := 1
34		if p.Compact {
35			precision = 0
36		}
37		parts = append(parts, fmt.Sprintf("C%.*f%%", precision, ratio*100))
38	}
39	if p.Usage.CacheWriteTokens > 0 {
40		parts = append(parts, fmt.Sprintf("W%s", formatTokens(p.Usage.CacheWriteTokens)))
41	}
42	if p.Usage.CostUSD > 0 || p.Subscription {
43		precision := 3
44		if p.Compact {
45			precision = 2
46		}
47		cost := fmt.Sprintf("$%.*f", precision, p.Usage.CostUSD)
48		if p.Subscription && !p.Compact {
49			cost += " (sub)"
50		}
51		parts = append(parts, cost)
52	}
53	return parts
54}
55
56// ContextUsageText returns the latest request's context utilization without
57// styling so callers can safely measure, truncate, and color the whole line.
58func ContextUsageText(used, max int) string {
59	label, _ := contextUsage(Theme{}, used, max)
60	return label
61}

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