v0.29.0 73d6864

fast_mode_test.go RawHistoryFolder

1package core
2
3import (
4	"context"
5	"strings"
6	"testing"
7
8	"github.com/bnema/zut/packages/provider"
9)
10
11type fastModeTestClient struct {
12	name    string
13	lastReq provider.Request
14	called  bool
15}
16
17func (c *fastModeTestClient) Name() string { return c.name }
18
19func (c *fastModeTestClient) Stream(_ context.Context, req provider.Request) (<-chan provider.Event, error) {
20	c.called = true
21	c.lastReq = req
22	out := make(chan provider.Event, 2)
23	out <- provider.EventTextDelta{Delta: "ok"}
24	out <- provider.EventDone{Stop: provider.StopEnd}
25	close(out)
26	return out, nil
27}
28
29func TestAgentPropagatesFastMode(t *testing.T) {
30	client := &fastModeTestClient{name: "openai"}
31	agent := NewAgent(client, "gpt-5", "", nil)
32	agent.FastMode = true
33
34	if err := agent.Prompt(context.Background(), "hello", nil, nil); err != nil {
35		t.Fatalf("Prompt returned %v", err)
36	}
37	if !client.called {
38		t.Fatal("provider was not called")
39	}
40	if !client.lastReq.FastMode {
41		t.Fatal("request FastMode = false, want true")
42	}
43}
44
45func TestAgentPropagatesFastModeToCompaction(t *testing.T) {
46	client := &fastModeTestClient{name: "openai"}
47	agent := NewAgent(client, "gpt-5", "", nil)
48	agent.FastMode = true
49	agent.SetMessages([]provider.Message{
50		{Role: provider.RoleUser, Content: []provider.Content{provider.TextBlock{Text: "old"}}},
51		{Role: provider.RoleAssistant, Content: []provider.Content{provider.TextBlock{Text: "answer"}}},
52	})
53
54	if _, err := agent.Compact(context.Background(), 1, nil); err != nil {
55		t.Fatalf("Compact returned %v", err)
56	}
57	if !client.lastReq.FastMode {
58		t.Fatal("compaction request FastMode = false, want true")
59	}
60}
61
62func TestAgentRejectsFastModeForNonOpenAIProvider(t *testing.T) {
63	client := &fastModeTestClient{name: "anthropic"}
64	agent := NewAgent(client, "claude-sonnet-4-5", "", nil)
65	agent.FastMode = true
66
67	err := agent.Prompt(context.Background(), "hello", nil, nil)
68	if err == nil || !strings.Contains(err.Error(), "only supported for OpenAI providers") {
69		t.Fatalf("Prompt error = %v, want unsupported-provider error", err)
70	}
71	if client.called {
72		t.Fatal("provider was called despite unsupported fast mode")
73	}
74}
75
76func TestAgentRejectsFastModeForNonOpenAIProviderDuringCompaction(t *testing.T) {
77	client := &fastModeTestClient{name: "anthropic"}
78	agent := NewAgent(client, "claude-sonnet-4-5", "", nil)
79	agent.FastMode = true
80	agent.SetMessages([]provider.Message{
81		{Role: provider.RoleUser, Content: []provider.Content{provider.TextBlock{Text: "old"}}},
82		{Role: provider.RoleAssistant, Content: []provider.Content{provider.TextBlock{Text: "answer"}}},
83	})
84
85	_, err := agent.Compact(context.Background(), 1, nil)
86	if err == nil || !strings.Contains(err.Error(), "only supported for OpenAI providers") {
87		t.Fatalf("Compact error = %v, want unsupported-provider error", err)
88	}
89	if client.called {
90		t.Fatal("provider was called despite unsupported fast mode")
91	}
92}

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