Documentation
¶
Overview ¶
Package tui provides the Terminal User Interface for monkey
Index ¶
- Constants
- func ApeModeActiveStyle() lipgloss.Style
- func ApeModeInactiveStyle() lipgloss.Style
- func AssistantMessageStyle(width int) lipgloss.Style
- func ErrorMessageStyle(width int) lipgloss.Style
- func FilePickerCursorStyle() lipgloss.Style
- func FilePickerStyle(width int) lipgloss.Style
- func InputStyle(width, height int) lipgloss.Style
- func LoadFilesCmd() tea.Cmd
- func MessageTimestampStyle(width int) lipgloss.Style
- func RenderAssistantBlock(width int, modelName, content string) string
- func RenderIntroBlock(width int, title, version, content string) string
- func RenderMarkdown(content string, width int) string
- func RenderSplitDiff(diff string, width int) string
- func RenderToolBlock(width int, toolName, content string) string
- func RenderUserBlock(width int, content string) string
- func SaveSession(path, model string, apiMessages []api.Message, messages []Message) error
- func SearchMatchStyle() lipgloss.Style
- func SendCompactCmd(client *api.Client, history []Message, timeout time.Duration) tea.Cmd
- func SendPromptCmd(client *api.Client, apiMessages []api.Message, prompt string) (tea.Cmd, context.CancelFunc)
- func SendPromptCmdWithTimeout(client *api.Client, apiMessages []api.Message, prompt string, ...) (tea.Cmd, context.CancelFunc)
- func SessionPath() string
- func SpinnerStyle() lipgloss.Style
- func StatusBarModelStyle() lipgloss.Style
- func StatusBarSepStyle() lipgloss.Style
- func StatusBarTokenStyle() lipgloss.Style
- func SystemMessageStyle(width int) lipgloss.Style
- func TimerStyle() lipgloss.Style
- func ToolApprovalCanceledLabelStyle() lipgloss.Style
- func ToolApprovalDeniedPreviewStyle() lipgloss.Style
- func ToolApprovalDeniedToolStyle() lipgloss.Style
- func ToolApprovalModelStyle() lipgloss.Style
- func ToolApprovalPreviewStyle() lipgloss.Style
- func ToolApprovalToolStyle() lipgloss.Style
- func ToolMessageStyle(width int) lipgloss.Style
- func UserMessageStyle(width int) lipgloss.Style
- func WaitingStyle() lipgloss.Style
- type ApprovingExecutor
- type CommandPicker
- func (cp *CommandPicker) Activate()
- func (cp *CommandPicker) Deactivate()
- func (cp CommandPicker) Height() int
- func (cp CommandPicker) IsActive() bool
- func (cp CommandPicker) SelectedCommand() string
- func (cp *CommandPicker) SetQuery(query string)
- func (cp *CommandPicker) SetWidth(w int)
- func (cp CommandPicker) Update(msg tea.Msg) (CommandPicker, tea.Cmd)
- func (cp CommandPicker) View() string
- type CompactResponseMsg
- type FilePicker
- func (fp *FilePicker) Activate()
- func (fp *FilePicker) Deactivate()
- func (fp FilePicker) Height() int
- func (fp FilePicker) IsActive() bool
- func (fp FilePicker) SelectedFile() string
- func (fp *FilePicker) SetFiles(files []string)
- func (fp *FilePicker) SetQuery(query string)
- func (fp *FilePicker) SetWidth(width int)
- func (fp FilePicker) Update(msg tea.Msg) (FilePicker, tea.Cmd)
- func (fp FilePicker) View() string
- type FilesLoadedMsg
- type HelpPanel
- type History
- type Message
- type Model
- func (m *Model) AddMessage(role, content string)
- func (m Model) CanSubmit() bool
- func (m *Model) ClearInput()
- func (m Model) GetAPIMessages() []api.Message
- func (m Model) GetDimensions() (int, int)
- func (m Model) GetHistory() []Message
- func (m Model) GetInput() string
- func (m Model) GetViewportHeight() int
- func (m Model) Init() tea.Cmd
- func (m Model) IsApeMode() bool
- func (m Model) IsLoading() bool
- func (m Model) IsTimerRunning() bool
- func (m *Model) RestoreSession(sess *SessionData)
- func (m *Model) SetDimensions(width, height int)
- func (m *Model) SetInput(text string)
- func (m *Model) SetIntro(intro string)
- func (m *Model) SetIntroTitle(title string)
- func (m *Model) SetIntroVersion(version string)
- func (m *Model) SetLoading(loading bool)
- func (m *Model) SetModels(models []string)
- func (m *Model) SetTimerActive(v bool)
- func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (m Model) View() string
- type ModelPicker
- func (mp *ModelPicker) Activate()
- func (mp *ModelPicker) Deactivate()
- func (mp ModelPicker) Height() int
- func (mp ModelPicker) IsActive() bool
- func (mp ModelPicker) SelectedModel() string
- func (mp *ModelPicker) SetCursor(model string)
- func (mp *ModelPicker) SetModels(models []string)
- func (mp *ModelPicker) SetWidth(w int)
- func (mp ModelPicker) Update(msg tea.Msg) (ModelPicker, tea.Cmd)
- func (mp ModelPicker) View() string
- type PartialResponseMsg
- type PromptCancelledMsg
- type PromptErrorMsg
- type PromptResponseMsg
- type RetryingMsg
- type SearchBar
- func (s *SearchBar) Activate()
- func (s SearchBar) CurrentMatchIndex() int
- func (s *SearchBar) Deactivate()
- func (s SearchBar) IsActive() bool
- func (s SearchBar) IsMatch(i int) bool
- func (s SearchBar) MatchCount() int
- func (s *SearchBar) NextMatch()
- func (s *SearchBar) PrevMatch()
- func (s SearchBar) Query() string
- func (s *SearchBar) SetQuery(q string, messages []Message)
- type SessionData
- type SlashCommand
- type State
- type ToolApprovalDialog
- func (d *ToolApprovalDialog) Activate(modelName, toolName, previewText string, responseCh chan<- bool)
- func (d *ToolApprovalDialog) Confirm()
- func (d *ToolApprovalDialog) Deactivate()
- func (d ToolApprovalDialog) DeniedHeight() int
- func (d ToolApprovalDialog) DeniedView() string
- func (d *ToolApprovalDialog) Deny()
- func (d ToolApprovalDialog) Height() int
- func (d ToolApprovalDialog) IsActive() bool
- func (d ToolApprovalDialog) IsApproved() bool
- func (d ToolApprovalDialog) IsDenied() bool
- func (d *ToolApprovalDialog) SetWidth(w int)
- func (d ToolApprovalDialog) Update(msg tea.Msg) (ToolApprovalDialog, tea.Cmd)
- func (d ToolApprovalDialog) View() string
- type ToolApprovalRequestMsg
- type ToolCallMsg
Constants ¶
const ( EnvPriceInput = "MONKEY_PRICE_INPUT" EnvPriceOutput = "MONKEY_PRICE_OUTPUT" )
Environment variables for overriding model pricing (USD per million tokens).
const ( ColorPrimary = "#461914" // Deep Brown-Red ColorAccent = "#A89228" // Antique Gold )
Primary brand colors. ColorPrimary is the anchor color for persistent UI elements (e.g. input border). ColorAccent is the warm highlight used for active/selected states.
const ( ColorUserBorder = "#8B3A21" // Rust Brown — warm, personal ColorAssistantBorder = "#729B2F" // Leaf Green — natural, positive ColorToolBorder = "#225057" // Dark Slate — cool, functional ColorSystemBorder = "#305322" // Forest Green — subdued, informational ColorErrorBorder = "#BA3F28" // Burnt Orange — danger/warning )
Message role border colors.
const ( ColorGrayLight = "#AAAAAA" // timer, secondary info ColorGrayMid = "#888888" // muted labels, canceled state ColorGrayDark = "#666666" // picker borders, subdued help text ColorGrayDeep = "#555555" // timestamps, inactive state, faint text )
Muted gray scale — explicit names instead of ad-hoc hex literals.
const ( ColorDiffAdd = ColorAssistantBorder // green — positive change, same as assistant border ColorDiffDel = ColorErrorBorder // red — destructive change, same as error border ColorDiffHunk = ColorToolBorder // cyan — structural/informational, same as tool border ColorDiffGutter = ColorGrayDeep // faint — line numbers recede into the background )
Diff view colors — derived from the app's existing semantic palette. Using ColorAssistantBorder and ColorToolBorder eliminates the three-greens and GitHub-blue problems: there is now one green and one cyan in the whole app.
const ( ColorApprovalModel = ColorAssistantBorder // green — the assistant is acting ColorApprovalTool = ColorToolBorder // cyan — it is a tool call )
Tool approval dialog colors, derived from existing semantic tokens.
const ( ColorMonkeyDark = "#2B1200" // very dark brown — ██ outline ColorMonkeyMid = "#7B4220" // medium brown — ▒▒ body ColorMonkeySkin = "#7c3400" // warm brown — ▓▓ skin ColorMonkeyLight = "#C49A6C" // warm tan — ░░ face / underbelly )
Intro art pixel colors — four tiers of block shading for the monkey sprite.
const APITimeout = 60 * time.Second
APITimeout is the default timeout for API requests
const ColorPickerCursor = ColorAccent
ColorPickerCursor is the highlighted-row color in all pickers. Uses ColorAccent so selection reads as "warm highlight", not "assistant message".
Variables ¶
This section is empty.
Functions ¶
func ApeModeActiveStyle ¶
ApeModeActiveStyle returns accent-color styling for the ape mode indicator when enabled.
func ApeModeInactiveStyle ¶
ApeModeInactiveStyle returns grey styling for the ape mode indicator when disabled.
func AssistantMessageStyle ¶
AssistantMessageStyle returns the styling for assistant messages
func ErrorMessageStyle ¶
ErrorMessageStyle returns the styling for error messages
func FilePickerCursorStyle ¶
FilePickerCursorStyle returns the styling for the highlighted file picker row. Uses ColorPickerCursor (accent) so "selected" reads as a warm highlight, distinct from ColorAssistantBorder which means "assistant message".
func FilePickerStyle ¶
FilePickerStyle returns the styling for the file picker dropdown border.
func InputStyle ¶
InputStyle returns the styling for the input textarea. Uses ColorAccent so the active input zone is clearly visible all session long.
func LoadFilesCmd ¶
LoadFilesCmd returns a tea.Cmd that walks the current directory tree and collects relative file paths, skipping hidden directories and vendor/node_modules.
func MessageTimestampStyle ¶
MessageTimestampStyle returns the styling for per-message timestamps: gray, right-aligned.
func RenderAssistantBlock ¶
RenderAssistantBlock renders an assistant message inside a green rounded border with the model name embedded in the top border: ╭─ claude-sonnet-4-5 ──────╮
func RenderIntroBlock ¶
RenderIntroBlock renders a two-panel block: left panel sized to fit the ASCII art, right panel taking the remaining space (title + version + help text).
func RenderMarkdown ¶
RenderMarkdown renders markdown-formatted content as ANSI-styled terminal text. Falls back to the original content if rendering fails or width is zero.
func RenderSplitDiff ¶
RenderSplitDiff renders a unified diff as two side-by-side panels: "Before" (left, red border) shows context + deleted lines, "After" (right, green border) shows context + added lines. Paired deletion/addition chunks are aligned on the same row.
func RenderToolBlock ¶
RenderToolBlock renders a tool call message inside a cyan rounded border with the tool name embedded in the top border: ╭─ bash ──────╮
func RenderUserBlock ¶
RenderUserBlock renders a user message inside a purple rounded border with "You" embedded in the top border: ╭─ You ──────╮
func SaveSession ¶
SaveSession persists the current session to path, creating parent directories as needed.
func SearchMatchStyle ¶
SearchMatchStyle returns the styling for the search-match indicator shown above matching messages.
func SendCompactCmd ¶
SendCompactCmd creates a tea.Cmd that sends a summarization request to the API. history is the current display messages used to build the summarization prompt. On success it returns a CompactResponseMsg; on failure a PromptErrorMsg.
func SendPromptCmd ¶
func SendPromptCmd(client *api.Client, apiMessages []api.Message, prompt string) (tea.Cmd, context.CancelFunc)
SendPromptCmd creates a tea.Cmd that sends the conversation history plus the new prompt to the API using the default timeout. apiMessages is the full API-layer history (including tool_use/tool_result from prior turns). The returned CancelFunc can be called to cancel the in-flight request.
func SendPromptCmdWithTimeout ¶
func SendPromptCmdWithTimeout(client *api.Client, apiMessages []api.Message, prompt string, timeout time.Duration, toolCallCh chan<- ToolCallMsg, approvalCh chan<- ToolApprovalRequestMsg, tokenCh chan<- PartialResponseMsg, retryChs ...chan<- RetryingMsg) (tea.Cmd, context.CancelFunc)
SendPromptCmdWithTimeout creates a tea.Cmd that sends the prompt with a per-attempt timeout. apiMessages is the full API-layer history (including tool_use/tool_result from prior turns). The returned CancelFunc can be called to cancel the in-flight request. toolCallCh, if non-nil, receives a ToolCallMsg for each tool call as it completes and is closed when done. approvalCh, if non-nil, enables the approval harness: each tool call sends a ToolApprovalRequestMsg and blocks until the TUI responds. When nil, tools execute without approval. tokenCh, if non-nil, uses the streaming SSE API and receives a PartialResponseMsg for each text token. An optional retryCh receives a RetryingMsg before each retry attempt and is closed when done.
func SessionPath ¶
func SessionPath() string
SessionPath returns the path to the session file, respecting XDG_CONFIG_HOME.
func SpinnerStyle ¶
SpinnerStyle returns the styling for the loading spinner
func StatusBarModelStyle ¶
StatusBarModelStyle renders the current model name in the status bar.
func StatusBarSepStyle ¶
StatusBarSepStyle renders the "|" separator between status bar segments.
func StatusBarTokenStyle ¶
StatusBarTokenStyle renders the token count in the status bar.
func SystemMessageStyle ¶
SystemMessageStyle returns the styling for system notices (e.g. retry messages)
func TimerStyle ¶
TimerStyle returns the styling for the elapsed time indicator
func ToolApprovalCanceledLabelStyle ¶
ToolApprovalCanceledLabelStyle returns muted gray italic styling for the "Canceled by user" label.
func ToolApprovalDeniedPreviewStyle ¶
ToolApprovalDeniedPreviewStyle returns faint gray styling for the preview in a canceled dialog.
func ToolApprovalDeniedToolStyle ¶
ToolApprovalDeniedToolStyle returns muted styling for the tool name in a canceled dialog.
func ToolApprovalModelStyle ¶
ToolApprovalModelStyle returns styling for the model name in the approval dialog. Uses ColorApprovalModel (green) — the assistant is the one requesting action.
func ToolApprovalPreviewStyle ¶
ToolApprovalPreviewStyle returns styling for the bash command preview line.
func ToolApprovalToolStyle ¶
ToolApprovalToolStyle returns styling for the tool name in the approval dialog. Uses ColorApprovalTool (cyan) — consistent with tool call borders.
func ToolMessageStyle ¶
ToolMessageStyle returns the styling for tool call messages (cyan border)
func UserMessageStyle ¶
UserMessageStyle returns the styling for user messages
func WaitingStyle ¶
WaitingStyle returns the styling for the idle/waiting prompt shown after cancellation.
Types ¶
type ApprovingExecutor ¶
type ApprovingExecutor struct {
// contains filtered or unexported fields
}
ApprovingExecutor wraps a ToolExecutor and requests user approval before each tool call. It sends a ToolApprovalRequestMsg on approvalCh and blocks until the TUI responds.
func (ApprovingExecutor) ExecuteTool ¶
func (a ApprovingExecutor) ExecuteTool(ctx context.Context, name string, input map[string]any) (string, error)
ExecuteTool requests approval via approvalCh, then delegates to inner on approval. Returns ctx.Err() if the context is cancelled while waiting for the user's decision.
type CommandPicker ¶
type CommandPicker struct {
// contains filtered or unexported fields
}
CommandPicker is a keyboard-navigable dropdown for slash command completion.
func NewCommandPicker ¶
func NewCommandPicker(width int) CommandPicker
NewCommandPicker returns an inactive command picker.
func (*CommandPicker) Activate ¶
func (cp *CommandPicker) Activate()
Activate makes the picker visible.
func (*CommandPicker) Deactivate ¶
func (cp *CommandPicker) Deactivate()
Deactivate hides the picker.
func (CommandPicker) Height ¶
func (cp CommandPicker) Height() int
Height returns the number of terminal rows occupied by the picker without rendering it. Returns 0 when inactive. Used by syncViewportHeight to avoid a full View() render just to count lines.
func (CommandPicker) IsActive ¶
func (cp CommandPicker) IsActive() bool
IsActive reports whether the picker is visible.
func (CommandPicker) SelectedCommand ¶
func (cp CommandPicker) SelectedCommand() string
SelectedCommand returns the full slash command string (e.g. "/exit") for the currently highlighted entry, or "" when inactive or no match.
func (*CommandPicker) SetQuery ¶
func (cp *CommandPicker) SetQuery(query string)
SetQuery filters commands by fuzzy-matching against the query.
func (*CommandPicker) SetWidth ¶
func (cp *CommandPicker) SetWidth(w int)
SetWidth updates the display width.
func (CommandPicker) Update ¶
func (cp CommandPicker) Update(msg tea.Msg) (CommandPicker, tea.Cmd)
Update handles Up/Down cursor navigation.
func (CommandPicker) View ¶
func (cp CommandPicker) View() string
View renders the command picker dropdown. Returns "" when inactive.
type CompactResponseMsg ¶
type CompactResponseMsg struct {
Summary string
}
CompactResponseMsg is returned when a /compact summarization request succeeds. Summary holds the condensed conversation text that replaces the message history.
type FilePicker ¶
type FilePicker struct {
// contains filtered or unexported fields
}
FilePicker is a keyboard-navigable file selection dropdown.
func NewFilePicker ¶
func NewFilePicker(width int) FilePicker
NewFilePicker returns an inactive file picker with the given display width.
func (FilePicker) Height ¶
func (fp FilePicker) Height() int
Height returns the number of terminal rows occupied by the picker without rendering it. Returns 0 when inactive. Used by syncViewportHeight to avoid a full View() render just to count lines.
func (FilePicker) IsActive ¶
func (fp FilePicker) IsActive() bool
IsActive reports whether the picker is currently visible.
func (FilePicker) SelectedFile ¶
func (fp FilePicker) SelectedFile() string
SelectedFile returns the currently highlighted file path, or "" if none.
func (*FilePicker) SetFiles ¶
func (fp *FilePicker) SetFiles(files []string)
SetFiles replaces the full file list and resets filtering.
func (*FilePicker) SetQuery ¶
func (fp *FilePicker) SetQuery(query string)
SetQuery filters the list by fuzzy-matching each file path against query. An empty query shows all files.
func (*FilePicker) SetWidth ¶
func (fp *FilePicker) SetWidth(width int)
SetWidth updates the display width.
func (FilePicker) Update ¶
func (fp FilePicker) Update(msg tea.Msg) (FilePicker, tea.Cmd)
Update handles Up/Down cursor navigation.
func (FilePicker) View ¶
func (fp FilePicker) View() string
View renders the picker as a bordered dropdown. Returns "" when inactive.
type FilesLoadedMsg ¶
type FilesLoadedMsg struct {
Files []string
}
FilesLoadedMsg is sent when the async file walk completes.
type HelpPanel ¶
type HelpPanel struct {
// contains filtered or unexported fields
}
HelpPanel is a static panel listing available input shortcuts.
func NewHelpPanel ¶
NewHelpPanel returns an inactive help panel.
type History ¶
type History struct {
// contains filtered or unexported fields
}
History manages prompt history persisted to a local file. Navigation mimics bash: Up moves to older entries, Down moves to newer ones.
func LoadHistory ¶
func LoadHistory() History
LoadHistory loads history from ~/.config/monkey/history (respecting XDG_DATA_HOME), creating it if it does not exist.
func (*History) Add ¶
Add appends an entry to the history and persists it to disk. Blank entries and consecutive duplicates are ignored.
type Message ¶
type Message struct {
Role string
Content string
ToolName string // set for Role=="tool" messages
Timestamp time.Time
Collapsed bool // for tool messages: true when long output is folded
}
Message represents a single message in the conversation
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the main bubbletea model for the TUI
func (*Model) AddMessage ¶
AddMessage appends a message to the conversation history (pointer receiver to mutate in place)
func (*Model) ClearInput ¶
func (m *Model) ClearInput()
ClearInput clears the input text (pointer receiver to mutate in place)
func (Model) GetAPIMessages ¶
GetAPIMessages returns the full API-layer message history (includes tool_use/tool_result).
func (Model) GetDimensions ¶
GetDimensions returns the current width and height
func (Model) GetHistory ¶
GetHistory returns the conversation history
func (Model) GetViewportHeight ¶
GetViewportHeight returns the current viewport height (for testing).
func (Model) IsTimerRunning ¶
IsTimerRunning returns whether the elapsed timer is active
func (*Model) RestoreSession ¶
func (m *Model) RestoreSession(sess *SessionData)
RestoreSession loads a saved SessionData into the model.
func (*Model) SetDimensions ¶
SetDimensions sets the viewport and textarea dimensions (pointer receiver to mutate in place)
func (*Model) SetIntro ¶
SetIntro sets the intro content (ASCII art + version) shown on startup before any messages.
func (*Model) SetIntroTitle ¶
SetIntroTitle sets the title displayed in the intro block's border.
func (*Model) SetIntroVersion ¶
SetIntroVersion sets the version string displayed next to the title in the intro block's border.
func (*Model) SetLoading ¶
SetLoading sets the loading state (pointer receiver to mutate in place)
func (*Model) SetTimerActive ¶
SetTimerActive sets the timer active state and records the start time when activating
type ModelPicker ¶
type ModelPicker struct {
// contains filtered or unexported fields
}
ModelPicker is a keyboard-navigable list for switching the active model.
func NewModelPicker ¶
func NewModelPicker(width int) ModelPicker
NewModelPicker returns an inactive model picker.
func (ModelPicker) Height ¶
func (mp ModelPicker) Height() int
Height returns the number of terminal rows occupied by the picker without rendering it. Returns 0 when inactive. Used by syncViewportHeight to avoid a full View() render just to count lines.
func (ModelPicker) IsActive ¶
func (mp ModelPicker) IsActive() bool
IsActive reports whether the picker is visible.
func (ModelPicker) SelectedModel ¶
func (mp ModelPicker) SelectedModel() string
SelectedModel returns the model under the cursor, or "" when inactive or empty.
func (*ModelPicker) SetCursor ¶
func (mp *ModelPicker) SetCursor(model string)
SetCursor positions the cursor on the given model value (0 if not found).
func (*ModelPicker) SetModels ¶
func (mp *ModelPicker) SetModels(models []string)
SetModels sets the available model values.
func (*ModelPicker) SetWidth ¶
func (mp *ModelPicker) SetWidth(w int)
SetWidth updates the display width.
func (ModelPicker) Update ¶
func (mp ModelPicker) Update(msg tea.Msg) (ModelPicker, tea.Cmd)
Update handles Up/Down cursor navigation.
func (ModelPicker) View ¶
func (mp ModelPicker) View() string
View renders the model picker dropdown. Returns "" when inactive.
type PartialResponseMsg ¶
type PartialResponseMsg struct {
Token string
}
PartialResponseMsg carries a single streamed text token from the assistant.
type PromptCancelledMsg ¶
type PromptCancelledMsg struct{}
PromptCancelledMsg is returned when the in-flight request is cancelled by the user
type PromptErrorMsg ¶
type PromptErrorMsg struct {
Err error
}
PromptErrorMsg is returned when the API returns an error
type PromptResponseMsg ¶
type PromptResponseMsg struct {
Response string
APIMessages []api.Message // full accumulated history including tool_use/tool_result
Usage api.Usage // token counts for this turn
}
PromptResponseMsg is returned when the API responds successfully
type RetryingMsg ¶
RetryingMsg is sent to the model when the API client is about to retry a failed request.
type SearchBar ¶
type SearchBar struct {
// contains filtered or unexported fields
}
SearchBar provides incremental search over conversation messages. Ctrl+F activates it; Ctrl+N / Ctrl+P cycle matches; Esc dismisses.
func (SearchBar) CurrentMatchIndex ¶
CurrentMatchIndex returns the message index of the current match, or -1 when there are no matches.
func (*SearchBar) Deactivate ¶
func (s *SearchBar) Deactivate()
Deactivate hides the search bar and clears state.
func (SearchBar) MatchCount ¶
MatchCount returns the number of matching messages.
func (*SearchBar) NextMatch ¶
func (s *SearchBar) NextMatch()
NextMatch advances the cursor to the next match, wrapping around.
type SessionData ¶
type SessionData struct {
Model string `json:"model"`
APIMessages []api.Message `json:"api_messages"`
Messages []Message `json:"messages"`
}
SessionData is the persisted state for --continue.
func LoadSession ¶
func LoadSession(path string) (*SessionData, error)
LoadSession reads the session file at path and returns the decoded SessionData. Returns (nil, nil) when the file does not exist.
type SlashCommand ¶
SlashCommand represents a supported slash command.
type ToolApprovalDialog ¶
type ToolApprovalDialog struct {
// contains filtered or unexported fields
}
ToolApprovalDialog is a Yes/No prompt shown when the model wants to run a tool.
func NewToolApprovalDialog ¶
func NewToolApprovalDialog(width int) ToolApprovalDialog
NewToolApprovalDialog returns an inactive approval dialog.
func (*ToolApprovalDialog) Activate ¶
func (d *ToolApprovalDialog) Activate(modelName, toolName, previewText string, responseCh chan<- bool)
Activate shows the dialog for the given model/tool pair with a response channel. previewText is optional additional content shown above the Yes/No prompt (e.g. a diff). The cursor is reset to Yes on each activation.
func (*ToolApprovalDialog) Confirm ¶
func (d *ToolApprovalDialog) Confirm()
Confirm sends the user's decision on responseCh and deactivates the dialog. If the cursor is on "No", sets the denied state so DeniedView can render.
func (*ToolApprovalDialog) Deactivate ¶
func (d *ToolApprovalDialog) Deactivate()
Deactivate hides the dialog and clears the response channel.
func (ToolApprovalDialog) DeniedHeight ¶
func (d ToolApprovalDialog) DeniedHeight() int
DeniedHeight returns the cached row count of DeniedView(). Returns 0 when not in the denied state. The value is computed once in Confirm() when the user selects "No".
func (ToolApprovalDialog) DeniedView ¶
func (d ToolApprovalDialog) DeniedView() string
DeniedView renders a grayed-out version of the dialog after the user cancels a tool. Returns "" when not in the denied state.
func (*ToolApprovalDialog) Deny ¶
func (d *ToolApprovalDialog) Deny()
Deny sends false on responseCh (non-blocking) and deactivates the dialog. Used for cancellation paths where the executor may have already timed out.
func (ToolApprovalDialog) Height ¶
func (d ToolApprovalDialog) Height() int
Height returns the cached row count of View(). Returns 0 when inactive. The value is computed once in Activate() to avoid re-rendering on every syncViewportHeight call.
func (ToolApprovalDialog) IsActive ¶
func (d ToolApprovalDialog) IsActive() bool
IsActive reports whether the dialog is visible.
func (ToolApprovalDialog) IsApproved ¶
func (d ToolApprovalDialog) IsApproved() bool
IsApproved reports whether the cursor is on "Yes".
func (ToolApprovalDialog) IsDenied ¶
func (d ToolApprovalDialog) IsDenied() bool
IsDenied reports whether the user explicitly selected "No" to cancel the tool.
func (*ToolApprovalDialog) SetWidth ¶
func (d *ToolApprovalDialog) SetWidth(w int)
SetWidth updates the display width.
func (ToolApprovalDialog) Update ¶
func (d ToolApprovalDialog) Update(msg tea.Msg) (ToolApprovalDialog, tea.Cmd)
Update handles Up/Down cursor navigation.
func (ToolApprovalDialog) View ¶
func (d ToolApprovalDialog) View() string
View renders the approval dialog. Returns "" when inactive.
type ToolApprovalRequestMsg ¶
type ToolApprovalRequestMsg struct {
ModelName string
ToolName string
Input map[string]any
ResponseCh chan<- bool
}
ToolApprovalRequestMsg is sent when the model wants to execute a tool and needs user approval.
type ToolCallMsg ¶
type ToolCallMsg struct {
ToolCall api.ToolCallResult
}
ToolCallMsg is sent to the model as each tool call completes during the API loop.