xonecas.io
60255
Zn

Zoea-Nova / commit 9cc2606

feat(tui): retro-futuristic redesign with Unicode width fixes

Redesign TUI with hexagonal theme matching the Zoea Nova brand:
- New header banner with ◆ and ⬡ decorative elements
- Hexagonal spinner frames replacing braille dots
- Brand color palette (#9D00FF purple, #00FFCC teal)
- CRT-style network indicator with block elements

Fix Unicode width calculation bugs throughout:
- Use lipgloss.Width() instead of len() for display width
- Add truncateToWidth() for safe Unicode string truncation
- Consolidate shared render utilities in styles.go

Add comprehensive TUI tests for width calculations and styling.
Update AGENTS.md with TUI testing and Unicode width guidelines.

xonecas2026-02-04 9cc2606259488d9986f6cd26a95794d6a97e6652 parent 481a537

10 files changed

This diff is too big to show in full. The first 1000 lines are below, and every file is listed with its counts.

AGENTS.md+23−1
@@ -13,13 +13,35 @@ Guidelines for AI agents working on the Zoea Nova codebase—a TUI-based swarm c
1313 - Use interfaces for external dependencies (LLM providers, MCP, store).
1414 - Run `make fmt` before committing. Fix all warnings and linter errors.
1515 - When committing, use `required_permissions: ["all"]` to bypass sandbox restrictions (GPG signing requires full filesystem access).
16-- Write unit tests for `internal/core`, `internal/store`, and `internal/config`. Target 80%+ coverage.
16+- Write unit tests for all modules. Target 95%+ coverage.
1717 - Never write data migrations. Schema changes require a fresh database.
1818 - Use `zerolog` for logging. Never log to stdout/stderr (TUI owns the terminal).
1919 - Keep the TUI responsive. All LLM/network calls must be non-blocking (goroutines + channels).
2020 - Follow the Bubble Tea Elm Architecture: Model → Update → View.
2121 - No "nice to haves." This is an MVP. Keep scope minimal. MVP is not an escuse for lack of testing or code quality.
2222
23+## TUI Testing:
24+
25+When testing styled TUI output with lipgloss:
26+
27+- **ANSI codes are stripped without TTY**: Lipgloss doesn't output ANSI escape codes when there's no terminal. Tests run without a TTY, so styled output appears unstyled by default.
28+- **Force color output**: Use `lipgloss.SetColorProfile(termenv.TrueColor)` at the start of tests that verify styling. Always `defer lipgloss.SetColorProfile(termenv.Ascii)` to reset.
29+- **Strip ANSI for content checks**: When verifying text content in styled output, strip ANSI codes first. Use a regex like `\x1b\[[0-9;]*m` to remove escape sequences.
30+- **Verify styling is applied**: Check for `"\x1b["` to confirm ANSI codes are present. Check for `"48;"` specifically for background colors, `"38;"` for foreground.
31+- **Use `lipgloss.Width()` for display width**: Never use `len()` on styled strings—it counts bytes including ANSI codes. `lipgloss.Width()` returns the actual display width.
32+- **Test the actual styled output**: Don't just test that code runs without panicking. Verify the styling produces correct ANSI codes and that content is properly formatted.
33+
34+## Unicode Width Calculations:
35+
36+Multi-byte Unicode characters cause width calculation bugs:
37+
38+- **`len()` returns BYTES, not display width**: Characters like `◈`, `◆`, `╭`, `─` are 3 bytes each but display as 1 column. Using `len()` for width calculations produces incorrect results.
39+- **ALWAYS use `lipgloss.Width()`**: This correctly calculates display width for both Unicode and ANSI-styled strings.
40+- **Test with Unicode-heavy content**: Section titles and decorative borders use Unicode box-drawing characters. Always test width calculations with actual Unicode content.
41+- **Panel alignment requires exact widths**: If a section title is `width` chars and a panel border is calculated with `len()` instead of `lipgloss.Width()`, they will visually misalign.
42+- **Style padding affects alignment**: `lipgloss.Style.Padding(0, 1)` adds 1 space on each side. If one element has padding and another doesn't, their decorations won't align even if both are "width" chars total.
43+- **`lipgloss.Width()` sets content width**: When using `style.Width(n)`, the `n` sets the CONTENT width. Borders and padding are added ON TOP. So `style.Width(98)` with a border produces total width 100.
44+
2345 ## Terminology:
2446
2547 - **Agent**: An AI-controlled player instance with its own provider, memory, and state.
internal/core/commander.go+5−0
@@ -261,6 +261,11 @@ func (c *Commander) Broadcast(content string) error {
261261 }
262262 c.mu.RUnlock()
263263
264+ // Check if any agents are running
265+ if len(agents) == 0 {
266+ return fmt.Errorf("no running agents to receive broadcast")
267+ }
268+
264269 // Emit broadcast event
265270 c.bus.Publish(Event{
266271 Type: EventBroadcast,
internal/tui/app.go+15−11
@@ -70,13 +70,13 @@ type EventMsg struct {
7070
7171 // New creates a new TUI model.
7272 func New(commander *core.Commander, s *store.Store, eventCh <-chan core.Event) Model {
73- // Initialize spinner with retro dots style
73+ // Initialize spinner with hexagonal theme (matching logo)
7474 sp := spinner.New()
7575 sp.Spinner = spinner.Spinner{
76- Frames: []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"},
77- FPS: time.Second / 10, // 10 frames per second
76+ Frames: []string{"⬡", "⬢", "⬡", "⬢", "◇", "◆", "◇", "◆"},
77+ FPS: time.Second / 8, // 8 frames per second
7878 }
79- sp.Style = lipgloss.NewStyle().Foreground(colorSecondary)
79+ sp.Style = lipgloss.NewStyle().Foreground(colorBrand)
8080
8181 // Initialize viewport for conversation scrolling
8282 vp := viewport.New(80, 20)
@@ -235,10 +235,11 @@ func (m Model) View() string {
235235 } else if m.view == ViewFocus {
236236 content = RenderFocusViewWithViewport(m.agentByID(m.focusID), m.viewport, m.width, isLoading, m.spinner.View(), m.autoScroll)
237237 } else {
238- // Convert swarm messages for display
238+ // Convert swarm messages for display (reversed so most recent is first)
239239 swarmInfos := make([]SwarmMessageInfo, len(m.swarmMessages))
240240 for i, msg := range m.swarmMessages {
241- swarmInfos[i] = SwarmMessageInfo{
241+ // Reverse order: most recent first
242+ swarmInfos[len(m.swarmMessages)-1-i] = SwarmMessageInfo{
242243 Content: msg.Content,
243244 CreatedAt: msg.CreatedAt,
244245 }
@@ -246,10 +247,8 @@ func (m Model) View() string {
246247 content = RenderDashboard(m.agents, swarmInfos, m.selectedIdx, m.width, contentHeight-3, m.loadingSet, m.spinner.View())
247248 }
248249
249- // Add input if active
250- if m.input.IsActive() {
251- content += "\n" + m.input.View()
252- }
250+ // Always show message bar
251+ content += "\n" + m.input.ViewAlways(m.width)
253252
254253 // Add error if present
255254 if m.err != nil {
@@ -614,9 +613,14 @@ func (m *Model) updateViewportContent() {
614613 return
615614 }
616615
616+ // Log entries must fill the panel content area exactly.
617+ // Panel is rendered with logStyle.Width(m.width - 2).Padding(0, 2)
618+ // Content width = m.width - 2, minus 4 for padding (2 each side) = m.width - 6
619+ panelContentWidth := m.width - 6
620+
617621 var lines []string
618622 for _, entry := range m.logs {
619- entryLines := renderLogEntry(entry, m.viewport.Width-2)
623+ entryLines := renderLogEntry(entry, panelContentWidth)
620624 lines = append(lines, entryLines...)
621625 }
622626
internal/tui/dashboard.go+63−20
@@ -29,8 +29,29 @@ type SwarmMessageInfo struct {
2929 func RenderDashboard(agents []AgentInfo, swarmMessages []SwarmMessageInfo, selectedIdx int, width, height int, loadingSet map[string]bool, spinnerView string) string {
3030 var sections []string
3131
32- // Header
33- header := headerStyle.Width(width).Render("╔═══ ZOEA NOVA COMMAND CENTER ═══╗")
32+ // Header - retro-futuristic command center banner with hexagonal motif (matching logo)
33+ // Build width-spanning lines (exactly `width` characters)
34+ if width < 20 {
35+ width = 20
36+ }
37+ topLine := "◆" + strings.Repeat("═", width-2) + "◆"
38+ titleText := " ⬡ Z O E A N O V A ⬡ COMMAND CENTER"
39+ // Center the title and pad to full width - use lipgloss.Width() for Unicode
40+ titleDisplayWidth := lipgloss.Width(titleText)
41+ titlePadding := (width - titleDisplayWidth) / 2
42+ if titlePadding < 0 {
43+ titlePadding = 0
44+ }
45+ titleLine := strings.Repeat(" ", titlePadding) + titleText
46+ // Pad right side to fill width
47+ titleLineWidth := lipgloss.Width(titleLine)
48+ if titleLineWidth < width {
49+ titleLine += strings.Repeat(" ", width-titleLineWidth)
50+ }
51+ bottomLine := "◆" + strings.Repeat("═", width-2) + "◆"
52+
53+ headerText := topLine + "\n" + titleLine + "\n" + bottomLine
54+ header := headerStyle.Width(width).Render(headerText)
3455 sections = append(sections, header)
3556
3657 // Stats bar
@@ -68,7 +89,7 @@ func RenderDashboard(agents []AgentInfo, swarmMessages []SwarmMessageInfo, selec
6889
6990 // Swarm message history
7091 if len(swarmMessages) > 0 {
71- swarmHeader := dimmedStyle.Render("─── Swarm Messages ───")
92+ swarmHeader := renderSectionTitle("SWARM BROADCAST", width)
7293 sections = append(sections, swarmHeader)
7394
7495 var msgLines []string
@@ -79,8 +100,8 @@ func RenderDashboard(agents []AgentInfo, swarmMessages []SwarmMessageInfo, selec
79100 if maxLen < 20 {
80101 maxLen = 20
81102 }
82- if len(content) > maxLen {
83- content = content[:maxLen-3] + "..."
103+ if lipgloss.Width(content) > maxLen {
104+ content = truncateToWidth(content, maxLen-3) + "..."
84105 }
85106 line := fmt.Sprintf("%s %s", dimmedStyle.Render(timeStr), content)
86107 msgLines = append(msgLines, line)
@@ -90,28 +111,47 @@ func RenderDashboard(agents []AgentInfo, swarmMessages []SwarmMessageInfo, selec
90111 }
91112
92113 // Agent list header
93- agentHeader := dimmedStyle.Render("─── Agents ───")
114+ agentHeader := renderSectionTitle("AGENT SWARM", width)
94115 sections = append(sections, agentHeader)
95116
96- // Agent list
117+ // Calculate height used by other elements to fill remaining space
118+ // Header: 3 lines + margin, Stats: 1 line, Swarm: header + messages, Agent header: 1 line, Footer: 1 line
119+ usedHeight := 6 // header (3 + margin) + stats (1) + agent header (1) + footer (1)
120+ if len(swarmMessages) > 0 {
121+ usedHeight += 1 + len(swarmMessages) // swarm header + messages
122+ }
123+ // Account for panel borders (top + bottom = 2 lines)
124+ usedHeight += 2
125+
126+ agentListHeight := height - usedHeight
127+ if agentListHeight < 3 {
128+ agentListHeight = 3
129+ }
130+
131+ // Agent list - DoubleBorder adds 2 chars each side, so content width is width-4
132+ contentWidth := width - 4
133+ if contentWidth < 20 {
134+ contentWidth = 20
135+ }
136+
97137 if len(agents) == 0 {
98138 emptyMsg := dimmedStyle.Render("No agents. Press 'n' to create one.")
99- agentList := agentListStyle.Width(width - 4).Render(emptyMsg)
139+ agentList := agentListStyle.Width(width - 2).Height(agentListHeight).Render(emptyMsg)
100140 sections = append(sections, agentList)
101141 } else {
102142 var agentLines []string
103143 for i, a := range agents {
104144 isLoading := loadingSet[a.ID]
105- line := renderAgentLine(a, i == selectedIdx, isLoading, spinnerView, width-8)
145+ line := renderAgentLine(a, i == selectedIdx, isLoading, spinnerView, contentWidth)
106146 agentLines = append(agentLines, line)
107147 }
108148 content := strings.Join(agentLines, "\n")
109- agentList := agentListStyle.Width(width - 4).Render(content)
149+ agentList := agentListStyle.Width(width - 2).Height(agentListHeight).Render(content)
110150 sections = append(sections, agentList)
111151 }
112152
113153 // Footer with hint
114- hint := dimmedStyle.Render("Press ? for help")
154+ hint := dimmedStyle.Render("[ ? ] HELP · [ n ] NEW AGENT · [ b ] BROADCAST")
115155 sections = append(sections, hint)
116156
117157 return lipgloss.JoinVertical(lipgloss.Left, sections...)
@@ -138,10 +178,10 @@ func renderAgentLine(a AgentInfo, selected, isLoading bool, spinnerView string,
138178 }
139179 }
140180
141- // Build line
181+ // Build line - use display width for truncation
142182 name := a.Name
143- if len(name) > 16 {
144- name = name[:13] + "..."
183+ if lipgloss.Width(name) > 16 {
184+ name = truncateToWidth(name, 13) + "..."
145185 }
146186
147187 stateText := StateStyle(a.State).Render(fmt.Sprintf("%-8s", a.State))
@@ -152,28 +192,31 @@ func renderAgentLine(a AgentInfo, selected, isLoading bool, spinnerView string,
152192
153193 // Calculate remaining width for last message
154194 // Account for the prefix "│ " for the message
155- usedWidth := 2 + 16 + 1 + 8 + 1 + len(a.Provider) + 2 + 4 // rough estimate
195+ // Use lipgloss.Width() for proper Unicode width calculation
196+ providerWidth := lipgloss.Width(a.Provider)
197+ usedWidth := 2 + 16 + 1 + 8 + 1 + providerWidth + 2 + 4 // rough estimate
156198 msgWidth := width - usedWidth - 8
157199 if msgWidth < 10 {
158200 msgWidth = 10
159201 }
160202
161- // Format last message (truncated)
203+ // Format last message (truncated) - use display width
162204 var msgPart string
163205 if a.LastMessage != "" {
164206 msg := strings.ReplaceAll(a.LastMessage, "\n", " ")
165- if len(msg) > msgWidth {
166- msg = msg[:msgWidth-3] + "..."
207+ if lipgloss.Width(msg) > msgWidth {
208+ msg = truncateToWidth(msg, msgWidth-3) + "..."
167209 }
168210 msgPart = dimmedStyle.Render(" │ " + msg)
169211 }
170212
171213 line := firstPart + msgPart
172214
215+ // Apply style with full width to ensure background fills the line
173216 if selected {
174- return agentItemSelectedStyle.Render(line)
217+ return agentItemSelectedStyle.Width(width).Render(line)
175218 }
176- return agentItemStyle.Render(line)
219+ return agentItemStyle.Width(width).Render(line)
177220 }
178221
179222 // AgentInfoFromCore converts a core.Agent to AgentInfo.
internal/tui/focus.go+92−32
@@ -15,7 +15,8 @@ type LogEntry struct {
1515 Content string
1616 }
1717
18-// wrapText wraps text to fit within maxWidth, preserving words.
18+// wrapText wraps text to fit within maxWidth display columns, preserving words.
19+// Uses lipgloss.Width() for proper Unicode character width calculation.
1920 func wrapText(text string, maxWidth int) []string {
2021 if maxWidth <= 0 {
2122 maxWidth = 80
@@ -38,7 +39,10 @@ func wrapText(text string, maxWidth int) []string {
3839
3940 currentLine := words[0]
4041 for _, word := range words[1:] {
41- if len(currentLine)+1+len(word) <= maxWidth {
42+ // Use lipgloss.Width() for proper Unicode width calculation
43+ lineWidth := lipgloss.Width(currentLine)
44+ wordWidth := lipgloss.Width(word)
45+ if lineWidth+1+wordWidth <= maxWidth {
4246 currentLine += " " + word
4347 } else {
4448 lines = append(lines, currentLine)
@@ -55,9 +59,8 @@ func wrapText(text string, maxWidth int) []string {
5559 func RenderFocusView(agent AgentInfo, logs []LogEntry, width, height int, isLoading bool, spinnerView string) string {
5660 var sections []string
5761
58- // Header with agent name
59- headerText := fmt.Sprintf("═══ AGENT: %s ═══", agent.Name)
60- header := headerStyle.Width(width).Render(headerText)
62+ // Header with agent name - spans full width
63+ header := renderFocusHeader(agent.Name, width)
6164 sections = append(sections, header)
6265
6366 // Agent info panel
@@ -72,11 +75,11 @@ func RenderFocusView(agent AgentInfo, logs []LogEntry, width, height int, isLoad
7275 fmt.Sprintf("%s %s", labelStyle.Render("Provider:"), valueStyle.Render(agent.Provider)),
7376 }
7477 infoContent := strings.Join(infoLines, " ")
75- infoPanel := panelStyle.Width(width - 4).Render(infoContent)
78+ infoPanel := panelStyle.Width(width - 2).Render(infoContent)
7679 sections = append(sections, infoPanel)
7780
78- // Logs panel
79- logTitle := panelTitleStyle.Render("── Conversation ──")
81+ // Logs panel - use full-width section title
82+ logTitle := renderSectionTitle("CONVERSATION LOG", width)
8083 sections = append(sections, logTitle)
8184
8285 // Calculate available height for logs
@@ -87,12 +90,15 @@ func RenderFocusView(agent AgentInfo, logs []LogEntry, width, height int, isLoad
8790 }
8891
8992 var logLines []string
93+ // Panel is rendered with logStyle.Width(width - 2).Padding(0, 2)
94+ // Content width = width - 2, minus 4 for padding (2 each side) = width - 6
95+ panelContentWidth := width - 6
9096 if len(logs) == 0 {
9197 logLines = append(logLines, dimmedStyle.Render("No conversation history."))
9298 } else {
93- // Render all log entries
99+ // Render all log entries to fill panel content area
94100 for _, entry := range logs {
95- entryLines := renderLogEntry(entry, width-6)
101+ entryLines := renderLogEntry(entry, panelContentWidth)
96102 logLines = append(logLines, entryLines...)
97103 }
98104
@@ -103,11 +109,11 @@ func RenderFocusView(agent AgentInfo, logs []LogEntry, width, height int, isLoad
103109 }
104110
105111 logContent := strings.Join(logLines, "\n")
106- logPanel := logStyle.Width(width - 4).Height(logHeight).Render(logContent)
112+ logPanel := logStyle.Width(width-2).Height(logHeight).Padding(0, 2).Render(logContent)
107113 sections = append(sections, logPanel)
108114
109115 // Footer
110- hint := dimmedStyle.Render("Esc: back | m: message | r: relaunch | s: stop | c: configure")
116+ hint := dimmedStyle.Render("[ ESC ] BACK · [ m ] MESSAGE · [ r ] RELAUNCH · [ s ] STOP")
111117 sections = append(sections, hint)
112118
113119 return lipgloss.JoinVertical(lipgloss.Left, sections...)
@@ -117,9 +123,8 @@ func RenderFocusView(agent AgentInfo, logs []LogEntry, width, height int, isLoad
117123 func RenderFocusViewWithViewport(agent AgentInfo, vp viewport.Model, width int, isLoading bool, spinnerView string, autoScroll bool) string {
118124 var sections []string
119125
120- // Header with agent name
121- headerText := fmt.Sprintf("═══ AGENT: %s ═══", agent.Name)
122- header := headerStyle.Width(width).Render(headerText)
126+ // Header with agent name - spans full width
127+ header := renderFocusHeader(agent.Name, width)
123128 sections = append(sections, header)
124129
125130 // Agent info panel
@@ -134,47 +139,64 @@ func RenderFocusViewWithViewport(agent AgentInfo, vp viewport.Model, width int,
134139 fmt.Sprintf("%s %s", labelStyle.Render("Provider:"), valueStyle.Render(agent.Provider)),
135140 }
136141 infoContent := strings.Join(infoLines, " ")
137- infoPanel := panelStyle.Width(width - 4).Render(infoContent)
142+ infoPanel := panelStyle.Width(width - 2).Render(infoContent)
138143 sections = append(sections, infoPanel)
139144
140- // Conversation title with scroll indicator
145+ // Conversation title with scroll indicator - spans full width
141146 scrollInfo := ""
142147 if !autoScroll {
143- scrollInfo = dimmedStyle.Render(" (scrolled)")
148+ scrollInfo = " ↑ SCROLLED"
144149 }
145- logTitle := panelTitleStyle.Render("── Conversation ──") + scrollInfo
150+ logTitle := renderSectionTitleWithSuffix("CONVERSATION LOG", scrollInfo, width)
146151 sections = append(sections, logTitle)
147152
148153 // Viewport content (scrollable)
149- vpView := logStyle.Width(width - 4).Render(vp.View())
154+ // Add horizontal padding (2 spaces each side) for content inside panel border
155+ vpView := logStyle.Width(width-2).Padding(0, 2).Render(vp.View())
150156 sections = append(sections, vpView)
151157
152158 // Footer with scroll hints
153- hint := dimmedStyle.Render("Esc: back | m: message | ↑↓/PgUp/PgDn: scroll | G/End: bottom")
159+ hint := dimmedStyle.Render("[ ESC ] BACK · [ m ] MESSAGE · [ ↑↓ ] SCROLL · [ G ] BOTTOM")
154160 sections = append(sections, hint)
155161
156162 return lipgloss.JoinVertical(lipgloss.Left, sections...)
157163 }
158164
165+// logBgColor is the background color for log entries (same as colorBgPanel)
166+var logBgColor = colorBgPanel
167+
159168 func renderLogEntry(entry LogEntry, maxWidth int) []string {
160- roleStyle := RoleStyle(entry.Role)
169+ // Get the role's foreground color and create a style with background
170+ roleColor := RoleColor(entry.Role)
171+ prefixStyle := lipgloss.NewStyle().
172+ Foreground(roleColor).
173+ Background(logBgColor)
174+
175+ // Content style - just background, no foreground override
176+ contentStyle := lipgloss.NewStyle().
177+ Background(logBgColor)
161178
162179 var prefix string
163180 switch entry.Role {
164181 case "user":
165- prefix = "YOU: "
182+ prefix = "YOU: "
166183 case "assistant":
167- prefix = "AI: "
184+ prefix = "AI: "
168185 case "system":
169- prefix = "SYS: "
186+ prefix = "SYS: "
170187 case "tool":
171- prefix = "TOOL: "
188+ prefix = "TOOL:"
172189 default:
173- prefix = "???: "
190+ prefix = "???:"
174191 }
175192
176- // Calculate content width (accounting for prefix on first line, indent on rest)
177- contentWidth := maxWidth - len(prefix) - 2
193+ // Inside padding: 1 space on left and right of all content
194+ const padLeft = 1
195+ const padRight = 1
196+
197+ // Calculate content width (accounting for prefix, padding, and gap after prefix)
198+ prefixWidth := len(prefix) + 1 // +1 for space after prefix
199+ contentWidth := maxWidth - prefixWidth - padLeft - padRight
178200 if contentWidth < 20 {
179201 contentWidth = 20
180202 }
@@ -183,13 +205,33 @@ func renderLogEntry(entry LogEntry, maxWidth int) []string {
183205 wrappedLines := wrapText(entry.Content, contentWidth)
184206
185207 var result []string
186- indent := strings.Repeat(" ", len(prefix))
208+ indent := strings.Repeat(" ", prefixWidth)
209+
210+ // Add top padding (empty line with background)
211+ emptyLine := contentStyle.Width(maxWidth).Render("")
212+ result = append(result, emptyLine)
187213
188214 for i, line := range wrappedLines {
215+ // Pad the line content to fill remaining width
216+ lineLen := lipgloss.Width(line)
217+ remainingWidth := contentWidth - lineLen
218+ if remainingWidth < 0 {
219+ remainingWidth = 0
220+ }
221+ paddedLine := line + strings.Repeat(" ", remainingWidth+padRight)
222+
189223 if i == 0 {
190- result = append(result, roleStyle.Render(prefix)+line)
224+ // First line: left pad + styled prefix + space + content with background
225+ leftPad := contentStyle.Render(strings.Repeat(" ", padLeft))
226+ styledPrefix := prefixStyle.Render(prefix)
227+ styledContent := contentStyle.Render(" " + paddedLine)
228+ result = append(result, leftPad+styledPrefix+styledContent)
191229 } else {
192- result = append(result, roleStyle.Render(indent)+line)
230+ // Continuation lines: left pad + indent + content with background
231+ leftPad := contentStyle.Render(strings.Repeat(" ", padLeft))
232+ styledIndent := contentStyle.Render(indent)
233+ styledContent := contentStyle.Render(paddedLine)
234+ result = append(result, leftPad+styledIndent+styledContent)
193235 }
194236 }
195237
@@ -203,3 +245,21 @@ func LogEntryFromMemory(m *store.Memory) LogEntry {
203245 Content: m.Content,
204246 }
205247 }
248+
249+// renderFocusHeader renders the focus view header spanning full width.
250+func renderFocusHeader(agentName string, width int) string {
251+ // Format: ◆─── ⬡ AGENT: name ⬡ ───◆ with dashes filling the remaining space
252+ // Use lipgloss.Width() for proper Unicode display width calculation
253+ titleText := " ⬡ AGENT: " + agentName + " ⬡ "
254+ titleDisplayWidth := lipgloss.Width(titleText)
255+ // Total fixed chars: ◆ (1) on each side = 2
256+ availableWidth := width - titleDisplayWidth - 2
257+ if availableWidth < 4 {
258+ availableWidth = 4
259+ }
260+ leftDashes := availableWidth / 2
261+ rightDashes := availableWidth - leftDashes
262+
263+ line := "◆" + strings.Repeat("─", leftDashes) + titleText + strings.Repeat("─", rightDashes) + "◆"
264+ return headerStyle.Width(width).Render(line)
265+}
internal/tui/help.go+1−1
@@ -32,7 +32,7 @@ var helpItems = []helpItem{
3232 // RenderHelp renders the help overlay.
3333 func RenderHelp(width, height int) string {
3434 var lines []string
35- lines = append(lines, titleStyle.Render("⌨ Keyboard Shortcuts"))
35+ lines = append(lines, titleStyle.Render("◆═══ ⬡ COMMAND REFERENCE ⬡ ═══◆"))
3636 lines = append(lines, "")
3737
3838 maxKeyLen := 0
internal/tui/input.go+11−0
@@ -175,6 +175,17 @@ func (m InputModel) View() string {
175175 return inputStyle.Render(m.textInput.View())
176176 }
177177
178+// ViewAlways renders the input bar, showing placeholder when not active.
179+func (m InputModel) ViewAlways(width int) string {
180+ if m.mode != InputModeNone {
181+ // Active - show the actual input
182+ return inputStyle.Width(width - 2).Render(m.textInput.View())
183+ }
184+ // Inactive - show placeholder prompt
185+ placeholder := dimmedStyle.Render("Press 'm' to message, 'b' to broadcast...")
186+ return inputStyle.Width(width - 2).Render(placeholder)
187+}
188+
178189 // Reset clears the input.
179190 func (m *InputModel) Reset() {
180191 m.textInput.Reset()
internal/tui/netindicator.go+14−14
@@ -85,12 +85,12 @@ func (n NetIndicator) Init() tea.Cmd {
8585
8686 // View renders the network indicator.
8787 func (n NetIndicator) View() string {
88- // Define the bar characters
88+ // Define the bar characters - use block elements for CRT feel
8989 const (
90- barEmpty = "─"
90+ barEmpty = "░"
9191 barFilled = "█"
92- barLeft = "["
93- barRight = "]"
92+ barLeft = "▐"
93+ barRight = "▌"
9494 )
9595
9696 // Get style based on activity
@@ -100,7 +100,7 @@ func (n NetIndicator) View() string {
100100 switch n.activity {
101101 case NetActivityIdle:
102102 style = lipgloss.NewStyle().Foreground(colorMuted)
103- label = "IDLE"
103+ label = "◇ IDLE"
104104 // For idle, show a static dim bar
105105 bar := barLeft
106106 for i := 0; i < n.width; i++ {
@@ -110,12 +110,12 @@ func (n NetIndicator) View() string {
110110 return style.Render(label + " " + bar)
111111
112112 case NetActivityLLM:
113- style = lipgloss.NewStyle().Foreground(colorAccent).Bold(true)
114- label = "LLM "
113+ style = lipgloss.NewStyle().Foreground(colorAssistant).Bold(true)
114+ label = "◆ LLM "
115115
116116 case NetActivityMCP:
117- style = lipgloss.NewStyle().Foreground(colorSecondary).Bold(true)
118- label = "MCP "
117+ style = lipgloss.NewStyle().Foreground(colorTeal).Bold(true)
118+ label = "◆ MCP "
119119 }
120120
121121 // Build the bouncing bar
@@ -135,8 +135,8 @@ func (n NetIndicator) View() string {
135135
136136 // ViewCompact renders a compact version for small screens.
137137 func (n NetIndicator) ViewCompact() string {
138- // Simpler animation frames for compact view
139- frames := []string{"◐", "◓", "◑", "◒"}
138+ // Simpler animation frames for compact view - hexagonal theme
139+ frames := []string{"⬡", "⬢", "⬡", "⬢"}
140140
141141 var style lipgloss.Style
142142 var label string
@@ -144,14 +144,14 @@ func (n NetIndicator) ViewCompact() string {
144144 switch n.activity {
145145 case NetActivityIdle:
146146 style = lipgloss.NewStyle().Foreground(colorMuted)
147- return style.Render("○ IDLE")
147+ return style.Render("◇ IDLE")
148148
149149 case NetActivityLLM:
150- style = lipgloss.NewStyle().Foreground(colorAccent).Bold(true)
150+ style = lipgloss.NewStyle().Foreground(colorAssistant).Bold(true)
151151 label = "LLM"
152152
153153 case NetActivityMCP:
154- style = lipgloss.NewStyle().Foreground(colorSecondary).Bold(true)
154+ style = lipgloss.NewStyle().Foreground(colorTeal).Bold(true)
155155 label = "MCP"
156156 }
157157
internal/tui/styles.go+136−46
@@ -1,72 +1,92 @@
11 package tui
22
33 import (
4+ "strings"
5+
46 "github.com/charmbracelet/lipgloss"
57 )
68
7-// Colors - Retro 80s/90s CRT aesthetic
9+// Colors - Retro-futuristic aesthetic based on Zoea Nova brand
10+// Brand colors from logo: #9D00FF (electric purple), #00FFCC (bright teal)
811 var (
9- // Primary colors
10- colorPrimary = lipgloss.Color("#00FF00") // Classic green terminal
11- colorSecondary = lipgloss.Color("#00AAAA") // Cyan
12- colorAccent = lipgloss.Color("#FFAA00") // Amber/Orange
13- colorWarning = lipgloss.Color("#FF5500") // Warning orange
14- colorError = lipgloss.Color("#FF0000") // Error red
15- colorMuted = lipgloss.Color("#666666") // Muted gray
16-
17- // Background
18- colorBg = lipgloss.Color("#0A0A0A") // Near black
19- colorBgAlt = lipgloss.Color("#1A1A1A") // Slightly lighter
20- colorBorder = lipgloss.Color("#333333") // Border gray
12+ // Brand colors
13+ colorBrand = lipgloss.Color("#9D00FF") // Electric purple (from logo)
14+ colorTeal = lipgloss.Color("#00FFCC") // Bright teal (from logo)
15+ colorBrandDim = lipgloss.Color("#6B00B3") // Dimmed purple for subtle accents
16+ colorTealDim = lipgloss.Color("#00AA99") // Dimmed teal
17+
18+ // Role colors (per design doc: user=green, assistant=magenta, system=cyan, tool=yellow)
19+ colorUser = lipgloss.Color("#00FF66") // Bright green for user messages
20+ colorAssistant = lipgloss.Color("#FF00CC") // Magenta/pink for assistant (complements brand purple)
21+ colorSystem = lipgloss.Color("#00CCFF") // Cyan for system messages
22+ colorTool = lipgloss.Color("#FFCC00") // Yellow/gold for tool calls
23+
24+ // Semantic colors
25+ colorWarning = lipgloss.Color("#FF6600") // Warning orange
26+ colorError = lipgloss.Color("#FF3366") // Error red-pink
27+ colorSuccess = lipgloss.Color("#00FF66") // Success green
28+ colorMuted = lipgloss.Color("#5555AA") // Muted purple-gray
29+
30+ // Backgrounds - deep space with purple undertones
31+ colorBg = lipgloss.Color("#08080F") // Deep space black
32+ colorBgAlt = lipgloss.Color("#101018") // Slightly lighter
33+ colorBgPanel = lipgloss.Color("#14141F") // Panel background
34+ colorBorder = lipgloss.Color("#2A2A55") // Purple-tinted border
35+ colorBorderHi = lipgloss.Color("#4040AA") // Highlighted border
36+
37+ // Legacy aliases for compatibility
38+ colorPrimary = colorBrand
39+ colorSecondary = colorTeal
40+ colorAccent = colorTeal
2141 )
2242
23-// Styles
43+// Styles - Retro-futuristic command center aesthetic
2444 var (
2545 // Base styles
2646 baseStyle = lipgloss.NewStyle().
2747 Background(colorBg)
2848
29- // Header
49+ // Header - Bold brand presence, no border (decorative lines in content)
3050 headerStyle = lipgloss.NewStyle().
3151 Bold(true).
32- Foreground(colorPrimary).
52+ Foreground(colorBrand).
3353 Background(colorBgAlt).
34- Padding(0, 1).
3554 MarginBottom(1)
3655
3756 titleStyle = lipgloss.NewStyle().
3857 Bold(true).
39- Foreground(colorPrimary)
58+ Foreground(colorBrand)
4059
41- // Status bar
60+ // Status bar - teal on dark, command center vibe
4261 statusBarStyle = lipgloss.NewStyle().
43- Foreground(colorSecondary).
62+ Foreground(colorTeal).
4463 Background(colorBgAlt).
4564 Padding(0, 1)
4665
47- // Agent list
66+ // Agent list - double border for that 80s terminal aesthetic
4867 agentListStyle = lipgloss.NewStyle().
49- Border(lipgloss.RoundedBorder()).
68+ Border(lipgloss.DoubleBorder()).
5069 BorderForeground(colorBorder).
51- Padding(0, 1)
70+ Background(colorBgPanel)
5271
5372 agentItemStyle = lipgloss.NewStyle().
54- Foreground(colorPrimary).
73+ Foreground(colorTeal).
74+ Background(colorBgPanel).
5575 Padding(0, 1)
5676
5777 agentItemSelectedStyle = lipgloss.NewStyle().
5878 Foreground(colorBg).
59- Background(colorPrimary).
79+ Background(colorBrand).
6080 Bold(true).
6181 Padding(0, 1)
6282
63- // Agent states
83+ // Agent states - distinct colors for each state
6484 stateRunningStyle = lipgloss.NewStyle().
65- Foreground(colorPrimary).
85+ Foreground(colorSuccess).
6686 Bold(true)
6787
6888 stateIdleStyle = lipgloss.NewStyle().
69- Foreground(colorSecondary)
89+ Foreground(colorTeal)
7090
7191 stateStoppedStyle = lipgloss.NewStyle().
7292 Foreground(colorMuted)
@@ -75,72 +95,82 @@ var (
7595 Foreground(colorError).
7696 Bold(true)
7797
78- // Logs/Messages
98+ // Logs/Messages - conversation styling per design doc
99+ // No padding here - padding is added to content lines directly
79100 logStyle = lipgloss.NewStyle().
80101 Border(lipgloss.RoundedBorder()).
81102 BorderForeground(colorBorder).
82- Padding(0, 1)
103+ Background(colorBgPanel)
83104
105+ // Role colors per design doc: user=green, assistant=magenta, system=cyan, tool=yellow
84106 logUserStyle = lipgloss.NewStyle().
85- Foreground(colorAccent)
107+ Foreground(colorUser).
108+ Bold(true)
86109
87110 logAssistantStyle = lipgloss.NewStyle().
88- Foreground(colorPrimary)
111+ Foreground(colorAssistant)
89112
90113 logSystemStyle = lipgloss.NewStyle().
91- Foreground(colorMuted).
114+ Foreground(colorSystem).
92115 Italic(true)
93116
94117 logToolStyle = lipgloss.NewStyle().
95- Foreground(colorSecondary).
118+ Foreground(colorTool).
96119 Italic(true)
97120
98- // Input
121+ // Input - teal border, brand prompt
99122 inputStyle = lipgloss.NewStyle().
100123 Border(lipgloss.RoundedBorder()).
101- BorderForeground(colorSecondary).
124+ BorderForeground(colorTeal).
125+ Background(colorBgPanel).
102126 Padding(0, 1)
103127
104128 inputPromptStyle = lipgloss.NewStyle().
105- Foreground(colorAccent).
129+ Foreground(colorBrand).
106130 Bold(true)
107131
108- // Help
132+ // Help - double border for prominence, centered brand feel
109133 helpStyle = lipgloss.NewStyle().
110134 Border(lipgloss.DoubleBorder()).
111- BorderForeground(colorSecondary).
135+ BorderForeground(colorBrand).
136+ Background(colorBgPanel).
112137 Padding(1, 2).
113138 Margin(1)
114139
115140 helpKeyStyle = lipgloss.NewStyle().
116- Foreground(colorAccent).
141+ Foreground(colorTeal).
117142 Bold(true)
118143
119144 helpDescStyle = lipgloss.NewStyle().
120145 Foreground(colorMuted)
121146
122- // Panels
147+ // Panels - consistent with agent list
123148 panelStyle = lipgloss.NewStyle().
124149 Border(lipgloss.RoundedBorder()).
125150 BorderForeground(colorBorder).
151+ Background(colorBgPanel).
126152 Padding(0, 1)
127153
128154 panelTitleStyle = lipgloss.NewStyle().
129- Foreground(colorSecondary).
130- Bold(true).
131- Padding(0, 1)
155+ Foreground(colorTeal).
156+ Bold(true)
132157
133- // Info/Stats
158+ // Info/Stats - brand colors for values
134159 labelStyle = lipgloss.NewStyle().
135160 Foreground(colorMuted)
136161
137162 valueStyle = lipgloss.NewStyle().
138- Foreground(colorPrimary).
163+ Foreground(colorBrand).
139164 Bold(true)
140165
141166 // Dimmed/Disabled
142167 dimmedStyle = lipgloss.NewStyle().
143168 Foreground(colorMuted)
169+
170+ // Highlight style for important info
171+ highlightStyle = lipgloss.NewStyle().
172+ Foreground(colorTeal).
173+ Bold(true)
144174 )
145175
146176 // StateStyle returns the appropriate style for an agent state.
@@ -174,3 +204,63 @@ func RoleStyle(role string) lipgloss.Style {
174204 return logSystemStyle
175205 }
176206 }
207+
208+// RoleColor returns the foreground color for a message role.
209+func RoleColor(role string) lipgloss.Color {
210+ switch role {
211+ case "user":
212+ return colorUser
213+ case "assistant":
214+ return colorAssistant
215+ case "system":
216+ return colorSystem
217+ case "tool":
218+ return colorTool
219+ default:
220+ return colorSystem
221+ }
222+}
223+
224+// renderSectionTitle renders a section title that spans the full width.
225+func renderSectionTitle(title string, width int) string {
226+ return renderSectionTitleWithSuffix(title, "", width)
227+}
228+
229+// renderSectionTitleWithSuffix renders a section title with an optional suffix (like scroll indicator).
230+func renderSectionTitleWithSuffix(title, suffix string, width int) string {
231+ // Format: ◈── TITLE ──◈ [suffix] with dashes filling the remaining space
232+ // Account for: 2 (◈ markers) + 2 (─ adjacent to markers) + title + 2 (spaces around title) = 4
233+ titleWithSpaces := " " + title + " "
234+ titleDisplayWidth := lipgloss.Width(titleWithSpaces)
235+ suffixDisplayWidth := lipgloss.Width(suffix)
236+ // Total fixed chars: ◈─ (2) on each side = 4
237+ availableWidth := width - titleDisplayWidth - 4 - suffixDisplayWidth
238+ if availableWidth < 2 {
239+ availableWidth = 2
240+ }
241+ leftDashes := availableWidth / 2
242+ rightDashes := availableWidth - leftDashes
243+
244+ line := "◈─" + strings.Repeat("─", leftDashes) + titleWithSpaces + strings.Repeat("─", rightDashes) + "─◈"
245+ if suffix != "" {
246+ line += suffix
247+ }
248+ return panelTitleStyle.Width(width).Render(line)
249+}
250+
251+// truncateToWidth truncates a string to fit within maxWidth display columns.
252+// Uses rune-aware iteration to avoid cutting multi-byte characters.
253+func truncateToWidth(s string, maxWidth int) string {
254+ if maxWidth <= 0 {
255+ return ""
256+ }
257+ currentWidth := 0
258+ for i, r := range s {
259+ charWidth := lipgloss.Width(string(r))
260+ if currentWidth+charWidth > maxWidth {
261+ return s[:i]
262+ }
263+ currentWidth += charWidth
264+ }
265+ return s
266+}
internal/tui/tui_test.go+945−5
@@ -1,15 +1,28 @@
11 package tui
22
33 import (
4+ "regexp"
5+ "strings"
46 "testing"
7+ "time"
58
69 tea "github.com/charmbracelet/bubbletea"
10+ "github.com/charmbracelet/lipgloss"
11+ "github.com/muesli/termenv"
712 "github.com/xonecas/zoea-nova/internal/config"
813 "github.com/xonecas/zoea-nova/internal/core"
914 "github.com/xonecas/zoea-nova/internal/provider"
1015 "github.com/xonecas/zoea-nova/internal/store"
1116 )
1217
18+// ansiRegex matches ANSI escape codes
19+var ansiRegex = regexp.MustCompile(`\x1b\[[0-9;]*m`)
20+
21+// stripANSI removes all ANSI escape codes from a string
22+func stripANSI(s string) string {
23+ return ansiRegex.ReplaceAllString(s, "")
24+}
25+
1326 func setupTestModel(t *testing.T) (Model, func()) {
1427 t.Helper()
1528
@@ -213,6 +226,39 @@ func TestInputModel(t *testing.T) {
213226 }
214227 }
215228
229+func TestInputModelViewAlways(t *testing.T) {
230+ input := NewInputModel()
231+ width := 100
232+
233+ // Test inactive state - should show placeholder
234+ inactiveView := input.ViewAlways(width)
235+ if inactiveView == "" {
236+ t.Error("ViewAlways should return non-empty view even when inactive")
237+ }
238+ if !strings.Contains(inactiveView, "Press") {
239+ t.Error("inactive view should contain placeholder text")
240+ }
241+
242+ // Check width
243+ inactiveWidth := lipgloss.Width(inactiveView)
244+ if inactiveWidth != width {
245+ t.Errorf("inactive view width = %d, want %d", inactiveWidth, width)
246+ }
247+
248+ // Test active state
249+ input.SetMode(InputModeBroadcast, "")
250+ activeView := input.ViewAlways(width)
251+ if activeView == "" {
252+ t.Error("ViewAlways should return non-empty view when active")
253+ }
254+
255+ // Check width when active
256+ activeWidth := lipgloss.Width(activeView)
257+ if activeWidth != width {
258+ t.Errorf("active view width = %d, want %d", activeWidth, width)
259+ }
260+}
261+
216262 func TestRenderHelp(t *testing.T) {
217263 help := RenderHelp(80, 24)
218264 if help == "" {
@@ -277,9 +323,903 @@ func TestStateStyle(t *testing.T) {
277323 }
278324
279325 func TestRoleStyle(t *testing.T) {
280- // Just ensure these don't panic
281- _ = RoleStyle("user")
282- _ = RoleStyle("assistant")
283- _ = RoleStyle("system")
284- _ = RoleStyle("unknown")
326+ // Force color output to verify ANSI codes
327+ lipgloss.SetColorProfile(termenv.TrueColor)
328+ defer lipgloss.SetColorProfile(termenv.Ascii)
329+
330+ testText := "test"
331+ roles := []string{"user", "assistant", "system", "tool", "unknown"}
332+ rendered := make(map[string]string)
333+
334+ for _, role := range roles {
335+ style := RoleStyle(role)
336+ output := style.Render(testText)
337+ rendered[role] = output
338+
339+ // Each should produce non-empty output
340+ if output == "" {
341+ t.Errorf("role %q should produce non-empty output", role)
342+ }
343+
344+ // Each should contain ANSI codes
345+ if !strings.Contains(output, "\x1b[") {
346+ t.Errorf("role %q should contain ANSI escape codes, got: %q", role, output)
347+ }
348+
349+ // Each should contain the test text
350+ if !strings.Contains(output, testText) {
351+ t.Errorf("role %q output should contain %q", role, testText)
352+ }
353+ }
354+
355+ // Verify distinct styles for main roles
356+ if rendered["user"] == rendered["assistant"] {
357+ t.Error("user and assistant should have distinct styles")
358+ }
359+ if rendered["system"] == rendered["tool"] {
360+ t.Error("system and tool should have distinct styles")
361+ }
362+}
363+
Cut short: this commit's diff is over 1000 lines.