xonecas.io
60255
Zn

Zoea-Nova / commit 88c4a4c

feat(tui): display reasoning content in focus view

- Add Reasoning field to LogEntry struct
- Update LogEntryFromMemory to populate reasoning
- Render reasoning below content with purple styling
- Add test coverage for reasoning display

xonecas2026-02-05 88c4a4c48dc35322dfd830db2a46de998e0223e7 parent 431e4e7

2 files changed

internal/tui/focus.go+52−0
@@ -16,6 +16,7 @@ type LogEntry struct {
1616 Source string
1717 SenderID string
1818 Content string
19+ Reasoning string // NEW: reasoning content from LLM
1920 Timestamp time.Time
2021 }
2122
@@ -246,6 +247,56 @@ func renderLogEntry(entry LogEntry, maxWidth int) []string {
246247 }
247248 }
248249
250+ // Render reasoning if present
251+ if entry.Reasoning != "" {
252+ // Add spacing line
253+ emptyLine := contentStyle.Width(maxWidth).Render("")
254+ result = append(result, emptyLine)
255+
256+ // Reasoning header in dimmed purple/magenta
257+ reasoningHeaderStyle := lipgloss.NewStyle().
258+ Foreground(lipgloss.Color("170")). // Dimmed purple
259+ Background(logBgColor)
260+
261+ reasoningStyle := lipgloss.NewStyle().
262+ Foreground(lipgloss.Color("213")). // Lighter purple for reasoning text
263+ Background(logBgColor)
264+
265+ reasoningHeader := "REASONING:"
266+ reasoningHeaderWidth := len(reasoningHeader) + 1 // +1 for space after
267+ reasoningContentWidth := maxWidth - reasoningHeaderWidth - padLeft - padRight
268+ if reasoningContentWidth < 20 {
269+ reasoningContentWidth = 20
270+ }
271+
272+ // Wrap reasoning text
273+ wrappedReasoning := wrapText(entry.Reasoning, reasoningContentWidth)
274+
275+ for i, line := range wrappedReasoning {
276+ lineLen := lipgloss.Width(line)
277+ remainingWidth := reasoningContentWidth - lineLen
278+ if remainingWidth < 0 {
279+ remainingWidth = 0
280+ }
281+ paddedLine := line + strings.Repeat(" ", remainingWidth+padRight)
282+
283+ if i == 0 {
284+ // First line: left pad + styled header + space + content
285+ leftPad := contentStyle.Render(strings.Repeat(" ", padLeft))
286+ styledHeader := reasoningHeaderStyle.Render(reasoningHeader)
287+ styledContent := reasoningStyle.Render(" " + paddedLine)
288+ result = append(result, leftPad+styledHeader+styledContent)
289+ } else {
290+ // Continuation lines: left pad + indent + content
291+ leftPad := contentStyle.Render(strings.Repeat(" ", padLeft))
292+ indent := strings.Repeat(" ", reasoningHeaderWidth)
293+ styledIndent := contentStyle.Render(indent)
294+ styledContent := reasoningStyle.Render(paddedLine)
295+ result = append(result, leftPad+styledIndent+styledContent)
296+ }
297+ }
298+ }
299+
249300 return result
250301 }
251302
@@ -260,6 +311,7 @@ func LogEntryFromMemory(m *store.Memory, currentMysisID string) LogEntry {
260311 Source: source,
261312 SenderID: m.SenderID,
262313 Content: m.Content,
314+ Reasoning: m.Reasoning, // NEW: copy reasoning field
263315 Timestamp: m.CreatedAt,
264316 }
265317 }
internal/tui/focus_test.go+40−0
@@ -1,8 +1,12 @@
11 package tui
22
33 import (
4+ "strings"
45 "testing"
6+ "time"
57
8+ "github.com/charmbracelet/lipgloss"
9+ "github.com/muesli/termenv"
610 "github.com/xonecas/zoea-nova/internal/store"
711 )
812
@@ -73,3 +77,39 @@ func TestLogEntryFromMemoryWithSender(t *testing.T) {
7377 })
7478 }
7579 }
80+
81+func TestRenderLogEntryWithReasoning(t *testing.T) {
82+ // Force color output for testing
83+ lipgloss.SetColorProfile(termenv.TrueColor)
84+ defer lipgloss.SetColorProfile(termenv.Ascii)
85+
86+ entry := LogEntry{
87+ Role: "assistant",
88+ Source: "llm",
89+ Content: "I will mine the asteroid.",
90+ Reasoning: "The asteroid contains valuable ore. I have enough fuel and cargo space.",
91+ Timestamp: time.Now(),
92+ }
93+
94+ maxWidth := 80
95+ lines := renderLogEntry(entry, maxWidth)
96+
97+ // Should have content lines + reasoning section
98+ if len(lines) < 4 {
99+ t.Errorf("Expected at least 4 lines (padding + content + reasoning header + reasoning), got %d", len(lines))
100+ }
101+
102+ // Join lines and check for reasoning content
103+ output := strings.Join(lines, "\n")
104+ if !strings.Contains(output, "REASONING:") {
105+ t.Error("Expected reasoning header 'REASONING:' in output")
106+ }
107+ if !strings.Contains(output, "The asteroid contains valuable ore") {
108+ t.Error("Expected reasoning content in output")
109+ }
110+
111+ // Verify ANSI codes are present (styling is applied)
112+ if !strings.Contains(output, "\x1b[") {
113+ t.Error("Expected ANSI escape codes (styling) in output")
114+ }
115+}