v0.3.96 c5883a4

cost.go RawHistoryFolder

1package core
2
3import "github.com/patriceckhart/zot/packages/provider"
4
5// CostTracker accumulates usage across turns in a session.
6//
7// Total is the cumulative usage shown in the status bar's "$x.xx"
8// readout. LastTurn is the per-turn usage of the most recent
9// completed turn; the TUI uses LastTurn.InputTokens+cache as a
10// proxy for "current context size" so the X%/Ymax gauge tracks the
11// prompt size that just went to the model.
12type CostTracker struct {
13	Total    provider.Usage
14	LastTurn provider.Usage
15	hasTotal bool
16}
17
18// Add folds u into the running total, records u as the last-turn
19// snapshot, and returns the new cumulative value.
20func (c *CostTracker) Add(u provider.Usage) provider.Usage {
21	if c.hasTotal {
22		c.Total = c.Total.Add(u)
23	} else {
24		c.Total = u
25		c.hasTotal = true
26	}
27	c.LastTurn = u
28	return c.Total
29}
30
31// Seed replaces the running total with usage restored from a session.
32func (c *CostTracker) Seed(u provider.Usage) {
33	c.Total = u
34	c.hasTotal = u.InputTokens != 0 || u.OutputTokens != 0 || u.CacheReadTokens != 0 || u.CacheWriteTokens != 0 || u.CostUSD != 0
35}

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