v0.29.1 d92a60f

interactive_host_test.go RawHistoryFolder

1package modes
2
3import (
4	"os"
5	"path/filepath"
6	"testing"
7
8	"github.com/bnema/zut/packages/agent/internal/orchestration"
9	"github.com/bnema/zut/packages/agent/subagents"
10	"github.com/bnema/zut/packages/core"
11	"github.com/bnema/zut/packages/provider"
12)
13
14func TestApplySessionAgentWithCWDRebindsInteractiveWorkspace(t *testing.T) {
15	oldCWD := t.TempDir()
16	newCWD := filepath.Join(t.TempDir(), "selected-workspace")
17	if err := os.MkdirAll(newCWD, 0o755); err != nil {
18		t.Fatal(err)
19	}
20	current := core.NewAgent(nil, "model", "", nil)
21	selected := core.NewAgent(nil, "model", "", nil)
22	selected.SetMessages([]provider.Message{{Role: provider.RoleUser, Content: []provider.Content{provider.TextBlock{Text: "selected"}}}})
23	i := NewInteractive(InteractiveConfig{Agent: current, CWD: oldCWD, StartupContextPaths: []string{filepath.Join(oldCWD, "AGENTS.md")}})
24	i.view.StartupContextPaths = []string{filepath.Join(oldCWD, "AGENTS.md")}
25	i.ApplySessionAgentWithCWD(selected, "provider", "model", newCWD, nil)
26	if i.cfg.CWD != newCWD || i.agent != selected {
27		t.Fatalf("interactive workspace = %q agent=%p, want cwd=%q agent=%p", i.cfg.CWD, i.agent, newCWD, selected)
28	}
29	if len(i.cfg.StartupContextPaths) != 0 || len(i.view.StartupContextPaths) != 0 {
30		t.Fatalf("old workspace paths remained: cfg=%q view=%q", i.cfg.StartupContextPaths, i.view.StartupContextPaths)
31	}
32	text, _ := i.view.Messages[0].Content[0].(provider.TextBlock)
33	if text.Text != "selected" {
34		t.Fatalf("resumed view text = %q", text.Text)
35	}
36}
37
38func TestCanResumeSessionSelectionRejectsBusyTurn(t *testing.T) {
39	i := NewInteractive(InteractiveConfig{Agent: core.NewAgent(nil, "model", "", nil), LoadSession: func(string) error { return nil }})
40	i.busy = true
41	if i.canResumeSessionSelection() {
42		t.Fatal("busy turn allowed session selection")
43	}
44}
45
46func TestSubmitOrQueuePreservesImagesInHostQueue(t *testing.T) {
47	i := &Interactive{agent: &core.Agent{}, busy: true, compacting: true}
48	image := provider.ImageBlock{MimeType: "image/png", Data: []byte("png-1")}
49
50	i.submitOrQueue("inspect", []provider.ImageBlock{image}, false)
51
52	if len(i.queued) != 1 || i.queued[0].Text != "inspect" {
53		t.Fatalf("queued messages = %#v, want one inspect prompt", i.queued)
54	}
55	if len(i.queued[0].Images) != 1 || string(i.queued[0].Images[0].Data) != "png-1" {
56		t.Fatalf("queued images = %#v, want png-1", i.queued[0].Images)
57	}
58}
59
60func TestSubmitOrQueuePreservesSealedWorkerWaveWithPendingWorker(t *testing.T) {
61	i := &Interactive{agent: &core.Agent{}}
62	i.applyCoordinator(orchestration.Event{Kind: orchestration.EventManagerStarted})
63	i.applyCoordinator(orchestration.Event{Kind: orchestration.EventWorkerRegistered, WorkerID: "worker#1"})
64	i.applyCoordinator(orchestration.Event{Kind: orchestration.EventManagerFinished})
65
66	image := provider.ImageBlock{MimeType: "image/png", Data: []byte("png-1")}
67	i.submitOrQueue("review the result", []provider.ImageBlock{image}, true)
68
69	actions := i.applyCoordinator(orchestration.Event{
70		Kind:     orchestration.EventWorkerFinished,
71		WorkerID: "worker#1",
72		Completion: subagents.Completion{
73			AgentID: "worker",
74			Status:  "completed",
75		},
76	})
77	if len(actions) != 1 {
78		t.Fatalf("completion actions = %d, want 1", len(actions))
79	}
80	if got := actions[0].Text; got != "review the result" {
81		t.Fatalf("completion action text = %q, want queued user input", got)
82	}
83	if len(actions[0].Images) != 1 || string(actions[0].Images[0].Data) != "png-1" {
84		t.Fatalf("completion action images = %#v, want queued image", actions[0].Images)
85	}
86}

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