v0.35.0 21873e8

subagent_status_test.go RawHistoryFolder

1package tools
2
3import (
4	"context"
5	"encoding/json"
6	"os"
7	"path/filepath"
8	"strings"
9	"testing"
10
11	"github.com/bnema/zut/packages/agent/subagents"
12)
13
14func TestResidentStatusResultReadErrors(t *testing.T) {
15	for _, scenario := range []struct {
16		name string
17		want string
18	}{
19		{"missing", "no saved result exists yet"},
20		{"foreign", "owned by another zut process"},
21		{"corrupt", "could not read or decode the saved result"},
22	} {
23		t.Run(scenario.name, func(t *testing.T) {
24			root := t.TempDir()
25			manager := subagents.NewResidentManager(root, func(subagents.ResidentChildSpec, *subagents.ResidentJournal) (subagents.ResidentTurnRunner, error) {
26				return func(ctx context.Context, _ string) error {
27					<-ctx.Done()
28					return ctx.Err()
29				}, nil
30			})
31			t.Cleanup(func() { _ = manager.Close(context.Background()) })
32			spec := subagents.ResidentChildSpec{ID: "status-error", InitialTurnID: "initial", SessionID: "session", Provider: "openai", Model: "test"}
33			if _, err := manager.Spawn(t.Context(), spec, "investigate"); err != nil {
34				t.Fatal(err)
35			}
36			statusManager := manager
37			if scenario.name == "foreign" {
38				statusManager = subagents.NewResidentManager(root, nil)
39				t.Cleanup(func() { _ = statusManager.Close(context.Background()) })
40				if errs := statusManager.Reconcile(); len(errs) != 0 {
41					t.Fatal(errs)
42				}
43			}
44			if scenario.name == "corrupt" {
45				if err := os.WriteFile(filepath.Join(root, spec.ID, "result.json"), []byte("private malformed payload"), 0o600); err != nil {
46					t.Fatal(err)
47				}
48			}
49			tool := &SubagentStatusTool{ResidentManager: statusManager, Enabled: func() bool { return true }}
50			result, err := tool.Execute(t.Context(), json.RawMessage(`{"agent_id":"status-error","include_result":true}`), nil)
51			if err != nil || !result.IsError {
52				t.Fatalf("result = %#v, error = %v", result, err)
53			}
54			text := toolResultText(t, result)
55			if !strings.Contains(text, scenario.want) || strings.Contains(text, root) || strings.Contains(text, "private") {
56				t.Fatalf("unexpected error text: %q", text)
57			}
58		})
59	}
60}

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 477

↑↓ moveenter openesc close