v0.22.0 fae6c20

resident_snapshot_test.go RawHistoryFolder

1package subagents
2
3import (
4	"context"
5	"fmt"
6	"testing"
7	"time"
8)
9
10func TestResidentManagerSnapshotPageAndLookupAreBounded(t *testing.T) {
11	manager := NewResidentManager(t.TempDir(), func(ResidentChildSpec, *ResidentJournal) (ResidentTurnRunner, error) {
12		return func(context.Context, string) error { return nil }, nil
13	})
14	t.Cleanup(func() { _ = manager.Close(context.Background()) })
15	for i := 0; i < 5; i++ {
16		spec := ResidentChildSpec{ID: fmt.Sprintf("child-%d", i), SessionID: fmt.Sprintf("session-%d", i), Provider: "openai", Model: "gpt-5"}
17		if _, err := manager.Spawn(context.Background(), spec, "task"); err != nil {
18			t.Fatal(err)
19		}
20	}
21	page, total := manager.SnapshotPage(2, 2)
22	if total != 5 || len(page) != 2 || page[0].ID != "child-2" || page[1].ID != "child-3" {
23		t.Fatalf("page/total = %#v/%d", page, total)
24	}
25	snapshot, ok := manager.SnapshotFor("child-4")
26	if !ok || snapshot.ID != "child-4" {
27		t.Fatalf("single snapshot = %#v, %t", snapshot, ok)
28	}
29}
30
31func TestResidentManagerRecentSnapshotPageOrdersLatestTransitionFirst(t *testing.T) {
32	now := time.Date(2026, time.August, 13, 12, 0, 0, 0, time.UTC)
33	manager := &ResidentManager{children: map[string]*ResidentChild{}, recovered: map[string]ResidentSnapshot{
34		"older": {ID: "older", State: ResidentIdle, UpdatedAt: now.Add(-time.Hour)},
35		"newer": {ID: "newer", State: ResidentRunning, UpdatedAt: now.Add(-time.Minute)},
36	}, recoveredSpec: map[string]ResidentChildSpec{}, pending: map[string]struct{}{}}
37	page, total := manager.RecentSnapshotPage(0, 1)
38	if total != 2 || len(page) != 1 || page[0].ID != "newer" {
39		t.Fatalf("recent page = %#v/%d", page, total)
40	}
41}

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