Documentation
¶
Index ¶
- Constants
- func Run(client api.Client, modelName string, session *config.Session) error
- type AutocompleteState
- func (a *AutocompleteState) Down()
- func (a *AutocompleteState) Filtered() []Command
- func (a *AutocompleteState) Hide()
- func (a *AutocompleteState) Index() int
- func (a *AutocompleteState) Select() string
- func (a *AutocompleteState) Up()
- func (a *AutocompleteState) Update(input string)
- func (a *AutocompleteState) Visible() bool
- type ChatState
- type Command
- type Config
- type EscAction
- type EscTimeoutMsg
- type HistoryNavigator
- func (h *HistoryNavigator) Add(entry string)
- func (h *HistoryNavigator) Down() string
- func (h *HistoryNavigator) HistoryLen() int
- func (h *HistoryNavigator) Index() int
- func (h *HistoryNavigator) IsBrowsing() bool
- func (h *HistoryNavigator) Reset()
- func (h *HistoryNavigator) SetHistory(history []string)
- func (h *HistoryNavigator) Up(currentInput string) string
- type Model
- func (m *Model) Err() error
- func (m Model) Init() tea.Cmd
- func (m *Model) IsResumed() bool
- func (m *Model) Messages() []api.Message
- func (m *Model) ModelName() string
- func (m *Model) Session() *config.Session
- func (m *Model) SetErr(err error)
- func (m *Model) SetMessages(messages []api.Message)
- func (m *Model) SetModelName(name string)
- func (m *Model) SetSession(session *config.Session)
- func (m *Model) StartStream() tea.Cmd
- func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (m Model) View() string
- func (m *Model) WaitForChunk() tea.Cmd
- type StreamChunkMsg
- type StreamDoneMsg
- type StreamErrMsg
- type StreamState
- func (s *StreamState) Cancel()
- func (s *StreamState) Chunks() <-chan string
- func (s *StreamState) Close()
- func (s *StreamState) ErrChan() <-chan error
- func (s *StreamState) IsCancelled() bool
- func (s *StreamState) IsDone() bool
- func (s *StreamState) SendChunk(chunk string)
- func (s *StreamState) SendError(err error)
- func (s *StreamState) SetReader(reader *api.StreamReader)
Constants ¶
const ( CmdResume = "/resume" CmdModels = "/models" CmdQuit = "/quit" CmdExit = "/exit" CmdNew = "/new" CmdClear = "/clear" )
Command constants for chat commands.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AutocompleteState ¶
type AutocompleteState struct {
// contains filtered or unexported fields
}
AutocompleteState manages command autocomplete state.
func NewAutocompleteState ¶
func NewAutocompleteState() *AutocompleteState
NewAutocompleteState creates a new AutocompleteState.
func (*AutocompleteState) Down ¶
func (a *AutocompleteState) Down()
Down moves selection down in the autocomplete list.
func (*AutocompleteState) Filtered ¶
func (a *AutocompleteState) Filtered() []Command
Filtered returns the filtered commands.
func (*AutocompleteState) Hide ¶
func (a *AutocompleteState) Hide()
Hide hides the autocomplete dropdown.
func (*AutocompleteState) Index ¶
func (a *AutocompleteState) Index() int
Index returns the current selection index.
func (*AutocompleteState) Select ¶
func (a *AutocompleteState) Select() string
Select returns the currently selected command name. Returns empty string if no valid selection.
func (*AutocompleteState) Up ¶
func (a *AutocompleteState) Up()
Up moves selection up in the autocomplete list.
func (*AutocompleteState) Update ¶
func (a *AutocompleteState) Update(input string)
Update updates the autocomplete state based on the current input.
func (*AutocompleteState) Visible ¶
func (a *AutocompleteState) Visible() bool
Visible returns whether autocomplete is currently showing.
type Command ¶
Command represents a chat command with autocomplete support.
func AvailableCommands ¶
func AvailableCommands() []Command
AvailableCommands returns all available chat commands.
func FilterCommands ¶
FilterCommands returns commands matching the given prefix.
type HistoryNavigator ¶
type HistoryNavigator struct {
// contains filtered or unexported fields
}
HistoryNavigator manages navigation through input history.
func NewHistoryNavigator ¶
func NewHistoryNavigator() *HistoryNavigator
NewHistoryNavigator creates a new HistoryNavigator.
func (*HistoryNavigator) Add ¶
func (h *HistoryNavigator) Add(entry string)
Add adds an entry to history (skip consecutive duplicates).
func (*HistoryNavigator) Down ¶
func (h *HistoryNavigator) Down() string
Down navigates to a newer history entry. Returns the history entry to display, or the draft if at bottom.
func (*HistoryNavigator) HistoryLen ¶
func (h *HistoryNavigator) HistoryLen() int
HistoryLen returns the length of history.
func (*HistoryNavigator) Index ¶
func (h *HistoryNavigator) Index() int
Index returns the current history index.
func (*HistoryNavigator) IsBrowsing ¶
func (h *HistoryNavigator) IsBrowsing() bool
IsBrowsing returns true if currently browsing history.
func (*HistoryNavigator) Reset ¶
func (h *HistoryNavigator) Reset()
Reset resets the history navigation state.
func (*HistoryNavigator) SetHistory ¶
func (h *HistoryNavigator) SetHistory(history []string)
SetHistory sets the history list.
func (*HistoryNavigator) Up ¶
func (h *HistoryNavigator) Up(currentInput string) string
Up navigates to an older history entry. Returns the history entry to display, or empty string if no change.
type Model ¶
type Model struct {
// Picker state (managed by parent)
ShowingPicker bool
ShowingModelPicker bool
// contains filtered or unexported fields
}
Model is the Bubble Tea model for the chat TUI.
func (*Model) SetMessages ¶
SetMessages sets the messages (used when resuming).
func (*Model) SetModelName ¶
SetModelName sets the model name and updates the session.
func (*Model) SetSession ¶
SetSession sets a new session.
func (*Model) StartStream ¶
StartStream starts a new streaming request. It creates a StreamState and returns a command that reads from the API. The StreamState is stored in m.activeStream before the command runs.
func (*Model) WaitForChunk ¶
WaitForChunk returns a command to wait for the next stream chunk.
type StreamState ¶
type StreamState struct {
// contains filtered or unexported fields
}
StreamState manages the state of an active stream. This replaces the global activeStream variable for better encapsulation.
func (*StreamState) Cancel ¶
func (s *StreamState) Cancel()
Cancel cancels the stream by closing the reader.
func (*StreamState) Chunks ¶
func (s *StreamState) Chunks() <-chan string
Chunks returns the channel for receiving stream chunks.
func (*StreamState) Close ¶
func (s *StreamState) Close()
Close marks the stream as done and closes channels.
func (*StreamState) ErrChan ¶
func (s *StreamState) ErrChan() <-chan error
ErrChan returns the channel for receiving stream errors.
func (*StreamState) IsCancelled ¶
func (s *StreamState) IsCancelled() bool
IsCancelled returns whether the stream was explicitly cancelled by the user.
func (*StreamState) IsDone ¶
func (s *StreamState) IsDone() bool
IsDone returns whether the stream is done.
func (*StreamState) SendChunk ¶
func (s *StreamState) SendChunk(chunk string)
SendChunk sends a chunk to the chunks channel.
func (*StreamState) SendError ¶
func (s *StreamState) SendError(err error)
SendError sends an error to the error channel.
func (*StreamState) SetReader ¶
func (s *StreamState) SetReader(reader *api.StreamReader)
SetReader sets the stream reader.