@@ -14,6 +14,7 @@ import (
1414 func TestDashboard(t *testing.T) {
1515 defer setupGoldenTest(t)()
1616
17+ // Use fixed timestamps for deterministic golden files.
1718 tests := []struct {
1819 name string
1920 myses []MysisInfo
@@ -21,6 +22,7 @@ func TestDashboard(t *testing.T) {
2122 selectedIdx int
2223 width int
2324 height int
25+ loadingSet map[string]bool
2426 }{
2527 {
2628 name: "empty_swarm",
@@ -29,6 +31,7 @@ func TestDashboard(t *testing.T) {
2931 selectedIdx: 0,
3032 width: TestTerminalWidth,
3133 height: TestTerminalHeight,
34+ loadingSet: map[string]bool{},
3235 },
3336 {
3437 name: "with_swarm_messages",
@@ -40,6 +43,7 @@ func TestDashboard(t *testing.T) {
4043 Provider: "ollama",
4144 AccountUsername: "crab_warrior",
4245 LastMessage: "Mining asteroid belt",
46+ LastMessageAt: time.Date(2026, 1, 15, 10, 45, 0, 0, time.UTC),
4347 CreatedAt: time.Date(2026, 1, 15, 10, 30, 0, 0, time.UTC),
4448 },
4549 {
@@ -49,23 +53,106 @@ func TestDashboard(t *testing.T) {
4953 Provider: "opencode_zen",
5054 AccountUsername: "crab_trader",
5155 LastMessage: "Waiting for orders",
56+ LastMessageAt: time.Date(2026, 1, 15, 10, 46, 0, 0, time.UTC),
5257 CreatedAt: time.Date(2026, 1, 15, 10, 35, 0, 0, time.UTC),
5358 },
5459 },
5560 swarmMsgs: []SwarmMessageInfo{
56- {Content: "All units: proceed to sector 7", CreatedAt: time.Date(2026, 1, 15, 11, 0, 0, 0, time.UTC)},
57- {Content: "Target rich environment detected", CreatedAt: time.Date(2026, 1, 15, 11, 5, 0, 0, time.UTC)},
61+ {SenderID: "mysis-1", SenderName: "alpha", Content: "All units: proceed to sector 7", CreatedAt: time.Date(2026, 1, 15, 11, 0, 0, 0, time.UTC)},
62+ {SenderID: "mysis-2", SenderName: "beta", Content: "Target rich environment detected", CreatedAt: time.Date(2026, 1, 15, 11, 5, 0, 0, time.UTC)},
5863 },
5964 selectedIdx: 0,
6065 width: TestTerminalWidth,
6166 height: TestTerminalHeight,
67+ loadingSet: map[string]bool{},
68+ },
69+ {
70+ name: "with_multiline_broadcast",
71+ myses: []MysisInfo{
72+ {
73+ ID: "mysis-3",
74+ Name: "gamma",
75+ State: "idle",
76+ Provider: "ollama",
77+ AccountUsername: "crab_cartographer",
78+ LastMessage: "Standing by",
79+ LastMessageAt: time.Date(2026, 1, 15, 12, 0, 0, 0, time.UTC),
80+ CreatedAt: time.Date(2026, 1, 15, 11, 55, 0, 0, time.UTC),
81+ },
82+ },
83+ swarmMsgs: []SwarmMessageInfo{
84+ {SenderID: "mysis-3", SenderName: "gamma", Content: "Line one\nLine two", CreatedAt: time.Date(2026, 1, 15, 12, 1, 0, 0, time.UTC)},
85+ },
86+ selectedIdx: 0,
87+ width: TestTerminalWidth,
88+ height: TestTerminalHeight,
89+ loadingSet: map[string]bool{},
90+ },
91+ {
92+ name: "with_loading_mysis",
93+ myses: []MysisInfo{
94+ {
95+ ID: "mysis-4",
96+ Name: "delta",
97+ State: "running",
98+ Provider: "ollama",
99+ AccountUsername: "crab_runner",
100+ LastMessage: "Processing",
101+ LastMessageAt: time.Date(2026, 1, 15, 12, 5, 0, 0, time.UTC),
102+ CreatedAt: time.Date(2026, 1, 15, 11, 50, 0, 0, time.UTC),
103+ },
104+ },
105+ swarmMsgs: []SwarmMessageInfo{},
106+ selectedIdx: 0,
107+ width: TestTerminalWidth,
108+ height: TestTerminalHeight,
109+ loadingSet: map[string]bool{"mysis-4": true},
110+ },
111+ {
112+ name: "narrow_terminal",
113+ myses: []MysisInfo{
114+ {
115+ ID: "mysis-5",
116+ Name: "epsilon",
117+ State: "idle",
118+ Provider: "ollama",
119+ AccountUsername: "crab_navigator",
120+ LastMessage: "Holding position",
121+ LastMessageAt: time.Date(2026, 1, 15, 12, 10, 0, 0, time.UTC),
122+ CreatedAt: time.Date(2026, 1, 15, 12, 5, 0, 0, time.UTC),
123+ },
124+ },
125+ swarmMsgs: []SwarmMessageInfo{},
126+ selectedIdx: 0,
127+ width: 80,
128+ height: 24,
129+ loadingSet: map[string]bool{},
130+ },
131+ {
132+ name: "wide_terminal",
133+ myses: []MysisInfo{
134+ {
135+ ID: "mysis-6",
136+ Name: "zeta",
137+ State: "running",
138+ Provider: "opencode_zen",
139+ AccountUsername: "crab_scout",
140+ LastMessage: "Surveying sector",
141+ LastMessageAt: time.Date(2026, 1, 15, 12, 20, 0, 0, time.UTC),
142+ CreatedAt: time.Date(2026, 1, 15, 12, 15, 0, 0, time.UTC),
143+ },
144+ },
145+ swarmMsgs: []SwarmMessageInfo{},
146+ selectedIdx: 0,
147+ width: 200,
148+ height: 60,
149+ loadingSet: map[string]bool{},
62150 },
63151 }
64152
65153 for _, tt := range tests {
66154 t.Run(tt.name, func(t *testing.T) {
67- loadingSet := make(map[string]bool)
68- output := RenderDashboard(tt.myses, tt.swarmMsgs, tt.selectedIdx, tt.width, tt.height, loadingSet, "⠋")
155+ output := RenderDashboard(tt.myses, tt.swarmMsgs, tt.selectedIdx, tt.width, tt.height, tt.loadingSet, "⠋")
69156
70157 t.Run("ANSI", func(t *testing.T) {
71158 golden.RequireEqual(t, []byte(output))
@@ -133,10 +220,11 @@ func TestFocusView(t *testing.T) {
133220 {
134221 name: "with_scrollbar",
135222 mysis: MysisInfo{
136- ID: "test-mysis",
137- Name: "beta",
138- State: "running",
139- Provider: "ollama",
223+ ID: "test-mysis",
224+ Name: "beta",
225+ State: "running",
226+ Provider: "ollama",
227+ CreatedAt: time.Date(2026, 1, 15, 9, 30, 0, 0, time.UTC),
140228 },
141229 logs: func() []LogEntry {
142230 // Create enough logs to trigger scrollbar
@@ -154,11 +242,32 @@ func TestFocusView(t *testing.T) {
154242 width: TestTerminalWidth,
155243 height: TestTerminalHeight,
156244 },
245+ {
246+ name: "narrow_terminal",
247+ mysis: MysisInfo{
248+ ID: "test-mysis",
249+ Name: "gamma",
250+ State: "idle",
251+ Provider: "opencode_zen",
252+ AccountUsername: "crab_surveyor",
253+ CreatedAt: time.Date(2026, 1, 15, 9, 45, 0, 0, time.UTC),
254+ },
255+ logs: []LogEntry{
256+ {
257+ Role: "assistant",
258+ Source: "llm",
259+ Content: "Short response for narrow view.",
260+ Timestamp: time.Date(2026, 1, 15, 9, 46, 0, 0, time.UTC),
261+ },
262+ },
263+ width: 80,
264+ height: 24,
265+ },
157266 }
158267
159268 for _, tt := range tests {
160269 t.Run(tt.name, func(t *testing.T) {
161- output := RenderFocusView(tt.mysis, tt.logs, tt.width, tt.height, false, "⠋", false)
270+ output := RenderFocusView(tt.mysis, tt.logs, tt.width, tt.height, false, "⠋", false, 1, 1)
162271
163272 t.Run("ANSI", func(t *testing.T) {
164273 golden.RequireEqual(t, []byte(output))
@@ -297,6 +406,7 @@ func TestFocusViewWithViewport(t *testing.T) {
297406 width int
298407 height int
299408 totalLines int
409+ autoScroll bool
300410 }{
301411 {
302412 name: "with_scrollbar",
@@ -306,14 +416,16 @@ func TestFocusViewWithViewport(t *testing.T) {
306416 State: "running",
307417 Provider: "ollama",
308418 AccountUsername: "crab_pilot",
419+ CreatedAt: time.Date(2026, 1, 15, 10, 0, 0, 0, time.UTC),
309420 },
310421 logs: func() []LogEntry {
311422 logs := make([]LogEntry, 50)
312423 for i := 0; i < 50; i++ {
313424 logs[i] = LogEntry{
314- Role: "user",
315- Source: "direct",
316- Content: "Test line " + string(rune('0'+i%10)),
425+ Role: "user",
426+ Source: "direct",
427+ Content: "Test line " + string(rune('0'+i%10)),
428+ Timestamp: time.Date(2026, 1, 15, 10, i%60, 0, 0, time.UTC),
317429 }
318430 }
319431 return logs
@@ -321,6 +433,34 @@ func TestFocusViewWithViewport(t *testing.T) {
321433 width: TestTerminalWidth,
322434 height: 20,
323435 totalLines: 50,
436+ autoScroll: true,
437+ },
438+ {
439+ name: "with_scroll_indicator",
440+ mysis: MysisInfo{
441+ ID: "test-id",
442+ Name: "test-mysis",
443+ State: "running",
444+ Provider: "ollama",
445+ AccountUsername: "crab_pilot",
446+ CreatedAt: time.Date(2026, 1, 15, 10, 0, 0, 0, time.UTC),
447+ },
448+ logs: func() []LogEntry {
449+ logs := make([]LogEntry, 30)
450+ for i := 0; i < 30; i++ {
451+ logs[i] = LogEntry{
452+ Role: "assistant",
453+ Source: "llm",
454+ Content: "Focus log line " + string(rune('A'+i)),
455+ Timestamp: time.Date(2026, 1, 15, 10, i%60, 0, 0, time.UTC),
456+ }
457+ }
458+ return logs
459+ }(),
460+ width: TestTerminalWidth,
461+ height: 20,
462+ totalLines: 30,
463+ autoScroll: false,
324464 },
325465 }
326466
@@ -336,7 +476,7 @@ func TestFocusViewWithViewport(t *testing.T) {
336476 vp.SetContent(strings.Join(contentLines, "\n"))
337477 vp.GotoTop()
338478
339- output := RenderFocusViewWithViewport(tt.mysis, vp, tt.width, false, "⠋", true, false, tt.totalLines)
479+ output := RenderFocusViewWithViewport(tt.mysis, vp, tt.width, false, "⠋", tt.autoScroll, false, tt.totalLines, 1, 1)
340480
341481 t.Run("ANSI", func(t *testing.T) {
342482 golden.RequireEqual(t, []byte(output))
@@ -456,9 +596,10 @@ func TestMysisLine(t *testing.T) {
456596 defer setupGoldenTest(t)()
457597
458598 tests := []struct {
459- name string
460- mysis MysisInfo
461- width int
599+ name string
600+ mysis MysisInfo
601+ width int
602+ loading bool
462603 }{
463604 {
464605 name: "with_account",
@@ -469,6 +610,7 @@ func TestMysisLine(t *testing.T) {
469610 Provider: "ollama",
470611 AccountUsername: "crab_miner",
471612 LastMessage: "Mining asteroid",
613+ LastMessageAt: time.Date(2026, 1, 15, 10, 5, 0, 0, time.UTC),
472614 CreatedAt: time.Date(2026, 1, 15, 10, 0, 0, 0, time.UTC),
473615 },
474616 width: 100,
@@ -486,11 +628,54 @@ func TestMysisLine(t *testing.T) {
486628 },
487629 width: 100,
488630 },
631+ {
632+ name: "long_name",
633+ mysis: MysisInfo{
634+ ID: "abc123",
635+ Name: "mysis-with-a-very-long-name",
636+ State: "running",
637+ Provider: "ollama",
638+ AccountUsername: "crab_miner",
639+ LastMessage: "Holding",
640+ LastMessageAt: time.Date(2026, 1, 15, 10, 10, 0, 0, time.UTC),
641+ CreatedAt: time.Date(2026, 1, 15, 10, 0, 0, 0, time.UTC),
642+ },
643+ width: 100,
644+ },
645+ {
646+ name: "errored_state",
647+ mysis: MysisInfo{
648+ ID: "abc123",
649+ Name: "test-mysis",
650+ State: "errored",
651+ Provider: "ollama",
652+ AccountUsername: "crab_miner",
653+ LastMessage: "",
Cut short: this commit's diff is over 1000 lines.