xonecas.io
60255
Zn

Zoea-Nova / commit 44fd43c

feat(tui): display account status in dashboard and focus views

- Add CurrentAccountUsername() method to Mysis
- Add AccountUsername field to MysisInfo
- Show account username in dashboard mysis list
- Show account status in focus view header
- Add test coverage for account display

xonecas2026-02-05 44fd43c3fdf718e04d60bcffb4257c22477eeb1e parent 88c4a4c

4 files changed

internal/core/mysis.go+7−0
@@ -249,6 +249,13 @@ func (a *Mysis) LastError() error {
249249 return a.lastError
250250 }
251251
252+// CurrentAccountUsername returns the username of the account this mysis is using.
253+func (a *Mysis) CurrentAccountUsername() string {
254+ a.mu.RLock()
255+ defer a.mu.RUnlock()
256+ return a.currentAccountUsername
257+}
258+
252259 // SetProvider updates the mysis provider.
253260 func (a *Mysis) SetProvider(p provider.Provider) {
254261 a.mu.Lock()
internal/tui/dashboard.go+25−14
@@ -11,12 +11,13 @@ import (
1111
1212 // MysisInfo holds display info for a mysis.
1313 type MysisInfo struct {
14- ID string
15- Name string
16- State string
17- Provider string
18- LastMessage string // Most recent message (user or assistant)
19- CreatedAt time.Time // When mysis was created
14+ ID string
15+ Name string
16+ State string
17+ Provider string
18+ AccountUsername string // NEW: game account username
19+ LastMessage string // Most recent message (user or assistant)
20+ CreatedAt time.Time // When mysis was created
2021 }
2122
2223 // SwarmMessageInfo holds display info for a broadcast message.
@@ -187,14 +188,23 @@ func renderMysisLine(m MysisInfo, selected, isLoading bool, spinnerView string,
187188 stateText := StateStyle(m.State).Render(fmt.Sprintf("%-8s", m.State))
188189 provider := dimmedStyle.Render(fmt.Sprintf("[%s]", m.Provider))
189190
190- // First part: indicator + name + state + provider
191- firstPart := fmt.Sprintf("%s %-16s %s %s", stateIndicator, name, stateText, provider)
191+ // Account username display
192+ var accountText string
193+ if m.AccountUsername != "" {
194+ accountText = dimmedStyle.Render(fmt.Sprintf("@%s", m.AccountUsername))
195+ } else {
196+ accountText = dimmedStyle.Render("(no account)")
197+ }
198+
199+ // First part: indicator + name + state + provider + account
200+ firstPart := fmt.Sprintf("%s %-16s %s %s %s", stateIndicator, name, stateText, provider, accountText)
192201
193202 // Calculate remaining width for last message
194203 // Account for the prefix "│ " for the message
195204 // Use lipgloss.Width() for proper Unicode width calculation
196205 providerWidth := lipgloss.Width(m.Provider)
197- usedWidth := 2 + 16 + 1 + 8 + 1 + providerWidth + 2 + 4 // rough estimate
206+ accountTextWidth := lipgloss.Width(accountText)
207+ usedWidth := 2 + 16 + 1 + 8 + 1 + providerWidth + 2 + 1 + accountTextWidth + 4
198208 msgWidth := width - usedWidth - 8
199209 if msgWidth < 10 {
200210 msgWidth = 10
@@ -222,10 +232,11 @@ func renderMysisLine(m MysisInfo, selected, isLoading bool, spinnerView string,
222232 // MysisInfoFromCore converts a core.Mysis to MysisInfo.
223233 func MysisInfoFromCore(m *core.Mysis) MysisInfo {
224234 return MysisInfo{
225- ID: m.ID(),
226- Name: m.Name(),
227- State: string(m.State()),
228- Provider: m.ProviderName(),
229- CreatedAt: m.CreatedAt(),
235+ ID: m.ID(),
236+ Name: m.Name(),
237+ State: string(m.State()),
238+ Provider: m.ProviderName(),
239+ AccountUsername: m.CurrentAccountUsername(), // NEW: copy account username
240+ CreatedAt: m.CreatedAt(),
230241 }
231242 }
internal/tui/dashboard_test.go+63−0
@@ -0,0 +1,63 @@
1+package tui
2+
3+import (
4+ "strings"
5+ "testing"
6+ "time"
7+
8+ "github.com/charmbracelet/lipgloss"
9+ "github.com/muesli/termenv"
10+)
11+
12+func TestRenderMysisLineWithAccount(t *testing.T) {
13+ // Force color output for testing
14+ lipgloss.SetColorProfile(termenv.TrueColor)
15+ defer lipgloss.SetColorProfile(termenv.Ascii)
16+
17+ info := MysisInfo{
18+ ID: "abc123",
19+ Name: "test-mysis",
20+ State: "running",
21+ Provider: "ollama",
22+ AccountUsername: "crab_miner",
23+ LastMessage: "Mining asteroid",
24+ CreatedAt: time.Now(),
25+ }
26+
27+ width := 100
28+ line := renderMysisLine(info, false, false, "⬡", width)
29+
30+ // Should contain account username
31+ if !strings.Contains(line, "crab_miner") {
32+ t.Error("Expected account username 'crab_miner' in mysis line")
33+ }
34+
35+ // Verify ANSI codes are present (styling is applied)
36+ if !strings.Contains(line, "\x1b[") {
37+ t.Error("Expected ANSI escape codes (styling) in output")
38+ }
39+}
40+
41+func TestRenderMysisLineWithoutAccount(t *testing.T) {
42+ // Force color output
43+ lipgloss.SetColorProfile(termenv.TrueColor)
44+ defer lipgloss.SetColorProfile(termenv.Ascii)
45+
46+ info := MysisInfo{
47+ ID: "abc123",
48+ Name: "test-mysis",
49+ State: "idle",
50+ Provider: "ollama",
51+ AccountUsername: "", // No account claimed yet
52+ LastMessage: "",
53+ CreatedAt: time.Now(),
54+ }
55+
56+ width := 100
57+ line := renderMysisLine(info, false, false, "⬡", width)
58+
59+ // Should contain indicator for no account
60+ if !strings.Contains(line, "no account") {
61+ t.Error("Expected 'no account' indicator when AccountUsername is empty")
62+ }
63+}
internal/tui/focus.go+16−0
@@ -79,6 +79,14 @@ func RenderFocusView(mysis MysisInfo, logs []LogEntry, width, height int, isLoad
7979 fmt.Sprintf("%s %s", labelStyle.Render("State:"), stateDisplay),
8080 fmt.Sprintf("%s %s", labelStyle.Render("Provider:"), valueStyle.Render(mysis.Provider)),
8181 }
82+
83+ // Add account info if available
84+ if mysis.AccountUsername != "" {
85+ infoLines = append(infoLines, fmt.Sprintf("%s %s", labelStyle.Render("Account:"), valueStyle.Render(mysis.AccountUsername)))
86+ } else {
87+ infoLines = append(infoLines, fmt.Sprintf("%s %s", labelStyle.Render("Account:"), dimmedStyle.Render("(not logged in)")))
88+ }
89+
8290 infoContent := strings.Join(infoLines, " ")
8391 infoPanel := panelStyle.Width(width - 2).Render(infoContent)
8492 sections = append(sections, infoPanel)
@@ -143,6 +151,14 @@ func RenderFocusViewWithViewport(mysis MysisInfo, vp viewport.Model, width int,
143151 fmt.Sprintf("%s %s", labelStyle.Render("State:"), stateDisplay),
144152 fmt.Sprintf("%s %s", labelStyle.Render("Provider:"), valueStyle.Render(mysis.Provider)),
145153 }
154+
155+ // Add account info if available
156+ if mysis.AccountUsername != "" {
157+ infoLines = append(infoLines, fmt.Sprintf("%s %s", labelStyle.Render("Account:"), valueStyle.Render(mysis.AccountUsername)))
158+ } else {
159+ infoLines = append(infoLines, fmt.Sprintf("%s %s", labelStyle.Render("Account:"), dimmedStyle.Render("(not logged in)")))
160+ }
161+
146162 infoContent := strings.Join(infoLines, " ")
147163 infoPanel := panelStyle.Width(width - 2).Render(infoContent)
148164 sections = append(sections, infoPanel)