xonecas.io
62159
Sy

symb / commit 33bc9ca

fix: syntax hl lag, and breakage. Smooth 60fps now :tada:

xonecas2026-02-15 33bc9ca5c765e9eefc30c9291e0842c646a9003b parent 1b3bca6

7 files changed

README.md+6−1
@@ -21,7 +21,7 @@ Symb pairs you with an LLM, providing an agentic UI with tools the LLM can use t
2121 - **Dual-pane TUI**: Code viewer on one side, agent conversation on the other
2222 - **Mouse support**: Click on conversation log to view files, changes, and tool call outputs in the code pane in full.
2323 - **Syntax highlighting**: Via Chroma for Go and other languages
24-- **Clean aesthetic**: Dark grayscale with minimal distractions
24+- **Clean aesthetic**: Inherits your syntax highlight colors for minimal distractions
2525 - **ELM architecture**: Built with BubbleTea for solid state management
2626 - **LLM integration**: Ollama local + Opencode Zen support
2727 - **Hashline-assisted edits**: LLM edit operations use line hashes for precise, conflict-free file modifications
@@ -32,6 +32,11 @@ Symb pairs you with an LLM, providing an agentic UI with tools the LLM can use t
3232 - **Deterministic schemas**: KV-cache optimized tool definitions for reproducible LLM behavior
3333 - **Session storage**: Sessions saved to app data in sqlite file. Session management comming soon (--resume, --list, --session <ID>)
3434
35+## Syntax Theme
36+
37+The syntax highlighting theme is configured in `internal/constants/constants.go`. Change the `SyntaxTheme` constant to any of the themes listed in the file comments. Only themes with complete token coverage (60+ entries) are supported.
38+
39+
3540 ## Quick Start
3641
3742 ```bash
internal/constants/constants.go+25−54
@@ -1,60 +1,31 @@
11 package constants
22
3-// TODO: Add constants for:
4-// - highlight color for search matches
5-
6-// SyntaxTheme is the Chroma syntax highlighting theme used in the editor.
7-//
8-// TODO: AFTER MVP -- Add way to toggle theme
3+// SyntaxTheme is the Chroma syntax highlighting theme used across the TUI.
4+// UI chrome colors (grayscale ramp, accent, error) are derived from the theme
5+// via highlight.ThemePalette — theme authors only need to define the Chroma XML.
96 //
10-// Available themes:
7+// Only themes with complete token coverage (60+ entries, 10+ Generic tokens)
8+// are listed. Incomplete themes will render markdown headings, bold, italic,
9+// and diff hunks without differentiation.
1110 //
12-// Dark themes (recommended for terminals):
13-// - monokai - Classic Sublime Text theme (current default)
14-// - dracula - Popular purple/pink theme
15-// - nord - Cool bluish theme
16-// - gruvbox - Warm, retro colors
17-// - onedark - Atom's One Dark
18-// - github-dark - GitHub's dark theme
19-// - solarized-dark - Classic Solarized
20-// - doom-one - Emacs Doom theme
21-// - doom-one2 - Emacs Doom theme variant
22-// - catppuccin-mocha - Pastel dark theme
23-// - catppuccin-frappe - Pastel dark theme variant
24-// - catppuccin-macchiato - Pastel dark theme variant
25-// - tokyonight-night - Popular VSCode theme
26-// - tokyonight-storm - Tokyo Night variant
27-// - tokyonight-moon - Tokyo Night variant
28-// - aura-theme-dark - Aura dark theme
29-// - aura-theme-dark-soft - Softer Aura dark
30-// - rose-pine - Pine-inspired theme
31-// - rose-pine-moon - Rose Pine dark variant
32-// - paraiso-dark - Paraiso dark theme
33-// - native - Chroma's native dark
34-// - vim - Classic Vim colors
35-// - vulcan - Star Trek inspired
36-// - witchhazel - Purple-ish theme
37-// - xcode-dark - Xcode dark theme
38-// - hrdark - High contrast dark
11+// Dark themes:
12+// - tokyonight-night #1a1b26 81 entries
13+// - tokyonight-storm #1a1b26 81 entries
14+// - tokyonight-moon #222436 81 entries
15+// - catppuccin-mocha #1e1e2e 81 entries
16+// - catppuccin-macchiato #24273a 81 entries
17+// - catppuccin-frappe #303446 81 entries
18+// - aura-theme-dark #15141b 84 entries
19+// - aura-theme-dark-soft #15141b 84 entries
20+// - dracula #282a36 72 entries
21+// - base16-snazzy #282a36 72 entries
22+// - vulcan #282c34 72 entries
23+// - doom-one2 #282c34 62 entries
24+// - github-dark #0d1117 43 entries
25+// - ashen #121212 66 entries
26+// - average #000000 72 entries
3927 //
4028 // Light themes:
41-// - github - GitHub's light theme
42-// - solarized-light - Classic Solarized light
43-// - gruvbox-light - Gruvbox light variant
44-// - catppuccin-latte - Pastel light theme
45-// - tokyonight-day - Tokyo Night light
46-// - rose-pine-dawn - Rose Pine light variant
47-// - paraiso-light - Paraiso light theme
48-// - modus-operandi - Emacs light theme
49-// - monokailight - Monokai light variant
50-// - vs - Visual Studio light
51-// - xcode - Xcode light theme
52-//
53-// Pure black (#000000) background:
54-// - average, modus-vivendi, rrt, swapoff, vim
55-//
56-// Other themes:
57-// - fruity, autumn, friendly, colorful, tango, algol, arduino
58-// - base16-snazzy, borland, emacs, pygments, rainbow_dash
59-// - and more...
60-const SyntaxTheme = "modus-vivendi"
29+// - tokyonight-day #e1e2e7 81 entries
30+// - catppuccin-latte #eff1f5 81 entries
31+const SyntaxTheme = "aura-theme-dark"
internal/highlight/highlight.go+133−0
@@ -125,3 +125,136 @@ func ThemeBg(theme string) string {
125125 }
126126 return bg.String() // "#rrggbb"
127127 }
128+
129+// Palette holds UI chrome colors derived deterministically from a Chroma theme.
130+// The grayscale ramp is a linear interpolation from bg to fg; the accent is the
131+// most saturated token color in the palette; error comes from the Error token.
132+type Palette struct {
133+ Bg string // Theme background
134+ Fg string // Theme foreground (primary text)
135+ Border string // 10% bg→fg — borders, dividers
136+ LinkBg string // 7% bg→fg — subtle hover background
137+ Dim string // 25% bg→fg — tertiary text, timestamps
138+ Muted string // 45% bg→fg — secondary text, reasoning
139+ Accent string // Most saturated token color
140+ Error string // From chroma Error token, lerped 45% toward fg
141+}
142+
143+// ThemePalette derives a full UI color palette from a Chroma theme name.
144+// Deterministic: same theme → same output. Falls back to sensible defaults
145+// when the theme is missing entries.
146+func ThemePalette(theme string) Palette {
147+ sty := styles.Get(theme)
148+ if sty == nil {
149+ return defaultPalette()
150+ }
151+ entry := sty.Get(chroma.Background)
152+ bg := "#000000"
153+ fg := "#c8c8c8"
154+ if entry.Background.IsSet() {
155+ bg = entry.Background.String()
156+ }
157+ if entry.Colour.IsSet() {
158+ fg = entry.Colour.String()
159+ }
160+
161+ p := Palette{
162+ Bg: bg,
163+ Fg: fg,
164+ Border: lerpHex(bg, fg, 0.10),
165+ LinkBg: lerpHex(bg, fg, 0.07),
166+ Dim: lerpHex(bg, fg, 0.25),
167+ Muted: lerpHex(bg, fg, 0.45),
168+ Accent: pickAccent(sty, fg),
169+ Error: pickError(sty, bg, fg),
170+ }
171+ return p
172+}
173+
174+func defaultPalette() Palette {
175+ return Palette{
176+ Bg: "#000000", Fg: "#c8c8c8",
177+ Border: "#141414", LinkBg: "#0e0e0e",
178+ Dim: "#323232", Muted: "#5a5a5a",
179+ Accent: "#00dfff", Error: "#932e2e",
180+ }
181+}
182+
183+// pickAccent returns the most saturated foreground color across all tokens.
184+func pickAccent(sty *chroma.Style, fallback string) string {
185+ best := fallback
186+ bestSat := 0.0
187+ for tt := chroma.TokenType(0); tt < 2000; tt++ {
188+ e := sty.Get(tt)
189+ if !e.Colour.IsSet() {
190+ continue
191+ }
192+ hex := e.Colour.String()
193+ r, g, b := hexToRGBf(hex)
194+ mx := maxf(r, maxf(g, b))
195+ mn := minf(r, minf(g, b))
196+ if mx == 0 {
197+ continue
198+ }
199+ sat := (mx - mn) / mx
200+ if sat > bestSat {
201+ bestSat = sat
202+ best = hex
203+ }
204+ }
205+ return best
206+}
207+
208+// pickError extracts the Error token color and lerps it 45% toward fg
209+// so it's visible but not garish against the theme background.
210+func pickError(sty *chroma.Style, bg, fg string) string {
211+ e := sty.Get(chroma.Error)
212+ if !e.Colour.IsSet() {
213+ return lerpHex(bg, fg, 0.45) // muted fallback
214+ }
215+ return lerpHex(bg, e.Colour.String(), 0.45)
216+}
217+
218+// lerpHex linearly interpolates between two hex colors at fraction t.
219+func lerpHex(a, b string, t float64) string {
220+ ar, ag, ab := hexToRGBf(a)
221+ br, bg, bb := hexToRGBf(b)
222+ return fmt.Sprintf("#%02x%02x%02x",
223+ clampByte(ar+(br-ar)*t),
224+ clampByte(ag+(bg-ag)*t),
225+ clampByte(ab+(bb-ab)*t),
226+ )
227+}
228+
229+func hexToRGBf(hex string) (float64, float64, float64) {
230+ if len(hex) != 7 || hex[0] != '#' {
231+ return 0, 0, 0
232+ }
233+ return float64(hexByte(hex[1], hex[2])),
234+ float64(hexByte(hex[3], hex[4])),
235+ float64(hexByte(hex[5], hex[6]))
236+}
237+
238+func clampByte(v float64) int {
239+ if v < 0 {
240+ return 0
241+ }
242+ if v > 255 {
243+ return 255
244+ }
245+ return int(v + 0.5)
246+}
247+
248+func maxf(a, b float64) float64 {
249+ if a > b {
250+ return a
251+ }
252+ return b
253+}
254+
255+func minf(a, b float64) float64 {
256+ if a < b {
257+ return a
258+ }
259+ return b
260+}
internal/tui/conv.go+1−1
@@ -20,7 +20,7 @@ func (m Model) convWidth() int { return m.layout.conv.Dx() }
2020 // (fenced code blocks, block quotes, etc.) maintain correct state.
2121 // Rendering cost is bounded by the frame-loop tick (~16ms).
2222 func highlightMarkdown(text string, fallback lipgloss.Style) []string {
23- hl := highlight.Highlight(text, "markdown", constants.SyntaxTheme, "#000000")
23+ hl := highlight.Highlight(text, "markdown", constants.SyntaxTheme, palette.Bg)
2424 if hl == text {
2525 // Chroma produced no highlighting; apply fallback per line.
2626 raw := strings.Split(text, "\n")
internal/tui/styles.go+22−20
@@ -1,26 +1,28 @@
11 package tui
22
3-import "charm.land/lipgloss/v2"
4-
5-// Semantic color palette — grayscale "suit and tie" with a single accent.
6-var (
7- // Accent — used sparingly: cursor, spinner, active indicators.
8- ColorHighlight = lipgloss.Color("#00dfff")
9-
10- // Backgrounds
11- ColorBg = lipgloss.Color("#000000") // Pure black — consistent everywhere
3+import (
4+ "charm.land/lipgloss/v2"
5+ "github.com/xonecas/symb/internal/constants"
6+ "github.com/xonecas/symb/internal/highlight"
7+)
128
13- // Foregrounds (grayscale ramp, light to dark)
14- ColorFg = lipgloss.Color("#c8c8c8") // Primary text
15- ColorMuted = lipgloss.Color("#6e6e6e") // Secondary / reasoning
16- ColorDim = lipgloss.Color("#3f3f3f") // Tertiary / timestamps
17- ColorBorder = lipgloss.Color("#1c1c1c") // Borders and dividers
18- ColorSurface = ColorHighlight // Selection highlight — reuse accent
9+// palette is computed once from the Chroma theme at init time.
10+var palette = highlight.ThemePalette(constants.SyntaxTheme)
1911
20- // Semantic aliases
21- ColorError = lipgloss.Color("#932e2e")
22- ColorWarning = lipgloss.Color("#8a6d2b")
23- ColorLinkBg = lipgloss.Color("#111111") // Subtle hover background for clickable elements
12+// Semantic color palette — derived from the active Chroma syntax theme.
13+// Grayscale ramp is a linear interpolation from theme bg to fg.
14+// Accent is the most saturated token color; error is lerped from the theme Error token.
15+var (
16+ ColorHighlight = lipgloss.Color(palette.Accent)
17+ ColorBg = lipgloss.Color(palette.Bg)
18+ ColorFg = lipgloss.Color(palette.Fg)
19+ ColorMuted = lipgloss.Color(palette.Muted)
20+ ColorDim = lipgloss.Color(palette.Dim)
21+ ColorBorder = lipgloss.Color(palette.Border)
22+ ColorSurface = lipgloss.Color(palette.Accent)
23+ ColorError = lipgloss.Color(palette.Error)
24+ ColorWarning = lipgloss.Color(palette.Error) // same source, context differentiates
25+ ColorLinkBg = lipgloss.Color(palette.LinkBg)
2426 )
2527
2628 // Styles holds all pre-built lipgloss styles used across the TUI.
@@ -38,7 +40,7 @@ type Styles struct {
3840 // Layout
3941 Border lipgloss.Style // Divider, separator lines
4042 Selection lipgloss.Style // Mouse text selection highlight
41- BgFill lipgloss.Style // Pure black background fill for empty areas
43+ BgFill lipgloss.Style // Background fill for empty areas
4244
4345 // Hover
4446 Hover lipgloss.Style // Highlight text on subtle dark bg for clickable hover
internal/tui/testdata/TestLayout/120x40/ANSI.golden+40−40
@@ -1,40 +1,40 @@
1- 1   │ 
2- │ 
3- │ 
4- │ 
5- │ 
6- │ 
7- │ 
8- │ 
9- │ 
10- │ 
11- │ 
12- │ 
13- │ 
14- │ 
15- │ 
16- │ 
17- │ 
18- │ 
19- │ 
20- │ 
21- │ 
22- │ 
23- │ 
24- │ 
25- │ 
26- │ 
27- │ 
28- │ 
29- │ 
30- │ 
31- │ 
32- │ 
33- │ 
34- │ 
35- │───────────────────────────────────────────────────────────
36- │Type a message...  
37- │  
38- │  
39-────────────────────────────────────────────────────────────┴───────────────────────────────────────────────────────────
40- symb ⣾  
1+ 1   │ 
2+ │ 
3+ │ 
4+ │ 
5+ │ 
6+ │ 
7+ │ 
8+ │ 
9+ │ 
10+ │ 
11+ │ 
12+ │ 
13+ │ 
14+ │ 
15+ │ 
16+ │ 
17+ │ 
18+ │ 
19+ │ 
20+ │ 
21+ │ 
22+ │ 
23+ │ 
24+ │ 
25+ │ 
26+ │ 
27+ │ 
28+ │ 
29+ │ 
30+ │ 
31+ │ 
32+ │ 
33+ │ 
34+ │ 
35+ │───────────────────────────────────────────────────────────
36+ │Type a message...  
37+ │  
38+ │  
39+────────────────────────────────────────────────────────────┴───────────────────────────────────────────────────────────
40+ symb ⣾  
internal/tui/testdata/TestLayout/80x24/ANSI.golden+24−24
@@ -1,24 +1,24 @@
1- 1   │ 
2- │ 
3- │ 
4- │ 
5- │ 
6- │ 
7- │ 
8- │ 
9- │ 
10- │ 
11- │ 
12- │ 
13- │ 
14- │ 
15- │ 
16- │ 
17- │ 
18- │ 
19- │───────────────────────────────────────
20- │Type a message...  
21- │  
22- │  
23-────────────────────────────────────────┴───────────────────────────────────────
24- symb ⣾  
1+ 1   │ 
2+ │ 
3+ │ 
4+ │ 
5+ │ 
6+ │ 
7+ │ 
8+ │ 
9+ │ 
10+ │ 
11+ │ 
12+ │ 
13+ │ 
14+ │ 
15+ │ 
16+ │ 
17+ │ 
18+ │ 
19+ │───────────────────────────────────────
20+ │Type a message...  
21+ │  
22+ │  
23+────────────────────────────────────────┴───────────────────────────────────────
24+ symb ⣾