detached dd4ecde

test(tui): synchronize resident activity rendering

commit
dd4ecde0b98c20b2cef0e8a41666206ce90c1d97
author
brice · · 2026-08-20 14:09 UTC
parent
9f470d3
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
1 file · +32 -3
M packages/agent/modes/resident_subagent_indicator_test.go +32 -3
@@ -51,7 +51,7 @@ func TestInteractiveResidentSubagentActivityRendersAllActiveChildrenWhenHeightAl
5151 }, nil
5252 })
5353 t.Cleanup(func() { _ = manager.Close(context.Background()) })
54- spawnResidentIndicatorChildren(t, manager, 10)
54+ spawnRunningResidentIndicatorChildren(t, manager, 10)
5555
5656 term := &residentIndicatorTerminal{cols: 80, rows: 40}
5757 interactive := NewInteractive(InteractiveConfig{Terminal: term, ResidentManager: manager, Theme: tui.Dark})
@@ -86,7 +86,7 @@ func TestInteractiveResidentSubagentActivitySummarizesBoundedPageUnderShortHeigh
8686 }, nil
8787 })
8888 t.Cleanup(func() { _ = manager.Close(context.Background()) })
89- spawnResidentIndicatorChildren(t, manager, 6)
89+ spawnRunningResidentIndicatorChildren(t, manager, 6)
9090
9191 term := &residentIndicatorTerminal{cols: 80, rows: 8}
9292 interactive := NewInteractive(InteractiveConfig{Terminal: term, ResidentManager: manager, Theme: tui.Dark})
@@ -112,7 +112,7 @@ func TestInteractiveResidentSubagentActivityShowsAllActiveChildrenWhenShortHeigh
112112 }, nil
113113 })
114114 t.Cleanup(func() { _ = manager.Close(context.Background()) })
115- spawnResidentIndicatorChildren(t, manager, 2)
115+ spawnRunningResidentIndicatorChildren(t, manager, 2)
116116
117117 term := &residentIndicatorTerminal{cols: 80, rows: 8}
118118 interactive := NewInteractive(InteractiveConfig{Terminal: term, ResidentManager: manager, Theme: tui.Dark})
@@ -132,6 +132,35 @@ func TestInteractiveResidentSubagentActivityShowsAllActiveChildrenWhenShortHeigh
132132 }
133133 }
134134
135+func spawnRunningResidentIndicatorChildren(t *testing.T, manager *subagents.ResidentManager, count int) {
136+ t.Helper()
137+ updates := make(chan string, count*2)
138+ manager.SetUpdateObserver(func(childID string) {
139+ select {
140+ case updates <- childID:
141+ default:
142+ }
143+ })
144+ spawnResidentIndicatorChildren(t, manager, count)
145+ defer manager.SetUpdateObserver(nil)
146+
147+ running := make(map[string]struct{}, count)
148+ timer := time.NewTimer(time.Second)
149+ defer timer.Stop()
150+ for len(running) < count {
151+ select {
152+ case childID := <-updates:
153+ snapshot, ok := manager.SnapshotFor(childID)
154+ if ok && snapshot.State == subagents.ResidentRunning {
155+ running[childID] = struct{}{}
156+ }
157+ case <-timer.C:
158+ snapshots, _ := manager.ActiveSnapshotPage(0)
159+ t.Fatalf("running resident children = %d, want %d; active snapshots=%#v", len(running), count, snapshots)
160+ }
161+ }
162+}
163+
135164 func spawnResidentIndicatorChildren(t *testing.T, manager *subagents.ResidentManager, count int) {
136165 t.Helper()
137166 for index := 0; index < count; index++ {
@@ -51,7 +51,7 @@ func TestInteractiveResidentSubagentActivityRendersAllActiveChildrenWhenHeightAl
51 }, nil51 }, nil
52 })52 })
53 t.Cleanup(func() { _ = manager.Close(context.Background()) })53 t.Cleanup(func() { _ = manager.Close(context.Background()) })
54- spawnResidentIndicatorChildren(t, manager, 10)54+ spawnRunningResidentIndicatorChildren(t, manager, 10)
55 55
56 term := &residentIndicatorTerminal{cols: 80, rows: 40}56 term := &residentIndicatorTerminal{cols: 80, rows: 40}
57 interactive := NewInteractive(InteractiveConfig{Terminal: term, ResidentManager: manager, Theme: tui.Dark})57 interactive := NewInteractive(InteractiveConfig{Terminal: term, ResidentManager: manager, Theme: tui.Dark})
@@ -86,7 +86,7 @@ func TestInteractiveResidentSubagentActivitySummarizesBoundedPageUnderShortHeigh
86 }, nil86 }, nil
87 })87 })
88 t.Cleanup(func() { _ = manager.Close(context.Background()) })88 t.Cleanup(func() { _ = manager.Close(context.Background()) })
89- spawnResidentIndicatorChildren(t, manager, 6)89+ spawnRunningResidentIndicatorChildren(t, manager, 6)
90 90
91 term := &residentIndicatorTerminal{cols: 80, rows: 8}91 term := &residentIndicatorTerminal{cols: 80, rows: 8}
92 interactive := NewInteractive(InteractiveConfig{Terminal: term, ResidentManager: manager, Theme: tui.Dark})92 interactive := NewInteractive(InteractiveConfig{Terminal: term, ResidentManager: manager, Theme: tui.Dark})
@@ -112,7 +112,7 @@ func TestInteractiveResidentSubagentActivityShowsAllActiveChildrenWhenShortHeigh
112 }, nil112 }, nil
113 })113 })
114 t.Cleanup(func() { _ = manager.Close(context.Background()) })114 t.Cleanup(func() { _ = manager.Close(context.Background()) })
115- spawnResidentIndicatorChildren(t, manager, 2)115+ spawnRunningResidentIndicatorChildren(t, manager, 2)
116 116
117 term := &residentIndicatorTerminal{cols: 80, rows: 8}117 term := &residentIndicatorTerminal{cols: 80, rows: 8}
118 interactive := NewInteractive(InteractiveConfig{Terminal: term, ResidentManager: manager, Theme: tui.Dark})118 interactive := NewInteractive(InteractiveConfig{Terminal: term, ResidentManager: manager, Theme: tui.Dark})
@@ -132,6 +132,35 @@ func TestInteractiveResidentSubagentActivityShowsAllActiveChildrenWhenShortHeigh
132 }132 }
133 }133 }
134 134
135+func spawnRunningResidentIndicatorChildren(t *testing.T, manager *subagents.ResidentManager, count int) {
136+ t.Helper()
137+ updates := make(chan string, count*2)
138+ manager.SetUpdateObserver(func(childID string) {
139+ select {
140+ case updates <- childID:
141+ default:
142+ }
143+ })
144+ spawnResidentIndicatorChildren(t, manager, count)
145+ defer manager.SetUpdateObserver(nil)
146+
147+ running := make(map[string]struct{}, count)
148+ timer := time.NewTimer(time.Second)
149+ defer timer.Stop()
150+ for len(running) < count {
151+ select {
152+ case childID := <-updates:
153+ snapshot, ok := manager.SnapshotFor(childID)
154+ if ok && snapshot.State == subagents.ResidentRunning {
155+ running[childID] = struct{}{}
156+ }
157+ case <-timer.C:
158+ snapshots, _ := manager.ActiveSnapshotPage(0)
159+ t.Fatalf("running resident children = %d, want %d; active snapshots=%#v", len(running), count, snapshots)
160+ }
161+ }
162+}
163+
135 func spawnResidentIndicatorChildren(t *testing.T, manager *subagents.ResidentManager, count int) {164 func spawnResidentIndicatorChildren(t *testing.T, manager *subagents.ResidentManager, count int) {
136 t.Helper()165 t.Helper()
137 for index := 0; index < count; index++ {166 for index := 0; index < count; index++ {

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