v0.0.23 74709a0

spinner.go RawHistoryFolder

1package modes
2
3import (
4	"math/rand"
5	"time"
6)
7
8// spinner drives the busy animation shown in the status bar while a
9// turn is streaming. It rotates through a list of playful status
10// messages and a small frame animation.
11type spinner struct {
12	frames    []string
13	messages  []string
14	startedAt time.Time
15	msgIdx    int
16	lastSwap  time.Time
17
18	// fixedMsg overrides the rotating funnyWorkingLines message when
19	// set. Used for auto-compaction so the spinner clearly says what's
20	// happening instead of cycling jokes.
21	fixedMsg string
22}
23
24// funnyWorkingLines is the rotating text. Kept deliberately short so it
25// fits next to the token counter on narrow terminals. A handful of
26// craftsman-style aphorisms are folded in among the irreverent lines
27// for a bit of contrast — the rotation never feels too uniform.
28var funnyWorkingLines = []string{
29	"thinking",
30	"reticulating splines",
31	"bribing the tokenizer",
32	"asking the rubber duck",
33	"summoning daemons",
34	"consulting the oracle",
35	"herding tokens",
36	"compiling excuses",
37	"poking the model",
38	"negotiating with rate limits",
39	"picking a fight with syntax",
40	"reading between the bits",
41	"tasting the semicolons",
42	"pretending to understand go generics",
43	"petting the cache",
44	"drafting clever replies",
45	"warming up the GPU choir",
46	"arguing with a stack trace",
47	"googling the answer (not really)",
48	"rewriting history",
49	"every draft is a stone in the work",
50	"bringing order to the unhewn",
51	"finding the load-bearing measure",
52	"where clarity grows, work grows lighter",
53	"every correction serves the work",
54}
55
56// spinnerFrames is the cli-spinners "dots3" preset — a 10-frame
57// single-cell braille spinner that reads as a small box of dots
58// rotating around its perimeter. Source:
59// https://github.com/sindresorhus/cli-spinners (MIT). Used at the
60// preset's recommended 80ms per step.
61var spinnerFrames = []string{
62	"⠋",
63	"⠙",
64	"⠚",
65	"⠞",
66	"⠖",
67	"⠦",
68	"⠴",
69	"⠲",
70	"⠳",
71	"⠓",
72}
73
74// newSpinner constructs a fresh spinner.
75func newSpinner() *spinner {
76	s := &spinner{
77		frames:   spinnerFrames,
78		messages: funnyWorkingLines,
79	}
80	return s
81}
82
83// Start resets the spinner to the beginning of its animation and picks
84// a random opening message.
85func (s *spinner) Start() {
86	s.startedAt = time.Now()
87	s.msgIdx = rand.Intn(len(s.messages))
88	s.lastSwap = s.startedAt
89	s.fixedMsg = ""
90}
91
92// StartFixed is like Start but pins the status text to msg for the
93// duration of this spinner run. Cleared by the next Start() call.
94func (s *spinner) StartFixed(msg string) {
95	s.startedAt = time.Now()
96	s.lastSwap = s.startedAt
97	s.fixedMsg = msg
98}
99
100// Frame returns the current spinner glyph for the running animation.
101//
102// 80ms per step matches the dots3 preset's recommended interval.
103func (s *spinner) Frame() string {
104	if s.startedAt.IsZero() {
105		return s.frames[0]
106	}
107	elapsed := time.Since(s.startedAt)
108	idx := int(elapsed/(80*time.Millisecond)) % len(s.frames)
109	return s.frames[idx]
110}
111
112// Message returns the current rotating status text. The text changes
113// every ~2.5 seconds so the spinner doesn't look frozen. When the
114// spinner was started via StartFixed, the pinned message is returned
115// unchanged.
116func (s *spinner) Message() string {
117	if s.fixedMsg != "" {
118		return s.fixedMsg
119	}
120	if time.Since(s.lastSwap) > 2500*time.Millisecond {
121		s.msgIdx = (s.msgIdx + 1) % len(s.messages)
122		s.lastSwap = time.Now()
123	}
124	return s.messages[s.msgIdx]
125}
126
127// Elapsed returns the wall-clock duration the spinner has been running.
128func (s *spinner) Elapsed() time.Duration {
129	if s.startedAt.IsZero() {
130		return 0
131	}
132	return time.Since(s.startedAt).Round(time.Second)
133}

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