v0.2.14 63e33d9

view_tool_overlay_test.go RawHistoryFolder

1package tui
2
3import (
4	"encoding/json"
5	"strings"
6	"testing"
7
8	"github.com/patriceckhart/zot/packages/provider"
9)
10
11func TestLiveToolOverlayRemainsAfterAssistantToolUse(t *testing.T) {
12	args := json.RawMessage(`{"command":"sleep 1"}`)
13	v := View{
14		Theme: Dark,
15		Messages: []provider.Message{
16			{
17				Role: provider.RoleAssistant,
18				Content: []provider.Content{
19					provider.ToolCallBlock{ID: "toolu_1", Name: "bash", Arguments: args},
20				},
21			},
22		},
23		ToolCalls: []ToolCallView{
24			{ID: "toolu_1", Name: "bash", Args: ShortArgs("bash", args), Done: false},
25		},
26	}
27
28	plain := stripANSI(strings.Join(v.Build(80), "\n"))
29	if !strings.Contains(plain, "bash sleep 1") {
30		t.Fatalf("live tool overlay disappeared after assistant tool_use was appended:\n%s", plain)
31	}
32}
33
34func TestLiveToolOverlayKeepsWritePreviewAfterArgsEnd(t *testing.T) {
35	args := json.RawMessage(`{"path":"/tmp/sample.ts","content":"export const n = 1\n"}`)
36	v := View{
37		Theme: Dark,
38		Messages: []provider.Message{
39			{
40				Role: provider.RoleAssistant,
41				Content: []provider.Content{
42					provider.ToolCallBlock{ID: "toolu_1", Name: "write", Arguments: args},
43				},
44			},
45		},
46		ToolCalls: []ToolCallView{
47			{
48				ID:         "toolu_1",
49				Name:       "write",
50				Args:       ShortArgs("write", args),
51				Streaming:  false,
52				RawJSONBuf: string(args),
53				LivePath:   "/tmp/sample.ts",
54			},
55		},
56	}
57
58	plain := stripANSI(strings.Join(v.Build(80), "\n"))
59	if !strings.Contains(plain, "export const n = 1") {
60		t.Fatalf("write preview collapsed after tool args ended but before tool_result arrived:\n%s", plain)
61	}
62}
63
64func TestLiveToolOverlayHidesAfterToolResult(t *testing.T) {
65	args := json.RawMessage(`{"command":"sleep 1"}`)
66	v := View{
67		Theme: Dark,
68		Messages: []provider.Message{
69			{
70				Role: provider.RoleAssistant,
71				Content: []provider.Content{
72					provider.ToolCallBlock{ID: "toolu_1", Name: "bash", Arguments: args},
73				},
74			},
75			{
76				Role: provider.RoleTool,
77				Content: []provider.Content{
78					provider.ToolResultBlock{
79						CallID:  "toolu_1",
80						Content: []provider.Content{provider.TextBlock{Text: "done"}},
81					},
82				},
83			},
84		},
85		ToolCalls: []ToolCallView{
86			{ID: "toolu_1", Name: "bash", Args: ShortArgs("bash", args), Result: "done", Done: true},
87		},
88	}
89
90	plain := stripANSI(strings.Join(v.BuildLive(80), "\n"))
91	if strings.Contains(plain, "bash sleep 1") {
92		t.Fatalf("live tool overlay still rendered after tool_result was appended:\n%s", plain)
93	}
94}

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