v0.50.0 c4ec31f

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, Message: provider.Message{
25		Role:    provider.RoleAssistant,
26		Content: []provider.Content{provider.TextBlock{Text: "ok"}},
27	}}
28	close(out)
29	return out, nil
30}
31
32func TestAgentPropagatesFastMode(t *testing.T) {
33	client := &fastModeTestClient{name: "openai"}
34	agent := NewAgent(client, "gpt-5", "", nil)
35	agent.FastMode = true
36
37	if err := agent.Prompt(context.Background(), "hello", nil, nil); err != nil {
38		t.Fatalf("Prompt returned %v", err)
39	}
40	if !client.called {
41		t.Fatal("provider was not called")
42	}
43	if !client.lastReq.FastMode {
44		t.Fatal("request FastMode = false, want true")
45	}
46}
47
48func TestAgentPropagatesFastModeToCompaction(t *testing.T) {
49	client := &fastModeTestClient{name: "openai"}
50	agent := NewAgent(client, "gpt-5", "", nil)
51	agent.FastMode = true
52	agent.SetMessages([]provider.Message{
53		{Role: provider.RoleUser, Content: []provider.Content{provider.TextBlock{Text: "old"}}},
54		{Role: provider.RoleAssistant, Content: []provider.Content{provider.TextBlock{Text: "answer"}}},
55	})
56
57	if _, err := agent.Compact(context.Background(), 1, nil); err != nil {
58		t.Fatalf("Compact returned %v", err)
59	}
60	if !client.lastReq.FastMode {
61		t.Fatal("compaction request FastMode = false, want true")
62	}
63}
64
65func TestAgentRejectsFastModeForNonOpenAIProvider(t *testing.T) {
66	client := &fastModeTestClient{name: "anthropic"}
67	agent := NewAgent(client, "claude-sonnet-4-5", "", nil)
68	agent.FastMode = true
69
70	err := agent.Prompt(context.Background(), "hello", nil, nil)
71	if err == nil || !strings.Contains(err.Error(), "only supported for OpenAI providers") {
72		t.Fatalf("Prompt error = %v, want unsupported-provider error", err)
73	}
74	if client.called {
75		t.Fatal("provider was called despite unsupported fast mode")
76	}
77}
78
79func TestAgentRejectsFastModeForNonOpenAIProviderDuringCompaction(t *testing.T) {
80	client := &fastModeTestClient{name: "anthropic"}
81	agent := NewAgent(client, "claude-sonnet-4-5", "", nil)
82	agent.FastMode = true
83	agent.SetMessages([]provider.Message{
84		{Role: provider.RoleUser, Content: []provider.Content{provider.TextBlock{Text: "old"}}},
85		{Role: provider.RoleAssistant, Content: []provider.Content{provider.TextBlock{Text: "answer"}}},
86	})
87
88	_, err := agent.Compact(context.Background(), 1, nil)
89	if err == nil || !strings.Contains(err.Error(), "only supported for OpenAI providers") {
90		t.Fatalf("Compact error = %v, want unsupported-provider error", err)
91	}
92	if client.called {
93		t.Fatal("provider was called despite unsupported fast mode")
94	}
95}

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