v0.50.0 c4ec31f

tool_gate_test.go RawHistoryFolder

1package modes
2
3import (
4	"strings"
5	"testing"
6)
7
8// drainTicks paints n pacer ticks worth of text.
9func drainTicks(s *streamPresenter, n int) {
10	for range n {
11		s.Tick()
12	}
13}
14
15// A tool that arrives while paced text is still buffered stays hidden until
16// the pacer has painted the text that preceded it.
17func TestToolGateHoldsToolUntilTextDrains(t *testing.T) {
18	var s streamPresenter
19	s.Start(-1, 0)
20	s.Push(strings.Repeat("a", 30))
21	s.Tick() // paints paintPaceRate runes
22
23	s.Gate("t1")
24	if s.GateOpen("t1") {
25		t.Fatal("tool visible before the preceding text was painted")
26	}
27	for s.paintedRunes < 30 {
28		if s.GateOpen("t1") {
29			t.Fatalf("tool visible at %d/30 painted runes", s.paintedRunes)
30		}
31		s.Tick()
32	}
33	if !s.GateOpen("t1") {
34		t.Fatal("tool still hidden after the preceding text was painted")
35	}
36}
37
38// Without live text a tool shows immediately.
39func TestToolGateOpenWhenNotStreaming(t *testing.T) {
40	var s streamPresenter
41	s.Gate("t1")
42	if !s.GateOpen("t1") {
43		t.Fatal("tool hidden while no text is streaming")
44	}
45}
46
47// First registration wins: a later EvToolCall must not move the gate.
48func TestToolGateFirstRegistrationWins(t *testing.T) {
49	var s streamPresenter
50	s.Start(-1, 0)
51	s.Push("0123456789")
52	s.Gate("t1")
53	first := s.gates["t1"]
54	s.Push("more text")
55	s.Gate("t1")
56	if s.gates["t1"] != first {
57		t.Fatalf("gate moved from %d to %d", first, s.gates["t1"])
58	}
59}
60
61// Once the stream finishes, every gate is open again.
62func TestToolGatesOpenAfterStreamEnds(t *testing.T) {
63	var s streamPresenter
64	s.Start(-1, 0)
65	s.Push("0123456789")
66	s.Gate("t1")
67	s.Finish()
68	drainTicks(&s, 10)
69	if s.Active() {
70		t.Fatal("stream still active after draining")
71	}
72	if !s.GateOpen("t1") {
73		t.Fatal("tool re-hidden after the stream ended")
74	}
75}

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