diff --git a/internal/format/spinner.go b/internal/format/spinner.go index cac659805d307bae782d0bc88d70fe361f6b7c57..ebaa47b6e175356052b4206f80a8bc11988df65d 100644 --- a/internal/format/spinner.go +++ b/internal/format/spinner.go @@ -20,7 +20,7 @@ type Spinner struct { type model struct { cancel context.CancelFunc - anim anim.Anim + anim anim.Spinner } func (m model) Init() tea.Cmd { return m.anim.Init() } diff --git a/internal/tui/components/anim/anim.go b/internal/tui/components/anim/anim.go index bfecf0b5878f4b92a1a10a84d253344805cee55f..52556bb9bf16ebc6ff258bb13f960659b6c0d502 100644 --- a/internal/tui/components/anim/anim.go +++ b/internal/tui/components/anim/anim.go @@ -97,7 +97,14 @@ type Settings struct { Static bool } -// anim is a Bubble for an animated spinner. +// Spinner is a Bubble for a spinner. +type Spinner interface { + Init() tea.Cmd + Update(tea.Msg) (Spinner, tea.Cmd) + View() string + SetLabel(string) +} + type anim struct { width int cyclingCharWidth int @@ -116,7 +123,7 @@ type anim struct { } // New creates a new anim instance with the specified width and label. -func New(opts Settings) Anim { +func New(opts Settings) Spinner { // Validate settings. if opts.Size < 1 { opts.Size = defaultNumCyclingChars @@ -319,7 +326,7 @@ func (a *anim) Init() tea.Cmd { } // Update processes animation steps (or not). -func (a *anim) Update(msg tea.Msg) (Anim, tea.Cmd) { +func (a *anim) Update(msg tea.Msg) (Spinner, tea.Cmd) { switch msg := msg.(type) { case StepMsg: if msg.id != a.id { diff --git a/internal/tui/components/anim/static.go b/internal/tui/components/anim/static.go index b9a00af11170539bde8e9f6734371c0b10e05ba3..fff8c6d458720094dcf9a62a33c3beb1edd62918 100644 --- a/internal/tui/components/anim/static.go +++ b/internal/tui/components/anim/static.go @@ -7,19 +7,12 @@ import ( "github.com/charmbracelet/lipgloss/v2" ) -type Anim interface { - Init() tea.Cmd - Update(tea.Msg) (Anim, tea.Cmd) - View() string - SetLabel(string) -} - type noAnim struct { Color color.Color rendered string } -func newStatic(label string, foreground color.Color) Anim { +func newStatic(label string, foreground color.Color) Spinner { a := &noAnim{Color: foreground} a.SetLabel(label) return a @@ -29,6 +22,6 @@ func (s *noAnim) SetLabel(label string) { s.rendered = lipgloss.NewStyle().Foreground(s.Color).Render(label + ellipsisFrames[2]) } -func (s noAnim) Init() tea.Cmd { return nil } -func (s *noAnim) Update(tea.Msg) (Anim, tea.Cmd) { return s, nil } -func (s *noAnim) View() string { return s.rendered } +func (s noAnim) Init() tea.Cmd { return nil } +func (s *noAnim) Update(tea.Msg) (Spinner, tea.Cmd) { return s, nil } +func (s *noAnim) View() string { return s.rendered } diff --git a/internal/tui/components/chat/messages/messages.go b/internal/tui/components/chat/messages/messages.go index ad61a96348f98a6262a15c9f71108f73531c35ea..1374df25867919b6f7e4e2a8875c41cd26eee9ba 100644 --- a/internal/tui/components/chat/messages/messages.go +++ b/internal/tui/components/chat/messages/messages.go @@ -54,7 +54,7 @@ type messageCmp struct { // Core message data and state message message.Message // The underlying message content spinning bool // Whether to show loading animation - anim anim.Anim // Animation component for loading states + anim anim.Spinner // Animation component for loading states // Thinking viewport for displaying reasoning content thinkingViewport viewport.Model diff --git a/internal/tui/components/chat/messages/tool.go b/internal/tui/components/chat/messages/tool.go index 30f9929e091434d95c2f46bbd6dc691d094b8995..e4b00510a7ed3505694ad452795b77ed812697d6 100644 --- a/internal/tui/components/chat/messages/tool.go +++ b/internal/tui/components/chat/messages/tool.go @@ -61,8 +61,8 @@ type toolCallCmp struct { permissionGranted bool // Animation state for pending tool calls - spinning bool // Whether to show loading animation - anim anim.Anim // Animation component for pending states + spinning bool // Whether to show loading animation + anim anim.Spinner // Animation component for pending states nestedToolCalls []ToolCallCmp // Nested tool calls for hierarchical display }