d247b19608
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>
44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
package app
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
// `/` as the first char of a chat line opens the command palette inline (opencode-style),
|
|
// without typing a literal slash.
|
|
func TestSlashOpensPaletteOnEmptyLine(t *testing.T) {
|
|
m := NewModel(nil)
|
|
m.editMode = ModeInsert
|
|
m.inputMode = ModeRouter
|
|
m.inputBuffer = ""
|
|
|
|
next, _ := m.handleInsertKey(keyMsg{Type: keyRunes, Runes: []rune("/")})
|
|
nm := next.(Model)
|
|
|
|
if nm.overlay != OverlayPalette {
|
|
t.Fatalf("'/' on an empty line should open the palette; overlay=%d", nm.overlay)
|
|
}
|
|
if nm.inputBuffer != "" {
|
|
t.Fatalf("'/' should not be typed literally; buffer=%q", nm.inputBuffer)
|
|
}
|
|
}
|
|
|
|
// Mid-line `/` is a literal slash (e.g. a path), not a command trigger.
|
|
func TestSlashLiteralMidLine(t *testing.T) {
|
|
m := NewModel(nil)
|
|
m.editMode = ModeInsert
|
|
m.inputMode = ModeRouter
|
|
m.inputBuffer = "path"
|
|
m.inputCursor = len("path")
|
|
|
|
next, _ := m.handleInsertKey(keyMsg{Type: keyRunes, Runes: []rune("/")})
|
|
nm := next.(Model)
|
|
|
|
if nm.overlay != OverlayNone {
|
|
t.Fatalf("mid-line '/' must stay literal, not open the palette; overlay=%d", nm.overlay)
|
|
}
|
|
if nm.inputBuffer != "path/" {
|
|
t.Fatalf("mid-line '/' should be typed; buffer=%q", nm.inputBuffer)
|
|
}
|
|
}
|