v0.1.24 ec79818

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

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 477

↑↓ moveenter openesc close