v0.1.66 9035106

statusbar_test.go RawHistoryFolder

1package tui
2
3import (
4	"strings"
5	"testing"
6
7	"github.com/patriceckhart/zot/internal/provider"
8)
9
10// TestStatusBarAlwaysTwoLines verifies the status bar always emits
11// two lines when a cwd is present, regardless of terminal width, and
12// that the cwd is indented with the 2-space pad so it lines up under
13// the "(provider)" column on line 1.
14func TestStatusBarAlwaysTwoLines(t *testing.T) {
15	// Wide terminal that would previously combine into one line.
16	lines := StatusBar(StatusBarParams{
17		Theme:    Dark,
18		Provider: "anthropic",
19		Model:    "claude-opus-4-7",
20		CWD:      "/tmp/x",
21		Usage: provider.Usage{
22			InputTokens:  476_000,
23			OutputTokens: 3_400,
24			CostUSD:      1.242,
25		},
26		Subscription: true,
27		ContextUsed:  55_000,
28		ContextMax:   1_000_000,
29		Cols:         500, // very wide
30	})
31	if len(lines) != 2 {
32		t.Fatalf("want 2 lines, got %d: %q", len(lines), lines)
33	}
34	if !strings.Contains(lines[0], "claude-opus-4-7") {
35		t.Errorf("line 1 should contain model, got %q", lines[0])
36	}
37	// Line 2 must start with 2-space indent.
38	if !strings.HasPrefix(lines[1], "  ") {
39		t.Errorf("line 2 should start with 2-space indent, got %q", lines[1])
40	}
41	if !strings.Contains(lines[1], "/tmp/x") {
42		t.Errorf("line 2 should contain cwd, got %q", lines[1])
43	}
44}
45
46// TestStatusBarNoCWD verifies an empty cwd stays single-line.
47func TestStatusBarNoCWD(t *testing.T) {
48	lines := StatusBar(StatusBarParams{
49		Theme:    Dark,
50		Provider: "openai",
51		Model:    "gpt-5.4",
52		CWD:      "",
53		Cols:     200,
54	})
55	if len(lines) != 1 {
56		t.Fatalf("empty cwd: want 1 line, got %d: %q", len(lines), lines)
57	}
58}
59
60func TestStatusBarNoYoloTagPrecedesCWD(t *testing.T) {
61	lines := StatusBar(StatusBarParams{
62		Theme:    Dark,
63		Provider: "openai",
64		Model:    "gpt-5.5",
65		CWD:      "/tmp/x",
66		NoYolo:   true,
67		Cols:     200,
68	})
69	if len(lines) != 2 {
70		t.Fatalf("want 2 lines, got %d: %q", len(lines), lines)
71	}
72	plain := stripANSI(lines[1])
73	if !strings.Contains(plain, "yolo mode disabled - /tmp/x") {
74		t.Fatalf("cwd line should include no-yolo tag before cwd, got %q", plain)
75	}
76}

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