on main help sign in
refactor: use v2 declarative API (#1229)
commit14f2f9c703b917cb9492dcba141a4d7a2d4be2a0 authorAyman Bagabas <ayman.bagabas@gmail.com> dateThu 23 Oct 2025, 12:09 (1 year ago) parent9f2c7d0
34 files changed+72−80
go.mod+3−3 go.sum+6−6 internal/cmd/root.go+1−4 internal/format/spinner.go+2−2 internal/tui/components/anim/anim.go+2−1 internal/tui/components/chat/chat.go+1−1 internal/tui/components/chat/editor/editor.go+1−1 internal/tui/components/chat/header/header.go+1−1 internal/tui/components/chat/messages/messages.go+3−3 internal/tui/components/chat/messages/tool.go+3−3 internal/tui/components/chat/sidebar/sidebar.go+1−1 internal/tui/components/chat/splash/splash.go+1−1 internal/tui/components/completions/completions.go+1−1 internal/tui/components/core/status/status.go+1−1 internal/tui/components/dialogs/commands/arguments.go+1−1 internal/tui/components/dialogs/commands/commands.go+1−1 internal/tui/components/dialogs/compact/compact.go+1−1 internal/tui/components/dialogs/dialogs.go+7−3 internal/tui/components/dialogs/filepicker/filepicker.go+1−1 internal/tui/components/dialogs/models/apikey.go+2−1 internal/tui/components/dialogs/models/models.go+1−1 internal/tui/components/dialogs/permissions/permissions.go+1−1 internal/tui/components/dialogs/quit/quit.go+1−1 internal/tui/components/dialogs/reasoning/reasoning.go+1−1 internal/tui/components/dialogs/sessions/sessions.go+1−1 internal/tui/exp/list/filterable.go+2−1 internal/tui/exp/list/filterable_group.go+2−1 internal/tui/exp/list/grouped.go+1−1 internal/tui/exp/list/items.go+3−2 internal/tui/exp/list/list.go+2−2 internal/tui/exp/list/list_test.go+3−2 internal/tui/page/chat/chat.go+1−1 internal/tui/tui.go+10−26 internal/tui/util/util.go+3−2
go.mod+3−3
@@ -13,7 +13,7 @@ require (
1313 github.com/charlievieth/fastwalk v1.0.14
1414 github.com/charmbracelet/anthropic-sdk-go v0.0.0-20251021163913-d29170d047bf
1515 github.com/charmbracelet/bubbles/v2 v2.0.0-beta.1.0.20250820203609-601216f68ee2
16− github.com/charmbracelet/bubbletea/v2 v2.0.0-beta.4.0.20251011205917-3b687ffc1619
16+ github.com/charmbracelet/bubbletea/v2 v2.0.0-beta.5
1717 github.com/charmbracelet/catwalk v0.7.0
1818 github.com/charmbracelet/fang v0.4.3
1919 github.com/charmbracelet/glamour/v2 v2.0.0-20250811143442-a27abb32f018
@@ -74,7 +74,7 @@ require (
7474 github.com/bahlo/generic-list-go v0.2.0 // indirect
7575 github.com/buger/jsonparser v1.1.1 // indirect
7676 github.com/charmbracelet/colorprofile v0.3.2
77− github.com/charmbracelet/ultraviolet v0.0.0-20250915111650-81d4262876ef
77+ github.com/charmbracelet/ultraviolet v0.0.0-20251017140847-d4ace4d6e731
7878 github.com/charmbracelet/x/cellbuf v0.0.14-0.20250811133356-e0c5dbe5ea4a // indirect
7979 github.com/charmbracelet/x/exp/slice v0.0.0-20250829135019-44e44e21330d
8080 github.com/charmbracelet/x/powernap v0.0.0-20251015113943-25f979b54ad4
@@ -148,7 +148,7 @@ require (
148148 golang.org/x/net v0.43.0 // indirect
149149 golang.org/x/oauth2 v0.30.0 // indirect
150150 golang.org/x/sync v0.17.0 // indirect
151− golang.org/x/sys v0.36.0 // indirect
151+ golang.org/x/sys v0.37.0 // indirect
152152 golang.org/x/term v0.35.0 // indirect
153153 golang.org/x/text v0.30.0
154154 golang.org/x/time v0.8.0 // indirect
go.sum+6−6
@@ -78,8 +78,8 @@ github.com/charmbracelet/anthropic-sdk-go v0.0.0-20251021163913-d29170d047bf h1:
7878github.com/charmbracelet/anthropic-sdk-go v0.0.0-20251021163913-d29170d047bf/go.mod h1:8TIYxZxsuCqqeJ0lga/b91tBwrbjoHDC66Sq5t8N2R4=
7979github.com/charmbracelet/bubbles/v2 v2.0.0-beta.1.0.20250820203609-601216f68ee2 h1:973OHYuq2Jx9deyuPwe/6lsuQrDCatOsjP8uCd02URE=
8080github.com/charmbracelet/bubbles/v2 v2.0.0-beta.1.0.20250820203609-601216f68ee2/go.mod h1:6HamsBKWqEC/FVHuQMHgQL+knPyvHH55HwJDHl/adMw=
81−github.com/charmbracelet/bubbletea/v2 v2.0.0-beta.4.0.20251011205917-3b687ffc1619 h1:hjOhtqsxa+LVuCAkzhfA43wtusOaUPyQdSTg/wbRscw=
82−github.com/charmbracelet/bubbletea/v2 v2.0.0-beta.4.0.20251011205917-3b687ffc1619/go.mod h1:5IzIGXU1n0foRc8bRAherC8ZuQCQURPlwx3ANLq1138=
81+github.com/charmbracelet/bubbletea/v2 v2.0.0-beta.5 h1:oAChAeh730gtLKK/BpaTeJHzmj3KFuEfQ7AZgf2VGHM=
82+github.com/charmbracelet/bubbletea/v2 v2.0.0-beta.5/go.mod h1:SUTLq+/pGQ5qntHgt0JswfVJFfgJgWDqyvyiSLVlmbo=
8383github.com/charmbracelet/catwalk v0.7.0 h1:qhLv56aeel5Q+2G/YFh9k5FhTqsozsn4HYViuAQ/Rio=
8484github.com/charmbracelet/catwalk v0.7.0/go.mod h1:ReU4SdrLfe63jkEjWMdX2wlZMV3k9r11oQAmzN0m+KY=
8585github.com/charmbracelet/colorprofile v0.3.2 h1:9J27WdztfJQVAQKX2WOlSSRB+5gaKqqITmrvb1uTIiI=
@@ -92,8 +92,8 @@ github.com/charmbracelet/lipgloss/v2 v2.0.0-beta.3.0.20250917201909-41ff0bf215ea
9292github.com/charmbracelet/lipgloss/v2 v2.0.0-beta.3.0.20250917201909-41ff0bf215ea/go.mod h1:ngHerf1JLJXBrDXdphn5gFrBPriCL437uwukd5c93pM=
9393github.com/charmbracelet/log/v2 v2.0.0-20250226163916-c379e29ff706 h1:WkwO6Ks3mSIGnGuSdKl9qDSyfbYK50z2wc2gGMggegE=
9494github.com/charmbracelet/log/v2 v2.0.0-20250226163916-c379e29ff706/go.mod h1:mjJGp00cxcfvD5xdCa+bso251Jt4owrQvuimJtVmEmM=
95−github.com/charmbracelet/ultraviolet v0.0.0-20250915111650-81d4262876ef h1:VrWaUi2LXYLjfjCHowdSOEc6dQ9Ro14KY7Bw4IWd19M=
96−github.com/charmbracelet/ultraviolet v0.0.0-20250915111650-81d4262876ef/go.mod h1:AThRsQH1t+dfyOKIwXRoJBniYFQUkUpQq4paheHMc2o=
95+github.com/charmbracelet/ultraviolet v0.0.0-20251017140847-d4ace4d6e731 h1:Lr+igmzKpLPdb8yUZBP9noYWwCZP042z2nWPrJZTc+8=
96+github.com/charmbracelet/ultraviolet v0.0.0-20251017140847-d4ace4d6e731/go.mod h1:KfWwUa0Oe//D72YlhbOq/g40L7UiGtATrvsGI3cciG8=
9797github.com/charmbracelet/x/ansi v0.10.2 h1:ith2ArZS0CJG30cIUfID1LXN7ZFXRCww6RUvAPA+Pzw=
9898github.com/charmbracelet/x/ansi v0.10.2/go.mod h1:HbLdJjQH4UH4AqA2HpRWuWNluRE6zxJH/yteYEYCFa8=
9999github.com/charmbracelet/x/cellbuf v0.0.14-0.20250811133356-e0c5dbe5ea4a h1:zYSNtEJM9jwHbJts2k+Hroj+xQwsW1yxc4Wopdv7KaI=
@@ -388,8 +388,8 @@ golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
388388golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
389389golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
390390golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
391−golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
392−golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
391+golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
392+golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
393393golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
394394golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
395395golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
internal/cmd/root.go+1−4
@@ -83,11 +83,8 @@ crush -y
8383 // Set up the TUI.
8484 program := tea.NewProgram(
8585 tui.New(app),
86− tea.WithAltScreen(),
8786 tea.WithContext(cmd.Context()),
88− tea.WithMouseCellMotion(), // Use cell motion instead of all motion to reduce event flooding
89− tea.WithFilter(tui.MouseEventFilter), // Filter mouse events based on focus state
90− )
87+ tea.WithFilter(tui.MouseEventFilter)) // Filter mouse events based on focus state
9188
9289 go app.Subscribe(program)
9390
internal/format/spinner.go+2−2
@@ -23,8 +23,8 @@ type model struct {
2323 anim *anim.Anim
2424}
2525
26−func (m model) Init() tea.Cmd { return m.anim.Init() }
27−func (m model) View() string { return m.anim.View() }
26+func (m model) Init() tea.Cmd { return m.anim.Init() }
27+func (m model) View() tea.View { return tea.NewView(m.anim.View()) }
2828
2929// Update implements tea.Model.
3030func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
internal/tui/components/anim/anim.go+2−1
@@ -16,6 +16,7 @@ import (
1616 "github.com/lucasb-eyer/go-colorful"
1717
1818 "github.com/charmbracelet/crush/internal/csync"
19+ "github.com/charmbracelet/crush/internal/tui/util"
1920)
2021
2122const (
@@ -318,7 +319,7 @@ func (a *Anim) Init() tea.Cmd {
318319}
319320
320321// Update processes animation steps (or not).
321−func (a *Anim) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
322+func (a *Anim) Update(msg tea.Msg) (util.Model, tea.Cmd) {
322323 switch msg := msg.(type) {
323324 case StepMsg:
324325 if msg.id != a.id {
internal/tui/components/chat/chat.go+1−1
@@ -101,7 +101,7 @@ func (m *messageListCmp) Init() tea.Cmd {
101101}
102102
103103// Update handles incoming messages and updates the component state.
104−func (m *messageListCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
104+func (m *messageListCmp) Update(msg tea.Msg) (util.Model, tea.Cmd) {
105105 var cmds []tea.Cmd
106106 if m.session.ID != "" && m.app.CoderAgent != nil {
107107 queueSize := m.app.CoderAgent.QueuedPrompts(m.session.ID)
internal/tui/components/chat/editor/editor.go+1−1
@@ -172,7 +172,7 @@ func (m *editorCmp) repositionCompletions() tea.Msg {
172172 return completions.RepositionCompletionsMsg{X: x, Y: y}
173173}
174174
175−func (m *editorCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
175+func (m *editorCmp) Update(msg tea.Msg) (util.Model, tea.Cmd) {
176176 var cmd tea.Cmd
177177 var cmds []tea.Cmd
178178 switch msg := msg.(type) {
internal/tui/components/chat/header/header.go+1−1
@@ -44,7 +44,7 @@ func (h *header) Init() tea.Cmd {
4444 return nil
4545}
4646
47−func (h *header) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
47+func (h *header) Update(msg tea.Msg) (util.Model, tea.Cmd) {
4848 switch msg := msg.(type) {
4949 case pubsub.Event[session.Session]:
5050 if msg.Type == pubsub.UpdatedEvent {
internal/tui/components/chat/messages/messages.go+3−3
@@ -35,7 +35,7 @@ var ClearSelectionKey = key.NewBinding(key.WithKeys("esc", "alt+esc"), key.WithH
3535// MessageCmp defines the interface for message components in the chat interface.
3636// It combines standard UI model interfaces with message-specific functionality.
3737type MessageCmp interface {
38− util.Model // Basic Bubble Tea model interface
38+ util.Model // Basic Bubble util.Model interface
3939 layout.Sizeable // Width/height management
4040 layout.Focusable // Focus state management
4141 GetMessage() message.Message // Access to underlying message data
@@ -94,7 +94,7 @@ func (m *messageCmp) Init() tea.Cmd {
9494
9595// Update handles incoming messages and updates the component state.
9696// Manages animation updates for spinning messages and stops animation when appropriate.
97−func (m *messageCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
97+func (m *messageCmp) Update(msg tea.Msg) (util.Model, tea.Cmd) {
9898 switch msg := msg.(type) {
9999 case anim.StepMsg:
100100 m.spinning = m.shouldSpin()
@@ -384,7 +384,7 @@ func (m *assistantSectionModel) Init() tea.Cmd {
384384 return nil
385385}
386386
387−func (m *assistantSectionModel) Update(tea.Msg) (tea.Model, tea.Cmd) {
387+func (m *assistantSectionModel) Update(tea.Msg) (util.Model, tea.Cmd) {
388388 return m, nil
389389}
390390
internal/tui/components/chat/messages/tool.go+3−3
@@ -27,7 +27,7 @@ import (
2727// ToolCallCmp defines the interface for tool call components in the chat interface.
2828// It manages the display of tool execution including pending states, results, and errors.
2929type ToolCallCmp interface {
30− util.Model // Basic Bubble Tea model interface
30+ util.Model // Basic Bubble util.Model interface
3131 layout.Sizeable // Width/height management
3232 layout.Focusable // Focus state management
3333 GetToolCall() message.ToolCall // Access to tool call data
@@ -147,7 +147,7 @@ func (m *toolCallCmp) Init() tea.Cmd {
147147
148148// Update handles incoming messages and updates the component state.
149149// Manages animation updates for pending tool calls.
150−func (m *toolCallCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
150+func (m *toolCallCmp) Update(msg tea.Msg) (util.Model, tea.Cmd) {
151151 switch msg := msg.(type) {
152152 case anim.StepMsg:
153153 var cmds []tea.Cmd
@@ -160,7 +160,7 @@ func (m *toolCallCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
160160 }
161161 if m.spinning {
162162 u, cmd := m.anim.Update(msg)
163− m.anim = u.(util.Model)
163+ m.anim = u
164164 cmds = append(cmds, cmd)
165165 }
166166 return m, tea.Batch(cmds...)
internal/tui/components/chat/sidebar/sidebar.go+1−1
@@ -88,7 +88,7 @@ func (m *sidebarCmp) Init() tea.Cmd {
8888 return nil
8989}
9090
91−func (m *sidebarCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
91+func (m *sidebarCmp) Update(msg tea.Msg) (util.Model, tea.Cmd) {
9292 switch msg := msg.(type) {
9393 case SessionFilesMsg:
9494 m.files = csync.NewMap[string, SessionFile]()
internal/tui/components/chat/splash/splash.go+1−1
@@ -135,7 +135,7 @@ func (s *splashCmp) SetSize(width int, height int) tea.Cmd {
135135}
136136
137137// Update implements SplashPage.
138−func (s *splashCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
138+func (s *splashCmp) Update(msg tea.Msg) (util.Model, tea.Cmd) {
139139 switch msg := msg.(type) {
140140 case tea.WindowSizeMsg:
141141 return s, s.SetSize(msg.Width, msg.Height)
internal/tui/components/completions/completions.go+1−1
@@ -112,7 +112,7 @@ func (c *completionsCmp) Init() tea.Cmd {
112112}
113113
114114// Update implements Completions.
115−func (c *completionsCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
115+func (c *completionsCmp) Update(msg tea.Msg) (util.Model, tea.Cmd) {
116116 switch msg := msg.(type) {
117117 case tea.WindowSizeMsg:
118118 c.wWidth, c.wHeight = msg.Width, msg.Height
internal/tui/components/core/status/status.go+1−1
@@ -36,7 +36,7 @@ func (m *statusCmp) Init() tea.Cmd {
3636 return nil
3737}
3838
39−func (m *statusCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
39+func (m *statusCmp) Update(msg tea.Msg) (util.Model, tea.Cmd) {
4040 switch msg := msg.(type) {
4141 case tea.WindowSizeMsg:
4242 m.width = msg.Width
internal/tui/components/dialogs/commands/arguments.go+1−1
@@ -92,7 +92,7 @@ func (c *commandArgumentsDialogCmp) Init() tea.Cmd {
9292}
9393
9494// Update implements CommandArgumentsDialog.
95−func (c *commandArgumentsDialogCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
95+func (c *commandArgumentsDialogCmp) Update(msg tea.Msg) (util.Model, tea.Cmd) {
9696 switch msg := msg.(type) {
9797 case tea.WindowSizeMsg:
9898 c.wWidth = msg.Width
internal/tui/components/dialogs/commands/commands.go+1−1
@@ -116,7 +116,7 @@ func (c *commandDialogCmp) Init() tea.Cmd {
116116 return c.SetCommandType(c.commandType)
117117}
118118
119−func (c *commandDialogCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
119+func (c *commandDialogCmp) Update(msg tea.Msg) (util.Model, tea.Cmd) {
120120 switch msg := msg.(type) {
121121 case tea.WindowSizeMsg:
122122 c.wWidth = msg.Width
internal/tui/components/dialogs/compact/compact.go+1−1
@@ -61,7 +61,7 @@ func (c *compactDialogCmp) Init() tea.Cmd {
6161 return nil
6262}
6363
64−func (c *compactDialogCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
64+func (c *compactDialogCmp) Update(msg tea.Msg) (util.Model, tea.Cmd) {
6565 switch msg := msg.(type) {
6666 case tea.WindowSizeMsg:
6767 c.wWidth = msg.Width
internal/tui/components/dialogs/dialogs.go+7−3
@@ -32,7 +32,7 @@ type CloseDialogMsg struct{}
3232
3333// DialogCmp manages a stack of dialogs with keyboard navigation.
3434type DialogCmp interface {
35− tea.Model
35+ util.Model
3636
3737 Dialogs() []DialogModel
3838 HasDialogs() bool
@@ -62,7 +62,7 @@ func (d dialogCmp) Init() tea.Cmd {
6262}
6363
6464// Update handles dialog lifecycle and forwards messages to the active dialog.
65−func (d dialogCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
65+func (d dialogCmp) Update(msg tea.Msg) (util.Model, tea.Cmd) {
6666 switch msg := msg.(type) {
6767 case tea.WindowSizeMsg:
6868 var cmds []tea.Cmd
@@ -98,7 +98,11 @@ func (d dialogCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
9898 return d, nil
9999}
100100
101−func (d dialogCmp) handleOpen(msg OpenDialogMsg) (tea.Model, tea.Cmd) {
101+func (d dialogCmp) View() string {
102+ return ""
103+}
104+
105+func (d dialogCmp) handleOpen(msg OpenDialogMsg) (util.Model, tea.Cmd) {
102106 if d.HasDialogs() {
103107 dialog := d.dialogs[len(d.dialogs)-1]
104108 if dialog.ID() == msg.Model.ID() {
internal/tui/components/dialogs/filepicker/filepicker.go+1−1
@@ -88,7 +88,7 @@ func (m *model) Init() tea.Cmd {
8888 return m.filePicker.Init()
8989}
9090
91−func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
91+func (m *model) Update(msg tea.Msg) (util.Model, tea.Cmd) {
9292 switch msg := msg.(type) {
9393 case tea.WindowSizeMsg:
9494 m.wWidth = msg.Width
internal/tui/components/dialogs/models/apikey.go+2−1
@@ -9,6 +9,7 @@ import (
99 "github.com/charmbracelet/crush/internal/config"
1010 "github.com/charmbracelet/crush/internal/home"
1111 "github.com/charmbracelet/crush/internal/tui/styles"
12+ "github.com/charmbracelet/crush/internal/tui/util"
1213 "github.com/charmbracelet/lipgloss/v2"
1314)
1415
@@ -75,7 +76,7 @@ func (a *APIKeyInput) Init() tea.Cmd {
7576 return a.spinner.Tick
7677}
7778
78−func (a *APIKeyInput) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
79+func (a *APIKeyInput) Update(msg tea.Msg) (util.Model, tea.Cmd) {
7980 switch msg := msg.(type) {
8081 case spinner.TickMsg:
8182 if a.state == APIKeyInputStateVerifying {
internal/tui/components/dialogs/models/models.go+1−1
@@ -98,7 +98,7 @@ func (m *modelDialogCmp) Init() tea.Cmd {
9898 return tea.Batch(m.modelList.Init(), m.apiKeyInput.Init())
9999}
100100
101−func (m *modelDialogCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
101+func (m *modelDialogCmp) Update(msg tea.Msg) (util.Model, tea.Cmd) {
102102 switch msg := msg.(type) {
103103 case tea.WindowSizeMsg:
104104 m.wWidth = msg.Width
internal/tui/components/dialogs/permissions/permissions.go+1−1
@@ -95,7 +95,7 @@ func (p *permissionDialogCmp) supportsDiffView() bool {
9595 return p.permission.ToolName == tools.EditToolName || p.permission.ToolName == tools.WriteToolName || p.permission.ToolName == tools.MultiEditToolName
9696}
9797
98−func (p *permissionDialogCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
98+func (p *permissionDialogCmp) Update(msg tea.Msg) (util.Model, tea.Cmd) {
9999 var cmds []tea.Cmd
100100
101101 switch msg := msg.(type) {
internal/tui/components/dialogs/quit/quit.go+1−1
@@ -40,7 +40,7 @@ func (q *quitDialogCmp) Init() tea.Cmd {
4040}
4141
4242// Update handles keyboard input for the quit dialog.
43−func (q *quitDialogCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
43+func (q *quitDialogCmp) Update(msg tea.Msg) (util.Model, tea.Cmd) {
4444 switch msg := msg.(type) {
4545 case tea.WindowSizeMsg:
4646 q.wWidth = msg.Width
internal/tui/components/dialogs/reasoning/reasoning.go+1−1
@@ -172,7 +172,7 @@ func (r *reasoningDialogCmp) populateEffortOptions() tea.Cmd {
172172 return nil
173173}
174174
175−func (r *reasoningDialogCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
175+func (r *reasoningDialogCmp) Update(msg tea.Msg) (util.Model, tea.Cmd) {
176176 switch msg := msg.(type) {
177177 case tea.WindowSizeMsg:
178178 r.wWidth = msg.Width
internal/tui/components/dialogs/sessions/sessions.go+1−1
@@ -81,7 +81,7 @@ func (s *sessionDialogCmp) Init() tea.Cmd {
8181 return tea.Sequence(cmds...)
8282}
8383
84−func (s *sessionDialogCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
84+func (s *sessionDialogCmp) Update(msg tea.Msg) (util.Model, tea.Cmd) {
8585 switch msg := msg.(type) {
8686 case tea.WindowSizeMsg:
8787 var cmds []tea.Cmd
internal/tui/exp/list/filterable.go+2−1
@@ -9,6 +9,7 @@ import (
99 tea "github.com/charmbracelet/bubbletea/v2"
1010 "github.com/charmbracelet/crush/internal/tui/components/core/layout"
1111 "github.com/charmbracelet/crush/internal/tui/styles"
12+ "github.com/charmbracelet/crush/internal/tui/util"
1213 "github.com/charmbracelet/lipgloss/v2"
1314 "github.com/sahilm/fuzzy"
1415)
@@ -116,7 +117,7 @@ func NewFilterableList[T FilterableItem](items []T, opts ...filterableListOption
116117 return f
117118}
118119
119−func (f *filterableList[T]) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
120+func (f *filterableList[T]) Update(msg tea.Msg) (util.Model, tea.Cmd) {
120121 switch msg := msg.(type) {
121122 case tea.KeyPressMsg:
122123 switch {
internal/tui/exp/list/filterable_group.go+2−1
@@ -11,6 +11,7 @@ import (
1111 tea "github.com/charmbracelet/bubbletea/v2"
1212 "github.com/charmbracelet/crush/internal/tui/components/core/layout"
1313 "github.com/charmbracelet/crush/internal/tui/styles"
14+ "github.com/charmbracelet/crush/internal/tui/util"
1415 "github.com/charmbracelet/lipgloss/v2"
1516 "github.com/sahilm/fuzzy"
1617)
@@ -65,7 +66,7 @@ func NewFilterableGroupedList[T FilterableItem](items []Group[T], opts ...filter
6566 return f
6667}
6768
68−func (f *filterableGroupList[T]) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
69+func (f *filterableGroupList[T]) Update(msg tea.Msg) (util.Model, tea.Cmd) {
6970 switch msg := msg.(type) {
7071 case tea.KeyPressMsg:
7172 switch {
internal/tui/exp/list/grouped.go+1−1
@@ -58,7 +58,7 @@ func (g *groupedList[T]) Init() tea.Cmd {
5858 return g.render()
5959}
6060
61−func (l *groupedList[T]) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
61+func (l *groupedList[T]) Update(msg tea.Msg) (util.Model, tea.Cmd) {
6262 u, cmd := l.list.Update(msg)
6363 l.list = u.(*list[Item])
6464 return l, cmd
internal/tui/exp/list/items.go+3−2
@@ -7,6 +7,7 @@ import (
77 "github.com/charmbracelet/crush/internal/tui/components/core"
88 "github.com/charmbracelet/crush/internal/tui/components/core/layout"
99 "github.com/charmbracelet/crush/internal/tui/styles"
10+ "github.com/charmbracelet/crush/internal/tui/util"
1011 "github.com/charmbracelet/lipgloss/v2"
1112 "github.com/charmbracelet/x/ansi"
1213 "github.com/google/uuid"
@@ -97,7 +98,7 @@ func (c *completionItemCmp[T]) Init() tea.Cmd {
9798}
9899
99100// Update implements CommandItem.
100−func (c *completionItemCmp[T]) Update(tea.Msg) (tea.Model, tea.Cmd) {
101+func (c *completionItemCmp[T]) Update(tea.Msg) (util.Model, tea.Cmd) {
101102 return c, nil
102103}
103104
@@ -348,7 +349,7 @@ func (m *itemSectionModel) Init() tea.Cmd {
348349 return nil
349350}
350351
351−func (m *itemSectionModel) Update(tea.Msg) (tea.Model, tea.Cmd) {
352+func (m *itemSectionModel) Update(tea.Msg) (util.Model, tea.Cmd) {
352353 return m, nil
353354}
354355
internal/tui/exp/list/list.go+2−2
@@ -217,7 +217,7 @@ func (l *list[T]) Init() tea.Cmd {
217217}
218218
219219// Update implements List.
220−func (l *list[T]) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
220+func (l *list[T]) Update(msg tea.Msg) (util.Model, tea.Cmd) {
221221 switch msg := msg.(type) {
222222 case tea.MouseWheelMsg:
223223 if l.enableMouse {
@@ -277,7 +277,7 @@ func (l *list[T]) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
277277 return l, nil
278278}
279279
280−func (l *list[T]) handleMouseWheel(msg tea.MouseWheelMsg) (tea.Model, tea.Cmd) {
280+func (l *list[T]) handleMouseWheel(msg tea.MouseWheelMsg) (util.Model, tea.Cmd) {
281281 var cmd tea.Cmd
282282 switch msg.Button {
283283 case tea.MouseWheelDown:
internal/tui/exp/list/list_test.go+3−2
@@ -7,6 +7,7 @@ import (
77
88 tea "github.com/charmbracelet/bubbletea/v2"
99 "github.com/charmbracelet/crush/internal/tui/components/core/layout"
10+ "github.com/charmbracelet/crush/internal/tui/util"
1011 "github.com/charmbracelet/lipgloss/v2"
1112 "github.com/charmbracelet/x/exp/golden"
1213 "github.com/google/uuid"
@@ -602,7 +603,7 @@ func (s *simpleItem) Init() tea.Cmd {
602603 return nil
603604}
604605
605−func (s *simpleItem) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
606+func (s *simpleItem) Update(msg tea.Msg) (util.Model, tea.Cmd) {
606607 return s, nil
607608}
608609
@@ -644,7 +645,7 @@ func (s *selectableItem) IsFocused() bool {
644645 return s.focused
645646}
646647
647−func execCmd(m tea.Model, cmd tea.Cmd) {
648+func execCmd(m util.Model, cmd tea.Cmd) {
648649 for cmd != nil {
649650 msg := cmd()
650651 m, cmd = m.Update(msg)
internal/tui/page/chat/chat.go+1−1
@@ -163,7 +163,7 @@ func (p *chatPage) Init() tea.Cmd {
163163 )
164164}
165165
166−func (p *chatPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
166+func (p *chatPage) Update(msg tea.Msg) (util.Model, tea.Cmd) {
167167 var cmds []tea.Cmd
168168 switch msg := msg.(type) {
169169 case tea.KeyboardEnhancementsMsg:
internal/tui/tui.go+10−26
@@ -91,8 +91,6 @@ func (a appModel) Init() tea.Cmd {
9191 cmd = a.status.Init()
9292 cmds = append(cmds, cmd)
9393
94− cmds = append(cmds, tea.EnableMouseAllMotion)
95−
9694 return tea.Batch(cmds...)
9795}
9896
@@ -106,9 +104,7 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
106104 case tea.KeyboardEnhancementsMsg:
107105 for id, page := range a.pages {
108106 m, pageCmd := page.Update(msg)
109− if model, ok := m.(util.Model); ok {
110− a.pages[id] = model
111− }
107+ a.pages[id] = m
112108
113109 if pageCmd != nil {
114110 cmds = append(cmds, pageCmd)
@@ -232,9 +228,7 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
232228
233229 // Forward to view.
234230 updated, itemCmd := item.Update(msg)
235− if model, ok := updated.(util.Model); ok {
236− a.pages[a.currentPage] = model
237− }
231+ a.pages[a.currentPage] = updated
238232
239233 return a, itemCmd
240234 case pubsub.Event[permission.PermissionRequest]:
@@ -292,9 +286,7 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
292286
293287 a.isConfigured = config.HasInitialDataConfig()
294288 updated, pageCmd := item.Update(msg)
295− if model, ok := updated.(util.Model); ok {
296− a.pages[a.currentPage] = model
297− }
289+ a.pages[a.currentPage] = updated
298290
299291 cmds = append(cmds, pageCmd)
300292 return a, tea.Batch(cmds...)
@@ -314,9 +306,7 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
314306 }
315307
316308 updated, pageCmd := item.Update(msg)
317− if model, ok := updated.(util.Model); ok {
318− a.pages[a.currentPage] = model
319− }
309+ a.pages[a.currentPage] = updated
320310
321311 cmds = append(cmds, pageCmd)
322312 }
@@ -336,9 +326,7 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
336326 }
337327
338328 updated, pageCmd := item.Update(msg)
339− if model, ok := updated.(util.Model); ok {
340− a.pages[a.currentPage] = model
341− }
329+ a.pages[a.currentPage] = updated
342330
343331 cmds = append(cmds, pageCmd)
344332 }
@@ -353,9 +341,7 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
353341 }
354342
355343 updated, cmd := item.Update(msg)
356− if model, ok := updated.(util.Model); ok {
357− a.pages[a.currentPage] = model
358− }
344+ a.pages[a.currentPage] = updated
359345
360346 if a.dialog.HasDialogs() {
361347 u, dialogCmd := a.dialog.Update(msg)
@@ -391,9 +377,7 @@ func (a *appModel) handleWindowResize(width, height int) tea.Cmd {
391377 // Update the current view.
392378 for p, page := range a.pages {
393379 updated, pageCmd := page.Update(tea.WindowSizeMsg{Width: width, Height: height})
394− if model, ok := updated.(util.Model); ok {
395− a.pages[p] = model
396− }
380+ a.pages[p] = updated
397381
398382 cmds = append(cmds, pageCmd)
399383 }
@@ -496,9 +480,7 @@ func (a *appModel) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {
496480 }
497481
498482 updated, cmd := item.Update(msg)
499− if model, ok := updated.(util.Model); ok {
500− a.pages[a.currentPage] = model
501− }
483+ a.pages[a.currentPage] = updated
502484 return cmd
503485 }
504486}
@@ -602,6 +584,8 @@ func (a *appModel) View() tea.View {
602584
603585 view.Layer = canvas
604586 view.Cursor = cursor
587+ view.MouseMode = tea.MouseModeCellMotion
588+ view.AltScreen = true
605589 if a.app != nil && a.app.CoderAgent != nil && a.app.CoderAgent.IsBusy() {
606590 // HACK: use a random percentage to prevent ghostty from hiding it
607591 // after a timeout.
internal/tui/util/util.go+3−2
@@ -12,8 +12,9 @@ type Cursor interface {
1212}
1313
1414type Model interface {
15− tea.Model
16− tea.ViewModel
15+ Init() tea.Cmd
16+ Update(tea.Msg) (Model, tea.Cmd)
17+ View() string
1718}
1819
1920func CmdHandler(msg tea.Msg) tea.Cmd {