v0.27.1 131edba

activity_test.go RawHistoryFolder

1package modes
2
3import (
4	"testing"
5	"time"
6
7	"github.com/bnema/zut/packages/core"
8	"github.com/bnema/zut/packages/provider"
9)
10
11func TestAgentActivityDescribesLifecycle(t *testing.T) {
12	a := newAgentActivity("anthropic", "claude-test")
13	check := func(want string) {
14		t.Helper()
15		if got := a.label(); got != want {
16			t.Fatalf("label = %q, want %q", got, want)
17		}
18	}
19
20	check("Preparing request")
21	a.apply(core.EvRequestStarted{Provider: "anthropic", Model: "claude-test", Scope: core.RetryScopeProvider, Attempt: 1, MaxAttempts: 3})
22	check("Sending request to anthropic")
23	a.apply(core.EvAssistantStart{})
24	check("Waiting for claude-test to respond")
25	a.apply(core.EvTextDelta{Delta: "hello"})
26	check("Receiving response from claude-test")
27	a.apply(core.EvToolUseStart{ID: "one", Name: "read"})
28	check("Preparing tool: read")
29	a.apply(core.EvToolCall{ID: "one", Name: "read"})
30	a.apply(core.EvToolCall{ID: "two", Name: "bash"})
31	a.apply(core.EvToolExecutionStarted{ID: "one", Name: "read"})
32	check("Running tool: read")
33	a.apply(core.EvToolResult{ID: "one", Result: core.ToolResult{}})
34	check("Preparing tool: bash")
35	a.apply(core.EvToolExecutionStarted{ID: "two", Name: "bash"})
36	a.apply(core.EvToolResult{ID: "two", Result: core.ToolResult{}})
37	check("Sending tool results to anthropic")
38	a.apply(core.EvRetryScheduled{Scope: core.RetryScopeAgent, Attempt: 2, MaxAttempts: 4, Delay: 2 * time.Second})
39	check("Retrying request in 2s (attempt 2/4)")
40}
41
42func TestActivityLabelsSanitizeAndFallback(t *testing.T) {
43	a := activity{kind: activitySendingRequest, provider: " \x1b[31mremote\n"}
44	if got, want := a.label(), "Sending request to [31mremote"; got != want {
45		t.Fatalf("sanitized label = %q, want %q", got, want)
46	}
47	a = activity{kind: activityRunningTool}
48	if got, want := a.label(), "Running tool: tool"; got != want {
49		t.Fatalf("fallback label = %q, want %q", got, want)
50	}
51}
52
53func TestAgentActivityIgnoresUnknownToolResult(t *testing.T) {
54	a := newAgentActivity("provider", "model")
55	a.apply(core.EvToolResult{ID: "unknown", Result: core.ToolResult{Content: []provider.Content{provider.TextBlock{Text: "ignored"}}}})
56	if got, want := a.label(), "Preparing request"; got != want {
57		t.Fatalf("label = %q, want %q", got, want)
58	}
59}
60
61func TestAgentActivityClearsDiscardedToolCallsOnAgentRetry(t *testing.T) {
62	a := newAgentActivity("provider", "model")
63	a.apply(core.EvToolCall{ID: "discarded", Name: "stale"})
64	a.apply(core.EvRetryScheduled{Scope: core.RetryScopeAgent, Attempt: 2, MaxAttempts: 2, Delay: time.Millisecond})
65	a.apply(core.EvToolCall{ID: "actual", Name: "read"})
66	a.apply(core.EvToolResult{ID: "actual", Result: core.ToolResult{}})
67
68	if got, want := a.label(), "Sending tool results to provider"; got != want {
69		t.Fatalf("label = %q, want %q", got, want)
70	}
71}

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