xonecas.io
60255
Zn

Zoea-Nova / commit 6c43b12

Add scrollable sidebar with mouse-aware scrolling and purple theme

- Remove sidebar border container, render content directly with inline scrollbar
- Add 1 character left padding to sidebar content
- Add purple vertical border separator between sidebar and conversation (colorBorder)
- Fix width calculations: scrollbar is 1 char, columnGap is 3 chars (space + │ + space)

Sidebar scrolling:
- Add sidebar scroll state to Model (sidebarScrollOffset, sidebarTotalLines)
- Clip sidebar content to viewport height when exceeds visible area
- Render inline scrollbar on right edge (1 character: █ or │)

Mouse-aware scrolling:
- Enable mouse support in program initialization (tea.WithMouseCellMotion)
- Add handleMouseInFocus() to route mouse wheel events by X position
- Mouse wheel over sidebar (left 33%) scrolls sidebar
- Mouse wheel over conversation (right side) scrolls conversation
- Keyboard fallback: Shift+Up/Down for sidebar, plain Up/Down for conversation

Visual consistency:
- Update renderSectionTitle to render continuous dashes when title is empty
- Add matching bottom borders for both sidebar and conversation
- Use colorBorder (#2A2A55) for all borders: vertical separator, scrollbars (track + thumb)
- Unified purple theme throughout focus view

Update RenderFocusViewWithViewport signature to accept sidebarScrollOffset
Update all test call sites to pass 0 for sidebar scroll offset

xonecas2026-02-09 6c43b12c838a91d5763ec49122d5f9ef8dc57d80 parent 74efcb5

11 files changed

AGENTS.md+1−0
@@ -15,6 +15,7 @@ TUI for orchestrating AI agents (Myses) that play SpaceMolt via MCP. Go 1.24.2,
1515 **Tool call storage format** (`internal/constants/constants.go:71-81`): Assistant messages with tools stored as `[TOOL_CALLS]id:name:args|id:name:args`. Tool results stored as `id:content`. This allows parsing without JSON in hot path and survives SQLite TEXT storage.
1616
1717 **Snapshot compaction** (`internal/core/mysis.go:1344-1403`): Only latest `get_*` tool result kept per tool. Prevents state-heavy tools (get_status, get_ship) from crowding context. Non-snapshot tools (login, travel, mine) always kept.
18+ "small_model": "opencode/gpt-5-nano",
1819
1920 **Orphaned tool call removal** (`internal/core/mysis.go:1429-1465`): Assistant messages with tool calls removed if no matching tool result exists. Prevents OpenAI API crashes from malformed sequences after context compression.
2021
cmd/zoea/main.go+1−1
@@ -148,7 +148,7 @@ func main() {
148148 bus.Close()
149149 })
150150
151- program := tea.NewProgram(model, tea.WithAltScreen())
151+ program := tea.NewProgram(model, tea.WithAltScreen(), tea.WithMouseCellMotion())
152152
153153 // Handle shutdown in a goroutine
154154 go func() {
internal/tui/app.go+66−4
@@ -78,6 +78,10 @@ type Model struct {
7878 viewport viewport.Model
7979 viewportTotalLines int // total lines in viewport content
8080
81+ // Sidebar scroll state
82+ sidebarScrollOffset int // current scroll position for game state sidebar
83+ sidebarTotalLines int // total lines in sidebar content
84+
8185 // Network activity indicator
8286 netIndicator NetIndicator
8387 activeNetworkOps int // Count of active network operations (LLM/MCP calls)
@@ -202,11 +206,11 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
202206 vpHeight = 5
203207 }
204208 // Viewport width must match the conversation log width calculation in focus.go
205- // Two-column layout: Sidebar (33% of width) + Gap (2) + Conversation
209+ // Two-column layout: Sidebar (33% of width) + Gap (3: space+│+space) + Conversation
206210 // Sidebar takes 33% of terminal width (multiply first to avoid precision loss)
207211 // Viewport content width = conversation - 2 (for scrollbar)
208212 sidebarWidth := (msg.Width * 33) / 100
209- const columnGap = 2
213+ const columnGap = 3
210214 conversationWidth := msg.Width - sidebarWidth - columnGap
211215 m.viewport.Width = conversationWidth - 2 // -2 for scrollbar
212216 m.viewport.Height = vpHeight
@@ -216,6 +220,16 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
216220 m.updateViewportContent()
217221 }
218222
223+ case tea.MouseMsg:
224+ // Handle mouse wheel scrolling in focus view
225+ if m.view == ViewFocus {
226+ return m.handleMouseInFocus(msg)
227+ }
228+ // For other views, let viewport handle it
229+ var cmd tea.Cmd
230+ m.viewport, cmd = m.viewport.Update(msg)
231+ return m, cmd
232+
219233 case tea.KeyMsg:
220234 // Handle input mode first
221235 if m.input.IsActive() {
@@ -356,7 +370,7 @@ func (m Model) View() string {
356370 }
357371 }
358372
359- content = RenderFocusViewWithViewport(focusMysis, m.viewport, m.width, isLoading, m.spinner.View(), m.verboseJSON, m.viewportTotalLines, focusIndex, totalMyses, m.currentTick, gameStateSnapshots, m.err)
373+ content = RenderFocusViewWithViewport(focusMysis, m.viewport, m.width, isLoading, m.spinner.View(), m.verboseJSON, m.viewportTotalLines, focusIndex, totalMyses, m.currentTick, gameStateSnapshots, m.sidebarScrollOffset, m.err)
360374 } else {
361375 // Convert swarm messages for display (reversed so most recent is first)
362376 swarmInfos := make([]SwarmMessageInfo, len(m.swarmMessages))
@@ -624,6 +638,23 @@ func (m Model) handleFocusKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
624638 // Re-render viewport content with new verbose setting
625639 m.updateViewportContent()
626640 return m, nil
641+
642+ // Sidebar scrolling (Shift+Up/Down for sidebar, plain Up/Down for conversation)
643+ case msg.String() == "shift+up":
644+ if m.sidebarScrollOffset > 0 {
645+ m.sidebarScrollOffset--
646+ }
647+ return m, nil
648+
649+ case msg.String() == "shift+down":
650+ // sidebarTotalLines is calculated during render, but we need to constrain here
651+ // For now, just increment - render will constrain to valid range
652+ m.sidebarScrollOffset++
653+ return m, nil
654+
655+ case msg.String() == "shift+home":
656+ m.sidebarScrollOffset = 0
657+ return m, nil
627658 }
628659
629660 // Pass other keys to viewport for scrolling
@@ -633,6 +664,37 @@ func (m Model) handleFocusKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
633664 return m, cmd
634665 }
635666
667+func (m Model) handleMouseInFocus(msg tea.MouseMsg) (tea.Model, tea.Cmd) {
668+ // Only handle mouse wheel events
669+ if msg.Type != tea.MouseWheelUp && msg.Type != tea.MouseWheelDown {
670+ // Pass other mouse events to viewport
671+ var cmd tea.Cmd
672+ m.viewport, cmd = m.viewport.Update(msg)
673+ return m, cmd
674+ }
675+
676+ // Calculate sidebar width (same calculation as in rendering)
677+ sidebarWidth := (m.width * 33) / 100
678+
679+ // Check if mouse is over sidebar (X coordinate < sidebarWidth)
680+ if msg.X < sidebarWidth {
681+ // Scroll sidebar
682+ if msg.Type == tea.MouseWheelUp {
683+ if m.sidebarScrollOffset > 0 {
684+ m.sidebarScrollOffset--
685+ }
686+ } else if msg.Type == tea.MouseWheelDown {
687+ m.sidebarScrollOffset++
688+ }
689+ return m, nil
690+ }
691+
692+ // Mouse is over conversation - pass to viewport
693+ var cmd tea.Cmd
694+ m.viewport, cmd = m.viewport.Update(msg)
695+ return m, cmd
696+}
697+
636698 func (m Model) handleInputKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
637699 switch {
638700 case key.Matches(msg, keys.Escape):
@@ -960,7 +1022,7 @@ func (m *Model) updateViewportContent() {
9601022 // Two-column layout: Game State Sidebar | Conversation Log
9611023 // Sidebar takes 33% of terminal width (multiply first to avoid precision loss)
9621024 sidebarWidth := (m.width * 33) / 100
963- const columnGap = 2
1025+ const columnGap = 3 // space + │ + space
9641026 conversationWidth := m.width - sidebarWidth - columnGap
9651027
9661028 // Content width for conversation log (accounting for scrollbar)
internal/tui/error_display_test.go+1−0
@@ -70,6 +70,7 @@ func TestErrorDisplayInFocusView(t *testing.T) {
7070 1,
7171 0,
7272 nil, // gameStateSnapshots
73+ 0, // sidebarScrollOffset
7374 testErr,
7475 )
7576
internal/tui/focus.go+78−20
@@ -167,7 +167,7 @@ func RenderFocusView(mysis MysisInfo, logs []LogEntry, width, height int, isLoad
167167 }
168168
169169 // RenderFocusViewWithViewport renders the detailed mysis view using a scrollable viewport.
170-func RenderFocusViewWithViewport(mysis MysisInfo, vp viewport.Model, width int, isLoading bool, spinnerView string, verbose bool, totalLines int, focusIndex, totalMyses int, currentTick int64, gameStateSnapshots []*store.GameStateSnapshot, err error) string {
170+func RenderFocusViewWithViewport(mysis MysisInfo, vp viewport.Model, width int, isLoading bool, spinnerView string, verbose bool, totalLines int, focusIndex, totalMyses int, currentTick int64, gameStateSnapshots []*store.GameStateSnapshot, sidebarScrollOffset int, err error) string {
171171 var sections []string
172172
173173 // Header with mysis name - spans full width (2 lines)
@@ -199,7 +199,7 @@ func RenderFocusViewWithViewport(mysis MysisInfo, vp viewport.Model, width int,
199199 // Two-column layout: Game State Sidebar | Conversation Log
200200 // Sidebar takes 33% of terminal width (multiply first to avoid precision loss)
201201 sidebarWidth := (width * 33) / 100 // Total width including border
202- const columnGap = 2 // Gap between columns
202+ const columnGap = 3 // Gap between columns (space + │ + space)
203203 conversationWidth := width - sidebarWidth - columnGap
204204
205205 // Conversation title with scroll indicator
@@ -216,21 +216,69 @@ func RenderFocusViewWithViewport(mysis MysisInfo, vp viewport.Model, width int,
216216 // Game state title
217217 gameStateTitle := renderSectionTitle("GAME STATE", sidebarWidth)
218218
219- // Render game state sidebar content (returns lines without border)
220- gameStateSidebarContent := renderGameStateSidebar(gameStateSnapshots, currentTick, sidebarWidth)
219+ // Render game state sidebar content directly (no border, just content + scrollbar)
220+ // Content width: sidebarWidth - leftPadding(1) - scrollbar(1)
221+ const sidebarScrollbarWidth = 1 // "█" or "│"
222+ const sidebarLeftPadding = 1 // Space on left edge
223+ sidebarContentWidth := sidebarWidth - sidebarLeftPadding - sidebarScrollbarWidth
224+ gameStateSidebarAllContent := renderGameStateSidebar(gameStateSnapshots, currentTick, sidebarContentWidth)
225+ sidebarTotalLines := len(gameStateSidebarAllContent)
226+
227+ // Clip sidebar content to viewport height
228+ sidebarHeight := vp.Height
229+ gameStateSidebarContent := gameStateSidebarAllContent
230+
231+ // Clip to visible area if content exceeds height
232+ if len(gameStateSidebarAllContent) > sidebarHeight {
233+ startLine := sidebarScrollOffset
234+ endLine := sidebarScrollOffset + sidebarHeight
235+ if startLine < 0 {
236+ startLine = 0
237+ }
238+ if endLine > len(gameStateSidebarAllContent) {
239+ endLine = len(gameStateSidebarAllContent)
240+ startLine = endLine - sidebarHeight
241+ if startLine < 0 {
242+ startLine = 0
243+ }
244+ }
245+ gameStateSidebarContent = gameStateSidebarAllContent[startLine:endLine]
246+ }
247+
248+ // Render sidebar scrollbar
249+ sidebarScrollbarStr := renderScrollbar(sidebarHeight, sidebarTotalLines, sidebarScrollOffset)
250+ sidebarScrollbarLines := strings.Split(sidebarScrollbarStr, "\n")
251+
252+ // Build sidebar lines with scrollbar (no border)
253+ gameStateSidebarLines := make([]string, sidebarHeight)
254+
255+ for i := 0; i < sidebarHeight; i++ {
256+ var contentLine string
257+ if i < len(gameStateSidebarContent) {
258+ contentLine = gameStateSidebarContent[i]
259+ } else {
260+ contentLine = ""
261+ }
221262
222- // Render sidebar with border using lipgloss
223- // Width() sets CONTENT width, padding is added on top, border is INCLUDED in width
224- // So: content_width + padding(2) = sidebarWidth
225- // Therefore: content_width = sidebarWidth - 2
226- sidebarStyle := lipgloss.NewStyle().
227- Border(lipgloss.RoundedBorder()).
228- BorderForeground(colorBorder).
229- Width(sidebarWidth-2). // -2 for padding (border is included in width)
230- Padding(0, 1) // 1 space padding on left/right
263+ // Pad content to fill width
264+ contentWidth := lipgloss.Width(contentLine)
265+ padding := sidebarContentWidth - contentWidth
266+ if padding < 0 {
267+ padding = 0
268+ }
269+ contentLine = contentLine + strings.Repeat(" ", padding)
231270
232- sidebarRendered := sidebarStyle.Render(strings.Join(gameStateSidebarContent, "\n"))
233- gameStateSidebarLines := strings.Split(sidebarRendered, "\n")
271+ // Add scrollbar
272+ var scrollLine string
273+ if i < len(sidebarScrollbarLines) {
274+ scrollLine = sidebarScrollbarLines[i]
275+ } else {
276+ scrollLine = " "
277+ }
278+
279+ // Add left padding space
280+ gameStateSidebarLines[i] = " " + contentLine + scrollLine
281+ }
234282
235283 // Render scrollbar based on viewport state
236284 scrollOffset := vp.YOffset
@@ -262,10 +310,14 @@ func RenderFocusViewWithViewport(mysis MysisInfo, vp viewport.Model, width int,
262310 conversationView := logStyle.Width(conversationWidth).Render(conversationContent)
263311 conversationViewLines := strings.Split(conversationView, "\n")
264312
265- // Combine titles
313+ // Vertical border between columns
314+ verticalBorderStyle := lipgloss.NewStyle().Foreground(colorBorder) // Purple-tinted border
315+ verticalBorder := verticalBorderStyle.Render("│")
316+
317+ // Combine titles with vertical border
266318 titleRow := lipgloss.JoinHorizontal(lipgloss.Top,
267319 gameStateTitle,
268- strings.Repeat(" ", columnGap),
320+ " "+verticalBorder+" ",
269321 logTitle,
270322 )
271323 sections = append(sections, titleRow)
@@ -293,15 +345,21 @@ func RenderFocusViewWithViewport(mysis MysisInfo, vp viewport.Model, width int,
293345
294346 combinedLine := lipgloss.JoinHorizontal(lipgloss.Top,
295347 leftLine,
296- strings.Repeat(" ", columnGap),
348+ " "+verticalBorder+" ",
297349 rightLine,
298350 )
299351 sections = append(sections, combinedLine)
300352 }
301353
302- // Bottom border for conversation log - matches top border style
354+ // Bottom borders for both sidebar and conversation log with vertical border
355+ sidebarBottomBorder := renderSectionTitle("", sidebarWidth)
303356 logBottomBorder := renderSectionTitle("", conversationWidth)
304- sections = append(sections, strings.Repeat(" ", sidebarWidth)+strings.Repeat(" ", columnGap)+logBottomBorder)
357+ bottomRow := lipgloss.JoinHorizontal(lipgloss.Top,
358+ sidebarBottomBorder,
359+ " "+verticalBorder+" ",
360+ logBottomBorder,
361+ )
362+ sections = append(sections, bottomRow)
305363
306364 // Footer with scroll hints, verbose toggle, and error status
307365 verboseHint := ""
internal/tui/focus_header_test.go+1−1
@@ -73,7 +73,7 @@ func TestFocusViewHeaderPresence(t *testing.T) {
7373 vp.GotoTop()
7474
7575 // Render focus view
76- output := RenderFocusViewWithViewport(mysis, vp, tt.termWidth, false, "⬡", false, len(contentLines), 1, 1, 0, nil, nil)
76+ output := RenderFocusViewWithViewport(mysis, vp, tt.termWidth, false, "⬡", false, len(contentLines), 1, 1, 0, nil, 0, nil)
7777
7878 // Split into lines
7979 lines := strings.Split(output, "\n")
internal/tui/focus_test.go+1−1
@@ -265,7 +265,7 @@ func TestRenderFocusViewWithScrollbar(t *testing.T) {
265265
266266 width := 100
267267 totalLines := 50
268- output := RenderFocusViewWithViewport(mysis, vp, width, false, "⬡", false, totalLines, 1, 1, 0, nil, nil)
268+ output := RenderFocusViewWithViewport(mysis, vp, width, false, "⬡", false, totalLines, 1, 1, 0, nil, 0, nil)
269269
270270 // Should contain scrollbar characters
271271 if !strings.Contains(output, "█") && !strings.Contains(output, "│") {
internal/tui/golden_test.go+1−1
@@ -473,7 +473,7 @@ func TestFocusViewWithViewport(t *testing.T) {
473473 vp.SetContent(strings.Join(contentLines, "\n"))
474474 vp.GotoTop()
475475
476- output := RenderFocusViewWithViewport(tt.mysis, vp, tt.width, false, "⠋", false, tt.totalLines, 1, 1, 0, nil, nil)
476+ output := RenderFocusViewWithViewport(tt.mysis, vp, tt.width, false, "⠋", false, tt.totalLines, 1, 1, 0, nil, 0, nil)
477477
478478 t.Run("ANSI", func(t *testing.T) {
479479 golden.RequireEqual(t, []byte(output))
internal/tui/layout_test.go+1−1
@@ -206,7 +206,7 @@ func TestFocusViewLayoutCalculations(t *testing.T) {
206206 }()
207207
208208 // Render focus view
209- output := RenderFocusViewWithViewport(mysis, vp, tt.termWidth, false, "⬡", false, tt.numLogs, 1, 1, 0, nil, nil)
209+ output := RenderFocusViewWithViewport(mysis, vp, tt.termWidth, false, "⬡", false, tt.numLogs, 1, 1, 0, nil, 0, nil)
210210
211211 // Basic validations
212212 if output == "" {
internal/tui/scrollbar.go+3−3
@@ -24,7 +24,7 @@ func renderScrollbar(height int, totalLines int, scrollOffset int) string {
2424 // If content fits in viewport, show empty track
2525 if totalLines <= height {
2626 track := make([]string, height)
27- trackStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("240")) // Dim gray
27+ trackStyle := lipgloss.NewStyle().Foreground(colorBorder) // Purple-tinted border
2828 for i := 0; i < height; i++ {
2929 track[i] = trackStyle.Render(scrollbarTrack)
3030 }
@@ -56,8 +56,8 @@ func renderScrollbar(height int, totalLines int, scrollOffset int) string {
5656
5757 // Build scrollbar lines
5858 lines := make([]string, height)
59- trackStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("240")) // Dim gray
60- thumbStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("245")) // Lighter gray
59+ trackStyle := lipgloss.NewStyle().Foreground(colorBorder) // Purple-tinted border
60+ thumbStyle := lipgloss.NewStyle().Foreground(colorBorder) // Purple-tinted border (same color)
6161
6262 for i := 0; i < height; i++ {
6363 if i >= thumbPos && i < thumbPos+thumbSize {
internal/tui/styles.go+11−0
@@ -215,6 +215,17 @@ func renderSectionTitle(title string, width int) string {
215215
216216 // renderSectionTitleWithSuffix renders a section title with an optional suffix (like scroll indicator).
217217 func renderSectionTitleWithSuffix(title, suffix string, width int) string {
218+ // If title is empty, render continuous dashes (for bottom borders)
219+ if title == "" && suffix == "" {
220+ // Format: ⬧────────────⬧ (continuous dashes, no gap)
221+ dashCount := width - 4 // -4 for ⬧─ on each side
222+ if dashCount < 0 {
223+ dashCount = 0
224+ }
225+ line := "⬧─" + strings.Repeat("─", dashCount) + "─⬧"
226+ return panelTitleStyle.Width(width).Render(line)
227+ }
228+
218229 // Format: ⬧── TITLE ──⬧ [suffix] with dashes filling the remaining space
219230 // Account for: 2 (⬧ markers) + 2 (─ adjacent to markers) + title + 2 (spaces around title) = 4
220231 titleWithSpaces := " " + title + " "