v0.33.0 653c635

interactive_resident_completion_test.go RawHistoryFolder

1package modes
2
3import (
4	"context"
5	"errors"
6	"strings"
7	"testing"
8	"time"
9
10	"github.com/bnema/zut/packages/agent/subagents"
11	"github.com/bnema/zut/packages/core"
12)
13
14func TestResidentCompletionSlidesIntoBusyParent(t *testing.T) {
15	for _, tc := range []struct {
16		name       string
17		err        error
18		compacting bool
19	}{
20		{name: "success"},
21		{name: "failure", err: errors.New("review failed")},
22		{name: "compaction", compacting: true},
23	} {
24		t.Run(tc.name, func(t *testing.T) {
25			ctx, cancel := context.WithCancel(context.Background())
26			defer cancel()
27			ag := core.NewAgent(nil, "model", "", nil)
28			i := &Interactive{agent: ag, busy: true, compacting: tc.compacting, runCtx: ctx}
29			release := i.beginCompletionDeliveryHold()
30			defer release()
31			i.TrackResidentSubagent("finished", "turn-1")
32			i.TrackResidentSubagent("still-running", "turn-2")
33			i.ReportResidentSubagent(subagents.ResidentCompletion{ChildID: "finished", TurnID: "turn-1", Task: "review", Summary: "saved result", Err: tc.err})
34
35			deadline := time.NewTimer(2 * time.Second)
36			defer deadline.Stop()
37			tick := time.NewTicker(time.Millisecond)
38			defer tick.Stop()
39			for {
40				i.mu.Lock()
41				queued := ag.PendingQueuedMessages()
42				if tc.compacting {
43					queued = append([]core.QueuedMessage(nil), i.queued...)
44				}
45				i.mu.Unlock()
46				if len(queued) != 0 {
47					if len(queued) != 1 || !queued[0].HostEvent || !strings.Contains(queued[0].Text, "saved result") || !strings.Contains(queued[0].Text, "[auto-subagents update]") {
48						t.Fatalf("queued completions = %#v", queued)
49					}
50					if tc.err != nil && !strings.Contains(queued[0].Text, tc.err.Error()) {
51						t.Fatalf("missing failure: %q", queued[0].Text)
52					}
53					if i.ensureCompletionTracker().Pending() != 1 {
54						t.Fatal("unfinished child was not retained")
55					}
56					return
57				}
58				select {
59				case <-deadline.C:
60					t.Fatal("completion did not slide in while parent and sibling were active")
61				case <-tick.C:
62				}
63			}
64		})
65	}
66}

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