xonecas.io
62159
Sy

symb / commit 69b0b42

feat: statusbar?

xonecas2026-02-15 69b0b42e2170e6457d65aa063e3c928e38d13a5e parent 3afe694

12 files changed

cmd/symb/main.go+1−1
@@ -93,7 +93,7 @@ func main() {
9393 }
9494
9595 p := tea.NewProgram(
96- tui.New(prov, svc.proxy, tools, providerCfg.Model, svc.webCache, sessionID, tsIndex, svc.deltaTracker, svc.fileTracker),
96+ tui.New(prov, svc.proxy, tools, providerCfg.Model, svc.webCache, sessionID, tsIndex, svc.deltaTracker, svc.fileTracker, providerName),
9797 tea.WithFilter(tui.MouseEventFilter),
9898 )
9999 svc.lspManager.SetCallback(func(absPath string, lines map[int]int) {
docs/DESIGN.md+10−7
@@ -114,8 +114,7 @@ Needs an undo.
114114
115115 - 60fps baseline
116116 - Optimized frame render logic.
117-
118-## Features waiting implementation for current version:
117+- Integrates with hl theme.
119118
120119 ### Context management
121120
@@ -126,31 +125,35 @@ Needs an undo.
126125 <undo if most recent agent message>
127126 ```
128127 Refactor so it shows two lines as above with text right aligned. Remove existing `---` separator completly
128+**DONE**
129129
130130 2. Gather baseline data with no context management. Then study:
131+**INPROGRESS**
131132
132133 https://manus.im/blog/Context-Engineering-for-AI-Agents-Lessons-from-Building-Manus
133134 (Search for more resources like the one above, build a document with concise knowledge base (500 lines max)
134135
135136 Implement findings?
136137
138+## Features waiting implementation for current version:
139+
137140 ### Statusbar implementation
138141
139142 (in order: left to right)
140143
141144 Left:
142145
143-- Show current branch + dirty status in status bar.
144-- Show lsp warnings and errors count for opened editor.
146+- Show current branch + dirty status in status bar. (needs to be updated every X frames/time) to be responsive
147+- Show lsp warnings and errors count for opened editor content, if any.
145148
146149 Right (right aligned text)
147150
148151 - Network errors to providers (llm, and exa_search), truncated.
149152 - NOTE: Animated icon becomes red until next successful request.
150-- Context info: tokens out/in + total context size.
151153 - Current llm provider config name
152-- Show name and version
153-- Animated icon.
154+- Animated icon:
155+ - Slow animation when idle.
156+ - Fast animation while a request to the LLM is in-flight (whole turn)
154157
155158 ### File Search modal
156159
internal/tui/golden_test.go+1−1
@@ -26,7 +26,7 @@ func TestLayout(t *testing.T) {
2626
2727 for _, tt := range tests {
2828 t.Run(tt.name, func(t *testing.T) {
29- m := New(nil, nil, nil, "test-model", nil, "test-session", nil, nil, nil)
29+ m := New(nil, nil, nil, "test-model", nil, "test-session", nil, nil, nil, "test-provider")
3030 updated, _ := m.Update(tea.WindowSizeMsg{Width: tt.width, Height: tt.height})
3131 m = updated.(Model)
3232
internal/tui/messages.go+39−0
@@ -3,6 +3,8 @@ package tui
33 import (
44 "encoding/json"
55 "os"
6+ "os/exec"
7+ "strings"
68 "time"
79
810 tea "charm.land/bubbletea/v2"
@@ -73,6 +75,12 @@ type LSPDiagnosticsMsg struct {
7375 Lines map[int]int // bufRow (0-indexed) -> max severity (1=error, 2=warning)
7476 }
7577
78+// gitBranchMsg carries the current git branch and dirty status.
79+type gitBranchMsg struct {
80+ branch string
81+ dirty bool
82+}
83+
7684 // ---------------------------------------------------------------------------
7785 // ELM commands
7886 // ---------------------------------------------------------------------------
@@ -84,6 +92,37 @@ func frameTick() tea.Cmd {
8492 })
8593 }
8694
95+// gitBranchCmd runs git to detect the current branch and dirty status.
96+func gitBranchCmd() tea.Cmd {
97+ return func() tea.Msg {
98+ branch := ""
99+ if out, err := exec.Command("git", "rev-parse", "--abbrev-ref", "HEAD").Output(); err == nil {
100+ branch = strings.TrimSpace(string(out))
101+ }
102+ dirty := false
103+ if err := exec.Command("git", "diff", "--quiet", "HEAD").Run(); err != nil {
104+ dirty = true // exit code 1 = dirty
105+ }
106+ return gitBranchMsg{branch: branch, dirty: dirty}
107+ }
108+}
109+
110+// gitBranchTick schedules a git branch re-poll after a 5-second delay.
111+func gitBranchTick() tea.Cmd {
112+ return tea.Tick(5*time.Second, func(time.Time) tea.Msg {
113+ // Run git commands inline after the delay to avoid an extra message type.
114+ branch := ""
115+ if out, err := exec.Command("git", "rev-parse", "--abbrev-ref", "HEAD").Output(); err == nil {
116+ branch = strings.TrimSpace(string(out))
117+ }
118+ dirty := false
119+ if err := exec.Command("git", "diff", "--quiet", "HEAD").Run(); err != nil {
120+ dirty = true
121+ }
122+ return gitBranchMsg{branch: branch, dirty: dirty}
123+ })
124+}
125+
87126 func (m Model) sendToLLM(userInput string) tea.Cmd {
88127 return func() tea.Msg { return llmUserMsg{content: userInput} }
89128 }
internal/tui/mouse.go+4−0
@@ -290,6 +290,8 @@ func (m *Model) handleConvClick(wrappedLine int) tea.Cmd {
290290 m.editor.SetGutterMarkers(GitFileMarkers(m.ctx, entry.filePath))
291291 m.editor.DiagnosticLines = nil
292292 m.editorFilePath = absPath
293+ m.lspErrors = 0
294+ m.lspWarnings = 0
293295 if entry.line > 0 {
294296 m.editor.GotoLine(entry.line)
295297 }
@@ -353,6 +355,8 @@ func (m *Model) tryOpenFilePath(text string) tea.Cmd {
353355 m.editor.SetGutterMarkers(GitFileMarkers(m.ctx, path))
354356 m.editor.DiagnosticLines = nil
355357 m.editorFilePath = absPath
358+ m.lspErrors = 0
359+ m.lspWarnings = 0
356360 if lineNum > 0 {
357361 m.editor.GotoLine(lineNum)
358362 }
internal/tui/testdata/TestLayout/120x40/ANSI.golden+1−1
@@ -37,4 +37,4 @@
3737  │  
3838  │  
3939 ────────────────────────────────────────────────────────────┴───────────────────────────────────────────────────────────
40- symb ⣾  
40+ test-provider ⠋ 
internal/tui/testdata/TestLayout/120x40/Stripped.golden+1−1
@@ -37,4 +37,4 @@
3737 │
3838 │
3939 ────────────────────────────────────────────────────────────┴───────────────────────────────────────────────────────────
40- symb ⣾
40+ test-provider ⠋
internal/tui/testdata/TestLayout/80x24/ANSI.golden+1−1
@@ -21,4 +21,4 @@
2121  │  
2222  │  
2323 ────────────────────────────────────────┴───────────────────────────────────────
24- symb ⣾  
24+ test-provider ⠋ 
internal/tui/testdata/TestLayout/80x24/Stripped.golden+1−1
@@ -21,4 +21,4 @@
2121 │
2222 │
2323 ────────────────────────────────────────┴───────────────────────────────────────
24- symb ⣾
24+ test-provider ⠋
internal/tui/tui.go+18−10
@@ -6,7 +6,6 @@ import (
66 "regexp"
77 "time"
88
9- "charm.land/bubbles/v2/spinner"
109 tea "charm.land/bubbletea/v2"
1110 "charm.land/lipgloss/v2"
1211 "github.com/xonecas/symb/internal/constants"
@@ -184,7 +183,6 @@ type Model struct {
184183 width, height int
185184
186185 // Sub-models
187- spinner spinner.Model
188186 editor editor.Model
189187 agentInput editor.Model
190188
@@ -249,17 +247,26 @@ type Model struct {
249247 // Frame loop
250248 streamDirty bool // New streaming content arrived since last rebuild
251249 frameLines []string // Per-frame cache of wrapped conv lines (cleared each Update)
250+
251+ // Statusbar state
252+ providerConfigName string // TOML config key (e.g. "zen-pickle")
253+ gitBranch string // Current git branch name
254+ gitDirty bool // Working tree has uncommitted changes
255+ lspErrors int // Error count for current editor file
256+ lspWarnings int // Warning count for current editor file
257+ lastNetError string // Last LLM network error (truncated for display)
258+ llmInFlight bool // True while an LLM turn is in progress
259+
260+ // Statusbar animation
261+ spinFrame int // Current braille spinner frame index
262+ spinFrameAt time.Time // When the current frame was set
252263 }
253264
254265 // New creates a new TUI model.
255-func New(prov provider.Provider, proxy *mcp.Proxy, tools []mcp.Tool, modelID string, db *store.Cache, sessionID string, idx *treesitter.Index, dt *delta.Tracker, ft FileReadResetter) Model {
266+func New(prov provider.Provider, proxy *mcp.Proxy, tools []mcp.Tool, modelID string, db *store.Cache, sessionID string, idx *treesitter.Index, dt *delta.Tracker, ft FileReadResetter, providerConfigName string) Model {
256267 sty := DefaultStyles()
257268 cursorStyle := lipgloss.NewStyle().Foreground(ColorHighlight)
258269
259- s := spinner.New()
260- s.Spinner = spinner.Dot
261- s.Style = cursorStyle.Background(ColorBg)
262-
263270 selStyle := sty.Selection
264271
265272 ed := editor.New()
@@ -299,7 +306,6 @@ func New(prov provider.Provider, proxy *mcp.Proxy, tools []mcp.Tool, modelID str
299306 }
300307
301308 return Model{
302- spinner: s,
303309 editor: ed,
304310 agentInput: ai,
305311 styles: sty,
@@ -323,10 +329,12 @@ func New(prov provider.Provider, proxy *mcp.Proxy, tools []mcp.Tool, modelID str
323329
324330 streamEntryStart: -1,
325331 hoverConvLine: -1,
332+
333+ providerConfigName: providerConfigName,
326334 }
327335 }
328336
329-// Init starts spinner, cursor blink, and the 60fps frame loop.
337+// Init starts cursor blink, the 60fps frame loop, and periodic git branch polling.
330338 func (m Model) Init() tea.Cmd {
331- return tea.Batch(m.spinner.Tick, func() tea.Msg { return editor.Blink() }, frameTick())
339+ return tea.Batch(func() tea.Msg { return editor.Blink() }, frameTick(), gitBranchCmd())
332340 }
internal/tui/update.go+54−11
@@ -47,6 +47,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
4747 // -- Frame tick (60fps) — rebuild streaming entries for live updates ------
4848 case tickMsg:
4949 m.tickStreaming()
50+ m.tickSpinner(time.Time(msg))
5051 return m, frameTick()
5152
5253 // -- LLM batch (multiple messages drained from updateChan) ---------------
@@ -55,6 +56,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
5556
5657 // -- LLM user message (sent before streaming begins) ---------------------
5758 case llmUserMsg:
59+ m.llmInFlight = true
5860 return m.handleUserMsg(msg), tea.Batch(m.processLLM(), m.waitForLLMUpdate())
5961
6062 case LSPDiagnosticsMsg:
@@ -71,22 +73,23 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
7173
7274 case undoMsg:
7375 return m.handleUndo(), nil
76+
77+ case gitBranchMsg:
78+ return m.handleGitBranch(msg)
7479 }
7580
76- // Always tick spinner
81+ // Forward remaining messages to sub-models (mouse is already handled above).
82+ return m.forwardToSubModels(msg)
83+}
84+
85+// forwardToSubModels sends a non-handled message to sub-editors.
86+func (m Model) forwardToSubModels(msg tea.Msg) (tea.Model, tea.Cmd) {
7787 var cmds []tea.Cmd
7888 var cmd tea.Cmd
79- m.spinner, cmd = m.spinner.Update(msg)
89+ m.editor, cmd = m.editor.Update(msg)
90+ cmds = append(cmds, cmd)
91+ m.agentInput, cmd = m.agentInput.Update(msg)
8092 cmds = append(cmds, cmd)
81-
82- // Forward non-mouse messages to focused component
83- if _, isMouse := msg.(tea.MouseMsg); !isMouse {
84- m.editor, cmd = m.editor.Update(msg)
85- cmds = append(cmds, cmd)
86- m.agentInput, cmd = m.agentInput.Update(msg)
87- cmds = append(cmds, cmd)
88- }
89-
9093 return m, tea.Batch(cmds...)
9194 }
9295
@@ -94,10 +97,29 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
9497 func (m *Model) handleLSPDiag(msg LSPDiagnosticsMsg) Model {
9598 if msg.FilePath == m.editorFilePath {
9699 m.editor.DiagnosticLines = msg.Lines
100+ // Count errors (severity 1) and warnings (severity 2) for the statusbar.
101+ errs, warns := 0, 0
102+ for _, sev := range msg.Lines {
103+ switch sev {
104+ case 1:
105+ errs++
106+ case 2:
107+ warns++
108+ }
109+ }
110+ m.lspErrors = errs
111+ m.lspWarnings = warns
97112 }
98113 return *m
99114 }
100115
116+// handleGitBranch updates statusbar git state and schedules the next poll.
117+func (m Model) handleGitBranch(msg gitBranchMsg) (tea.Model, tea.Cmd) {
118+ m.gitBranch = msg.branch
119+ m.gitDirty = msg.dirty
120+ return m, gitBranchTick()
121+}
122+
101123 // handleResize applies a window size change and re-derives layout.
102124 func (m *Model) handleResize(msg tea.WindowSizeMsg) {
103125 m.width, m.height = msg.Width, msg.Height
@@ -233,6 +255,9 @@ func (m Model) handleLLMBatch(batch llmBatchMsg) (tea.Model, tea.Cmd) {
233255 m.applyToolResultMsg(msg)
234256
235257 case llmErrorMsg:
258+ m.llmInFlight = false
259+ m.lastNetError = msg.err.Error()
260+ m.clearStreaming()
236261 m.appendText("", m.styles.Error.Render("Error: "+msg.err.Error()), "")
237262 return m, nil
238263
@@ -243,6 +268,8 @@ func (m Model) handleLLMBatch(batch llmBatchMsg) (tea.Model, tea.Cmd) {
243268 m.totalOutputTokens += msg.outputTokens
244269
245270 case llmDoneMsg:
271+ m.llmInFlight = false
272+ m.lastNetError = ""
246273 m.demoteOldUndo()
247274 m.appendText("")
248275 sep := m.makeSeparator(msg.duration.Round(time.Second).String(), msg.timestamp,
@@ -257,6 +284,22 @@ func (m Model) handleLLMBatch(batch llmBatchMsg) (tea.Model, tea.Cmd) {
257284 return m, m.waitForLLMUpdate()
258285 }
259286
287+// brailleFrames is the spinner animation sequence.
288+var brailleFrames = []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"}
289+
290+// tickSpinner advances the braille spinner frame based on elapsed time.
291+// Slow (~500ms/frame) when idle, fast (~100ms/frame) during LLM turns.
292+func (m *Model) tickSpinner(now time.Time) {
293+ interval := 500 * time.Millisecond
294+ if m.llmInFlight {
295+ interval = 100 * time.Millisecond
296+ }
297+ if now.Sub(m.spinFrameAt) >= interval {
298+ m.spinFrame = (m.spinFrame + 1) % len(brailleFrames)
299+ m.spinFrameAt = now
300+ }
301+}
302+
260303 // tickStreaming rebuilds streaming entries when new content has arrived.
261304 func (m *Model) tickStreaming() {
262305 if m.streamDirty {
internal/tui/view.go+58−4
@@ -1,6 +1,7 @@
11 package tui
22
33 import (
4+ "fmt"
45 "strings"
56
67 tea "charm.land/bubbletea/v2"
@@ -126,14 +127,67 @@ func (m Model) renderStatusBar(b *strings.Builder, bgFill lipgloss.Style) {
126127 b.WriteString(m.styles.Border.Render(strings.Repeat("─", m.width-divX-1)))
127128 b.WriteByte('\n')
128129
129- left := m.styles.StatusText.Render(" symb")
130- spin := strings.TrimSpace(m.spinner.View())
131- gap := m.width - lipgloss.Width(left) - lipgloss.Width(spin) - 1
130+ // -- Left segments --
131+ var leftParts []string
132+
133+ // Git branch + dirty
134+ if m.gitBranch != "" {
135+ branch := m.gitBranch
136+ if m.gitDirty {
137+ branch += "*"
138+ }
139+ leftParts = append(leftParts, m.styles.StatusText.Render(" "+branch))
140+ }
141+
142+ // LSP diagnostics for current editor file
143+ if m.lspErrors > 0 || m.lspWarnings > 0 {
144+ var diags []string
145+ if m.lspErrors > 0 {
146+ diags = append(diags, m.styles.Error.Render(fmt.Sprintf("✗ %d", m.lspErrors)))
147+ }
148+ if m.lspWarnings > 0 {
149+ diags = append(diags, m.styles.Warning.Render(fmt.Sprintf("⚠ %d", m.lspWarnings)))
150+ }
151+ leftParts = append(leftParts, strings.Join(diags, m.styles.StatusText.Render(" ")))
152+ }
153+
154+ left := strings.Join(leftParts, m.styles.StatusText.Render(" "))
155+
156+ // -- Right segments --
157+ var rightParts []string
158+
159+ // Network error (truncated)
160+ if m.lastNetError != "" {
161+ errText := m.lastNetError
162+ if len(errText) > 30 {
163+ errText = errText[:30] + "…"
164+ }
165+ rightParts = append(rightParts, m.styles.Error.Render("✗ "+errText))
166+ }
167+
168+ // Provider config name
169+ rightParts = append(rightParts, m.styles.StatusText.Render(m.providerConfigName))
170+
171+ // Animated braille spinner — red on error, accent otherwise
172+ frame := brailleFrames[m.spinFrame%len(brailleFrames)]
173+ if m.lastNetError != "" {
174+ frame = m.styles.Error.Render(frame)
175+ } else {
176+ frame = lipgloss.NewStyle().Background(ColorBg).Foreground(ColorHighlight).Render(frame)
177+ }
178+ rightParts = append(rightParts, frame)
179+
180+ right := strings.Join(rightParts, m.styles.StatusText.Render(" "))
181+
182+ // -- Compose: left + gap + right + trailing space --
183+ leftW := lipgloss.Width(left)
184+ rightW := lipgloss.Width(right)
185+ gap := m.width - leftW - rightW - 1
132186 if gap < 0 {
133187 gap = 0
134188 }
135189 b.WriteString(left)
136190 b.WriteString(bgFill.Render(strings.Repeat(" ", gap)))
137- b.WriteString(spin)
191+ b.WriteString(right)
138192 b.WriteString(bgFill.Render(" "))
139193 }