xonecas.io
62159
Sy

symb / commit 435ef6b

feat: better git info in statusbar

xonecas2026-02-19 435ef6be749c0ba12efb5dda7b241de9f5440355 parent d8df70f

8 files changed

TODO.md+5−0
@@ -11,6 +11,11 @@ Timeout shouldn't interrupt subagents, this is breaking the subagent tool.
1111 exceeded while awaiting headers) view
1212 ```
1313
14+```
15+→ SubAgent(max_iterations=5, prompt=Find status bar branch name label and gi…, type=explore)
16+← sub-agent failed: LLM stream failed: Post "https://opencode.ai/zen/v1/chat/completions": unexpected EOF view
17+```
18+
1419 - [ ]: Undo tracking is too slow, every turn feels like an eternity.
1520
1621 We need to be smarter and take a snapshot when the user sends a new message. And save it as a restore point
go.mod+1−3
@@ -11,11 +11,9 @@ require (
1111 github.com/charmbracelet/x/ansi v0.11.6
1212 github.com/charmbracelet/x/exp/golden v0.0.0-20260209194814-eeb2896ac759
1313 github.com/charmbracelet/x/powernap v0.0.0-20260209132835-6b065b8ba62c
14- github.com/hexops/gotextdiff v1.0.3
1514 github.com/rs/zerolog v1.34.0
16- github.com/sacenox/go-opencode-ai-zen-sdk v0.0.2
15+ github.com/sacenox/go-opencode-ai-zen-sdk v0.0.3
1716 github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82
18- golang.org/x/net v0.50.0
1917 modernc.org/sqlite v1.45.0
2018 mvdan.cc/sh/v3 v3.12.0
2119 )
go.sum+2−8
@@ -92,14 +92,10 @@ github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7
9292 github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
9393 github.com/rs/zerolog v1.34.0 h1:k43nTLIwcTVQAncfCw4KZ2VY6ukYoZaBPNOE8txlOeY=
9494 github.com/rs/zerolog v1.34.0/go.mod h1:bJsvje4Z08ROH4Nhs5iH600c3IkWhwp44iRc54W6wYQ=
95-github.com/sacenox/go-opencode-ai-zen-sdk v0.0.0-20260217230320-035924957efe h1:A5+tr2aMC9eLLknAOSEmtrzwqJE3oBAMtniY/jgzdLo=
96-github.com/sacenox/go-opencode-ai-zen-sdk v0.0.0-20260217230320-035924957efe/go.mod h1:MK7Zno/U0BRk1/YDHKisc3ZXoQhcTyGnU9SbEuQ/c34=
97-github.com/sacenox/go-opencode-ai-zen-sdk v0.0.0-20260218233948-be38230e6c9a h1:Pnr+ikm8pNBFb7HQpFKQW/p1N5MuuqRDZDjaSFZFfTg=
98-github.com/sacenox/go-opencode-ai-zen-sdk v0.0.0-20260218233948-be38230e6c9a/go.mod h1:MK7Zno/U0BRk1/YDHKisc3ZXoQhcTyGnU9SbEuQ/c34=
99-github.com/sacenox/go-opencode-ai-zen-sdk v0.0.1 h1:i0S5jrvDdsjr7+F7CeP88ahkZkq901nLg5leWj/jrf4=
100-github.com/sacenox/go-opencode-ai-zen-sdk v0.0.1/go.mod h1:MK7Zno/U0BRk1/YDHKisc3ZXoQhcTyGnU9SbEuQ/c34=
10195 github.com/sacenox/go-opencode-ai-zen-sdk v0.0.2 h1:V6SOmoYmYLpQDxiqubKiGOQsG5pwBPj4uTdwlMcT8Go=
10296 github.com/sacenox/go-opencode-ai-zen-sdk v0.0.2/go.mod h1:MK7Zno/U0BRk1/YDHKisc3ZXoQhcTyGnU9SbEuQ/c34=
97+github.com/sacenox/go-opencode-ai-zen-sdk v0.0.3 h1:dARO0XgMEHRv2oeo926R/4CaSUVn83+MTrlgnn0G7CY=
98+github.com/sacenox/go-opencode-ai-zen-sdk v0.0.3/go.mod h1:MK7Zno/U0BRk1/YDHKisc3ZXoQhcTyGnU9SbEuQ/c34=
10399 github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82 h1:6C8qej6f1bStuePVkLSFxoU22XBS165D3klxlzRg8F4=
104100 github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82/go.mod h1:xe4pgH49k4SsmkQq5OT8abwhWmnzkhpgnXeekbx2efw=
105101 github.com/sourcegraph/jsonrpc2 v0.2.1 h1:2GtljixMQYUYCmIg7W9aF2dFmniq/mOr2T9tFRh6zSQ=
@@ -112,8 +108,6 @@ golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 h1:mgKeJMpvi0yx/sU5GsxQ7p6s2
112108 golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546/go.mod h1:j/pmGrbnkbPtQfxEe5D0VQhZC6qKbfKifgD0oM7sR70=
113109 golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c=
114110 golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU=
115-golang.org/x/net v0.50.0 h1:ucWh9eiCGyDR3vtzso0WMQinm2Dnt8cFMuQa9K33J60=
116-golang.org/x/net v0.50.0/go.mod h1:UgoSli3F/pBgdJBHCTc+tp3gmrU4XswgGRgtnwWTfyM=
117111 golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
118112 golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
119113 golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
internal/tui/messages.go+45−4
@@ -112,8 +112,11 @@ type LSPDiagnosticsMsg struct {
112112
113113 // gitBranchMsg carries the current git branch and dirty status.
114114 type gitBranchMsg struct {
115- branch string
116- dirty bool
115+ branch string
116+ dirty bool
117+ added int
118+ modified int
119+ removed int
117120 }
118121
119122 // ---------------------------------------------------------------------------
@@ -127,6 +130,42 @@ func frameTick() tea.Cmd {
127130 })
128131 }
129132
133+func gitStatusCounts() (added int, modified int, removed int) {
134+ out, err := exec.Command("git", "status", "--porcelain").Output()
135+ if err != nil {
136+ return 0, 0, 0
137+ }
138+ trimmed := strings.TrimSpace(string(out))
139+ if trimmed == "" {
140+ return 0, 0, 0
141+ }
142+ for _, line := range strings.Split(trimmed, "\n") {
143+ if line == "" {
144+ continue
145+ }
146+ if strings.HasPrefix(line, "??") {
147+ added++
148+ continue
149+ }
150+ if len(line) < 2 {
151+ continue
152+ }
153+ x := line[0]
154+ y := line[1]
155+ if x == 'A' || y == 'A' {
156+ added++
157+ }
158+ if x == 'M' || y == 'M' || x == 'R' || y == 'R' || x == 'C' || y == 'C' {
159+ modified++
160+ }
161+ if x == 'D' || y == 'D' {
162+ removed++
163+ }
164+ }
165+ return added, modified, removed
166+}
167+
168+
130169 // gitBranchCmd runs git to detect the current branch and dirty status.
131170 func gitBranchCmd() tea.Cmd {
132171 return func() tea.Msg {
@@ -138,7 +177,8 @@ func gitBranchCmd() tea.Cmd {
138177 if err := exec.Command("git", "diff", "--quiet", "HEAD").Run(); err != nil {
139178 dirty = true // exit code 1 = dirty
140179 }
141- return gitBranchMsg{branch: branch, dirty: dirty}
180+ added, modified, removed := gitStatusCounts()
181+ return gitBranchMsg{branch: branch, dirty: dirty, added: added, modified: modified, removed: removed}
142182 }
143183 }
144184
@@ -154,7 +194,8 @@ func gitBranchTick() tea.Cmd {
154194 if err := exec.Command("git", "diff", "--quiet", "HEAD").Run(); err != nil {
155195 dirty = true
156196 }
157- return gitBranchMsg{branch: branch, dirty: dirty}
197+ added, modified, removed := gitStatusCounts()
198+ return gitBranchMsg{branch: branch, dirty: dirty, added: added, modified: modified, removed: removed}
158199 })
159200 }
160201
internal/tui/styles.go+7−0
@@ -68,6 +68,10 @@ type Styles struct {
6868
6969 // Status bar
7070 StatusText lipgloss.Style // Status bar text
71+ StatusAdd lipgloss.Style // Statusbar added count
72+ StatusMod lipgloss.Style // Statusbar modified count
73+ StatusDel lipgloss.Style // Statusbar removed count
74+
7175 }
7276
7377 // DefaultStyles builds the complete style set.
@@ -89,5 +93,8 @@ func DefaultStyles() Styles {
8993 Clickable: lipgloss.NewStyle().Background(ColorLinkBg).Foreground(ColorHighlight),
9094
9195 StatusText: bg.Foreground(ColorDim),
96+ StatusAdd: bg.Foreground(lipgloss.Color("2")),
97+ StatusMod: bg.Foreground(lipgloss.Color("3")),
98+ StatusDel: bg.Foreground(lipgloss.Color("1")),
9299 }
93100 }
internal/tui/tui.go+4−0
@@ -234,6 +234,10 @@ type Model struct {
234234 providerConfigName string // TOML config key (e.g. "zen-pickle")
235235 gitBranch string // Current git branch name
236236 gitDirty bool // Working tree has uncommitted changes
237+ gitAdded int
238+ gitModified int
239+ gitRemoved int
240+
237241 lastNetError string // Last LLM network error (truncated for display)
238242 llmInFlight bool // True while an LLM turn is in progress
239243
internal/tui/update_status.go+3−0
@@ -13,5 +13,8 @@ func (m *Model) handleLSPDiag(_ LSPDiagnosticsMsg) Model {
1313 func (m Model) handleGitBranch(msg gitBranchMsg) (tea.Model, tea.Cmd) {
1414 m.gitBranch = msg.branch
1515 m.gitDirty = msg.dirty
16+ m.gitAdded = msg.added
17+ m.gitModified = msg.modified
18+ m.gitRemoved = msg.removed
1619 return m, gitBranchTick()
1720 }
internal/tui/view_status.go+11−1
@@ -1,6 +1,7 @@
11 package tui
22
33 import (
4+ "strconv"
45 "strings"
56
67 "charm.land/lipgloss/v2"
@@ -20,7 +21,16 @@ func (m Model) renderStatusBar(b *strings.Builder, bgFill lipgloss.Style) {
2021 if m.gitDirty {
2122 branch += "*"
2223 }
23- leftParts = append(leftParts, m.styles.StatusText.Render(" "+branch))
24+ branchPart := m.styles.StatusText.Render(" " + branch)
25+ if m.gitAdded+m.gitModified+m.gitRemoved > 0 {
26+ counts := strings.Join([]string{
27+ m.styles.StatusAdd.Render("+" + strconv.Itoa(m.gitAdded)),
28+ m.styles.StatusMod.Render("~" + strconv.Itoa(m.gitModified)),
29+ m.styles.StatusDel.Render("-" + strconv.Itoa(m.gitRemoved)),
30+ }, m.styles.StatusText.Render(" "))
31+ branchPart = strings.Join([]string{branchPart, counts}, m.styles.StatusText.Render(" "))
32+ }
33+ leftParts = append(leftParts, branchPart)
2434 }
2535
2636 left := strings.Join(leftParts, m.styles.StatusText.Render(" "))