tui: migrate Bubble Tea v1 → v2 (charm.land), enable Shift+Enter

Move the Go TUI from github.com/charmbracelet/{bubbletea,lipgloss} to the v2
ecosystem at charm.land/{bubbletea,lipgloss}/v2 (Go 1.25). v2's kitty keyboard
disambiguation is on by default, so Shift+Enter now reliably inserts a newline
in the composer (Ctrl+J / Alt+Enter kept as fallbacks for non-kitty terminals).

Approach: rather than rewrite ~190 key-match sites to v2's (Code, Mod) idiom, a
small shim (internal/app/key.go) converts a v2 KeyPressMsg into the v1-shaped
keyMsg the handlers already expect, at the single Update boundary. The rest is
mechanical:
- key constants tea.Key* → shim consts; tea.KeyMsg → keyMsg.
- lipgloss.Color is now a func returning color.Color, not a type → fields/params
  retyped to image/color.Color (theme/diff/overlays/view).
- v2 View() returns tea.View: render() builds the string, View() wraps it and
  carries AltScreen (alt-screen is a per-frame View field now, not a program opt).
- WithWhitespaceBackground/Foreground → WithWhitespaceStyle(Style).
- preview: drop lipgloss.SetColorProfile (v2 renders truecolor by default).

Build, vet, gofmt, and the full test suite are green; preview renders truecolor
across kinds.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-22 15:59:55 +00:00
parent 6c792b83e2
commit d247b19608
27 changed files with 432 additions and 300 deletions
+30 -26
View File
@@ -1,36 +1,40 @@
package app
import "github.com/charmbracelet/lipgloss"
import (
"image/color"
"charm.land/lipgloss/v2"
)
// Palette is the "Soft" chrome from docs/visual/ref with the blue accent:
// rounded borders, opaque dark panels, generous spacing.
type Palette struct {
Bg lipgloss.Color // panel/background fill
BgDeep lipgloss.Color // outermost backdrop (slightly darker)
BgPanel lipgloss.Color // inside-panel fill
Sel lipgloss.Color // selection row background
Border lipgloss.Color // idle panel border
BorderHi lipgloss.Color // active panel border
Fg lipgloss.Color // primary text
FgStrong lipgloss.Color // headings / emphasis
Dim lipgloss.Color // labels, secondary text
Faint lipgloss.Color // tertiary, hints
Accent lipgloss.Color // blue accent
Accent2 lipgloss.Color // secondary accent
Bg color.Color // panel/background fill
BgDeep color.Color // outermost backdrop (slightly darker)
BgPanel color.Color // inside-panel fill
Sel color.Color // selection row background
Border color.Color // idle panel border
BorderHi color.Color // active panel border
Fg color.Color // primary text
FgStrong color.Color // headings / emphasis
Dim color.Color // labels, secondary text
Faint color.Color // tertiary, hints
Accent color.Color // blue accent
Accent2 color.Color // secondary accent
OK lipgloss.Color
Warn lipgloss.Color
Bad lipgloss.Color
OK color.Color
Warn color.Color
Bad color.Color
DiffAdd lipgloss.Color // added-line cell background
DiffDel lipgloss.Color // removed-line cell background
DiffAdd color.Color // added-line cell background
DiffDel color.Color // removed-line cell background
CatLifecycle lipgloss.Color
CatContext lipgloss.Color
CatInference lipgloss.Color
CatTool lipgloss.Color
CatDomain lipgloss.Color
CatApproval lipgloss.Color
CatLifecycle color.Color
CatContext color.Color
CatInference color.Color
CatTool color.Color
CatDomain color.Color
CatApproval color.Color
}
// SoftBlue mirrors the reference Soft theme (#14161a bg, #ced3da fg) with the
@@ -91,7 +95,7 @@ type Theme struct {
// NewTheme builds the style set for a palette.
func NewTheme(p Palette) Theme {
base := lipgloss.NewStyle().Background(p.Bg).Foreground(p.Fg)
roundBase := func(border lipgloss.Color) lipgloss.Style {
roundBase := func(border color.Color) lipgloss.Style {
return lipgloss.NewStyle().
Border(lipgloss.RoundedBorder()).
BorderForeground(border).
@@ -128,7 +132,7 @@ func NewTheme(p Palette) Theme {
}
// categoryColor maps an event category label to its accent color.
func (t Theme) categoryColor(cat string) lipgloss.Color {
func (t Theme) categoryColor(cat string) color.Color {
switch cat {
case "Lifecycle":
return t.P.CatLifecycle