ui

package
v0.178.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateConversationHeight added in v0.18.1

func CalculateConversationHeight(totalHeight int) int

Layout calculation utilities

func CalculateInputHeight added in v0.18.1

func CalculateInputHeight(totalHeight int) int

func CalculateStatusHeight added in v0.18.1

func CalculateStatusHeight(totalHeight int) int

Types

type A2ATaskCoordinator added in v0.178.0

type A2ATaskCoordinator interface {
	HandleTaskSubmitted(msg agentdomain.A2ATaskSubmittedEvent) tea.Cmd
	HandleTaskCompleted(msg agentdomain.A2ATaskCompletedEvent) tea.Cmd
	HandleTaskFailed(msg agentdomain.A2ATaskFailedEvent) tea.Cmd
	HandleTaskStatusUpdate(msg agentdomain.A2ATaskStatusUpdateEvent) tea.Cmd
	HandleTaskInputRequired(msg agentdomain.A2ATaskInputRequiredEvent) tea.Cmd
	HandleToolCallExecuted(msg agentdomain.A2AToolCallExecutedEvent) tea.Cmd
}

A2ATaskCoordinator owns the UI side of A2A (agent-to-agent) task lifecycle events. It translates the six A2A event types into status updates, streaming-content events, and conversation-history refreshes, and keeps the chat session listener pumping. Self-contained - depends only on the conversation repo, task retention, the chat state manager, and a chat event listener.

type AgentReadinessState added in v0.178.0

type AgentReadinessState struct {
	TotalAgents int                     `json:"total_agents"`
	ReadyAgents int                     `json:"ready_agents"`
	Agents      map[string]*AgentStatus `json:"agents"`
	StartTime   time.Time               `json:"start_time"`
}

AgentReadinessState represents the current state of A2A agents during startup

type AgentStatus added in v0.178.0

type AgentStatus struct {
	Name        string                 `json:"name"`
	URL         string                 `json:"url"`
	Image       string                 `json:"image"`
	State       agentdomain.AgentState `json:"state"`
	Message     string                 `json:"message,omitempty"`
	StartTime   time.Time              `json:"start_time"`
	Error       string                 `json:"error,omitempty"`
	LayersDone  int                    `json:"layers_done,omitempty"`
	LayersTotal int                    `json:"layers_total,omitempty"`
}

AgentStatus represents the status of an individual A2A agent

type AgentStatusUpdateEvent added in v0.178.0

type AgentStatusUpdateEvent struct {
	AgentName string
	State     agentdomain.AgentState
	Message   string
	URL       string
	Image     string
}

AgentStatusUpdateEvent indicates an agent's status has changed

type ApplicationState added in v0.178.0

type ApplicationState struct {
	// contains filtered or unexported fields
}

ApplicationState represents the overall application state with proper typing

func NewApplicationState added in v0.178.0

func NewApplicationState() *ApplicationState

NewApplicationState creates a new application state

func (*ApplicationState) AddQueuedMessage added in v0.178.0

func (s *ApplicationState) AddQueuedMessage(message sdk.Message, requestID string)

AddQueuedMessage adds a message to the input queue

func (*ApplicationState) AreAllAgentsReady added in v0.178.0

func (s *ApplicationState) AreAllAgentsReady() bool

AreAllAgentsReady returns true if all agents are ready

func (*ApplicationState) ClearAgentReadiness added in v0.178.0

func (s *ApplicationState) ClearAgentReadiness()

ClearAgentReadiness clears the agent readiness state

func (*ApplicationState) ClearApprovalUIState added in v0.178.0

func (s *ApplicationState) ClearApprovalUIState()

ClearApprovalUIState clears the approval UI state

func (*ApplicationState) ClearComputerUsePauseState added in v0.178.0

func (s *ApplicationState) ClearComputerUsePauseState()

ClearComputerUsePauseState clears the pause state

func (*ApplicationState) ClearFileSelectionState added in v0.178.0

func (s *ApplicationState) ClearFileSelectionState()

ClearFileSelectionState clears the file selection state

func (*ApplicationState) ClearLastClickCoordinates added in v0.178.0

func (s *ApplicationState) ClearLastClickCoordinates()

ClearLastClickCoordinates clears the stored click coordinates

func (*ApplicationState) ClearLastFocusedApp added in v0.178.0

func (s *ApplicationState) ClearLastFocusedApp()

ClearLastFocusedApp clears the stored focused app

func (*ApplicationState) ClearMessageEditState added in v0.178.0

func (s *ApplicationState) ClearMessageEditState()

ClearMessageEditState clears the message edit state

func (*ApplicationState) ClearPlanApprovalUIState added in v0.178.0

func (s *ApplicationState) ClearPlanApprovalUIState()

ClearPlanApprovalUIState clears the plan approval UI state

func (*ApplicationState) ClearQueuedMessages added in v0.178.0

func (s *ApplicationState) ClearQueuedMessages()

ClearQueuedMessages clears all queued messages

func (*ApplicationState) ClearUserQuestionUIState added in v0.178.0

func (s *ApplicationState) ClearUserQuestionUIState()

ClearUserQuestionUIState clears the AskUserQuestion form state and closes the response channel (without a prior send this signals cancellation to the blocked tool). Nil-safe and idempotent.

func (*ApplicationState) CompleteCurrentTool added in v0.178.0

func (s *ApplicationState) CompleteCurrentTool(result *agentdomain.ToolExecutionResult) error

CompleteCurrentTool marks the current tool as completed and moves to next

func (*ApplicationState) CycleAgentMode added in v0.178.0

func (s *ApplicationState) CycleAgentMode() agentdomain.AgentMode

CycleAgentMode cycles to the next agent mode. The human shift+tab cycle is deliberately three-way (Standard -> Plan -> AutoAccept); AgentModeReadOnly is a subagent-only capability set by the Agent tool's `type` parameter, not a mode a user can toggle their own chat into.

func (*ApplicationState) EndChatSession added in v0.178.0

func (s *ApplicationState) EndChatSession()

EndChatSession cleans up the chat session

func (*ApplicationState) EndToolExecution added in v0.178.0

func (s *ApplicationState) EndToolExecution()

EndToolExecution cleans up the tool execution session

func (*ApplicationState) FailCurrentTool added in v0.178.0

func (s *ApplicationState) FailCurrentTool(result *agentdomain.ToolExecutionResult) error

FailCurrentTool marks the current tool as failed and moves to next

func (*ApplicationState) GetAgentMode added in v0.178.0

func (s *ApplicationState) GetAgentMode() agentdomain.AgentMode

GetAgentMode returns the current agent mode

func (*ApplicationState) GetAgentReadiness added in v0.178.0

func (s *ApplicationState) GetAgentReadiness() *AgentReadinessState

GetAgentReadiness returns the current agent readiness state

func (*ApplicationState) GetApprovalUIState added in v0.178.0

func (s *ApplicationState) GetApprovalUIState() *agentdomain.ApprovalUIState

GetApprovalUIState returns the current approval UI state

func (*ApplicationState) GetChatSession added in v0.178.0

func (s *ApplicationState) GetChatSession() *agentdomain.ChatSession

GetChatSession returns the current chat session

func (*ApplicationState) GetCurrentView added in v0.178.0

func (s *ApplicationState) GetCurrentView() ViewState

GetCurrentView returns the current view state

func (*ApplicationState) GetDimensions added in v0.178.0

func (s *ApplicationState) GetDimensions() (int, int)

GetDimensions returns the current UI dimensions

func (*ApplicationState) GetFileSelectionState added in v0.178.0

func (s *ApplicationState) GetFileSelectionState() *FileSelectionState

GetFileSelectionState returns the current file selection state

func (*ApplicationState) GetLastClickCoordinates added in v0.178.0

func (s *ApplicationState) GetLastClickCoordinates() (x, y int)

GetLastClickCoordinates returns the coordinates of the last click

func (*ApplicationState) GetLastFocusedApp added in v0.178.0

func (s *ApplicationState) GetLastFocusedApp() string

GetLastFocusedApp returns the application ID of the last focused application

func (*ApplicationState) GetMessageEditState added in v0.178.0

func (s *ApplicationState) GetMessageEditState() *MessageEditState

GetMessageEditState returns the current message edit state

func (*ApplicationState) GetPausedRequestID added in v0.178.0

func (s *ApplicationState) GetPausedRequestID() string

GetPausedRequestID returns the request ID of the paused execution

func (*ApplicationState) GetPlanApprovalUIState added in v0.178.0

func (s *ApplicationState) GetPlanApprovalUIState() *agentdomain.PlanApprovalUIState

GetPlanApprovalUIState returns the current plan approval UI state

func (*ApplicationState) GetPreviousView added in v0.178.0

func (s *ApplicationState) GetPreviousView() ViewState

GetPreviousView returns the previous view state

func (*ApplicationState) GetQueuedMessages added in v0.178.0

func (s *ApplicationState) GetQueuedMessages() []convdomain.QueuedMessage

GetQueuedMessages returns the current queued messages

func (*ApplicationState) GetRetryStatus added in v0.178.0

func (s *ApplicationState) GetRetryStatus() *agentdomain.RetryStatus

GetRetryStatus returns a copy of the current retry status, or nil when no retry is in progress. Returning a copy keeps callers from sharing the mutable pointer with the agent's streaming goroutine.

func (*ApplicationState) GetTodos added in v0.178.0

func (s *ApplicationState) GetTodos() []agentdomain.TodoItem

GetTodos returns the current todo list

func (*ApplicationState) GetToolExecution added in v0.178.0

func (s *ApplicationState) GetToolExecution() *agentdomain.ToolExecutionSession

GetToolExecution returns the current tool execution session

func (*ApplicationState) GetUserQuestionUIState added in v0.178.0

func (s *ApplicationState) GetUserQuestionUIState() *agentdomain.UserQuestionUIState

GetUserQuestionUIState returns the current AskUserQuestion form state, or nil.

func (*ApplicationState) InitializeAgentReadiness added in v0.178.0

func (s *ApplicationState) InitializeAgentReadiness(totalAgents int)

InitializeAgentReadiness initializes the agent readiness tracking

func (*ApplicationState) IsComputerUsePaused added in v0.178.0

func (s *ApplicationState) IsComputerUsePaused() bool

IsComputerUsePaused returns whether computer use is currently paused

func (*ApplicationState) IsDebugMode added in v0.178.0

func (s *ApplicationState) IsDebugMode() bool

IsDebugMode returns whether debug mode is enabled

func (*ApplicationState) IsEditingMessage added in v0.178.0

func (s *ApplicationState) IsEditingMessage() bool

IsEditingMessage returns true if currently editing a message

func (*ApplicationState) PopQueuedMessage added in v0.178.0

func (s *ApplicationState) PopQueuedMessage() *convdomain.QueuedMessage

PopQueuedMessage removes and returns the first message from the queue (FIFO)

func (*ApplicationState) RemoveAgent added in v0.178.0

func (s *ApplicationState) RemoveAgent(name string)

RemoveAgent removes an agent from the readiness tracking

func (*ApplicationState) SetAgentError added in v0.178.0

func (s *ApplicationState) SetAgentError(name string, err error)

SetAgentError sets an error for a specific agent

func (*ApplicationState) SetAgentMode added in v0.178.0

func (s *ApplicationState) SetAgentMode(mode agentdomain.AgentMode)

SetAgentMode sets the agent mode

func (*ApplicationState) SetChatPending added in v0.178.0

func (s *ApplicationState) SetChatPending()

SetChatPending creates a minimal chat session to mark the agent as busy before the actual chat starts. This prevents race conditions.

func (*ApplicationState) SetComputerUsePaused added in v0.178.0

func (s *ApplicationState) SetComputerUsePaused(paused bool, requestID string)

SetComputerUsePaused sets the paused state for computer use

func (*ApplicationState) SetDebugMode added in v0.178.0

func (s *ApplicationState) SetDebugMode(enabled bool)

SetDebugMode enables or disables debug mode

func (*ApplicationState) SetDimensions added in v0.178.0

func (s *ApplicationState) SetDimensions(width, height int)

SetDimensions updates the UI dimensions

func (*ApplicationState) SetFileSelectedIndex added in v0.178.0

func (s *ApplicationState) SetFileSelectedIndex(index int)

SetFileSelectedIndex sets the selected file index

func (*ApplicationState) SetLastClickCoordinates added in v0.178.0

func (s *ApplicationState) SetLastClickCoordinates(x, y int)

SetLastClickCoordinates stores the coordinates of the last click

func (*ApplicationState) SetLastFocusedApp added in v0.178.0

func (s *ApplicationState) SetLastFocusedApp(appID string)

SetLastFocusedApp stores the application ID of the last focused application This is used to restore focus before keyboard operations

func (*ApplicationState) SetMessageEditState added in v0.178.0

func (s *ApplicationState) SetMessageEditState(state *MessageEditState)

SetMessageEditState sets the message edit state

func (*ApplicationState) SetPlanApprovalSelectedIndex added in v0.178.0

func (s *ApplicationState) SetPlanApprovalSelectedIndex(index int)

SetPlanApprovalSelectedIndex sets the plan approval selection index

func (*ApplicationState) SetRetryStatus added in v0.178.0

func (s *ApplicationState) SetRetryStatus(status *agentdomain.RetryStatus)

SetRetryStatus updates the retry status on the current chat session

func (*ApplicationState) SetTodos added in v0.178.0

func (s *ApplicationState) SetTodos(todos []agentdomain.TodoItem)

SetTodos sets the todo list

func (*ApplicationState) SetupApprovalUIState added in v0.178.0

func (s *ApplicationState) SetupApprovalUIState(toolCall *sdk.ChatCompletionMessageToolCall, responseChan chan agentdomain.ApprovalAction)

SetupApprovalUIState initializes approval UI state with the pending tool call

func (*ApplicationState) SetupFileSelection added in v0.178.0

func (s *ApplicationState) SetupFileSelection(files []string)

SetupFileSelection initializes file selection state

func (*ApplicationState) SetupPlanApprovalUIState added in v0.178.0

func (s *ApplicationState) SetupPlanApprovalUIState(planContent, planID string, responseChan chan agentdomain.PlanApprovalAction)

SetupPlanApprovalUIState initializes plan approval UI state

func (*ApplicationState) SetupUserQuestionUIState added in v0.178.0

func (s *ApplicationState) SetupUserQuestionUIState(questions []agentdomain.UserQuestion, responseChan chan []agentdomain.UserQuestionAnswer)

SetupUserQuestionUIState initializes the AskUserQuestion form state for the given questions.

func (*ApplicationState) StartChatSession added in v0.178.0

func (s *ApplicationState) StartChatSession(requestID, model string, eventChan <-chan agentdomain.ChatEvent)

StartChatSession initializes a new chat session

func (*ApplicationState) StartToolExecution added in v0.178.0

func (s *ApplicationState) StartToolExecution(tools []agentdomain.ToolCall)

StartToolExecution initializes a new tool execution session

func (*ApplicationState) TouchChatActivity added in v0.178.0

func (s *ApplicationState) TouchChatActivity()

TouchChatActivity records that the stream produced output: it bumps the session's LastActivity and clears any retry status, since receiving a chunk means the connection is healthy again.

func (*ApplicationState) TransitionToView added in v0.178.0

func (s *ApplicationState) TransitionToView(newView ViewState) error

TransitionToView changes the current view with validation

func (*ApplicationState) UpdateAgentPullProgress added in v0.178.0

func (s *ApplicationState) UpdateAgentPullProgress(name string, done, total int)

UpdateAgentPullProgress updates the image pull layer counts for a specific agent

func (*ApplicationState) UpdateAgentStatus added in v0.178.0

func (s *ApplicationState) UpdateAgentStatus(name string, state agentdomain.AgentState, message string, url string, image string)

UpdateAgentStatus updates the status of a specific agent

func (*ApplicationState) UpdateChatStatus added in v0.178.0

func (s *ApplicationState) UpdateChatStatus(status agentdomain.ChatStatus) error

UpdateChatStatus updates the chat session status

func (*ApplicationState) UpdateFileSearchQuery added in v0.178.0

func (s *ApplicationState) UpdateFileSearchQuery(query string)

UpdateFileSearchQuery updates the file search query

type ApprovalCoordinator added in v0.178.0

type ApprovalCoordinator interface {
	HandlePlanApprovalRequested(msg agentdomain.PlanApprovalRequestedEvent) tea.Cmd
	HandlePlanApprovalResponse(msg PlanApprovalResponseEvent) (cmd tea.Cmd, restart bool)
	HandleUserQuestionRequested(msg agentdomain.UserQuestionRequestedEvent) tea.Cmd
	HandleComputerUsePaused(msg agentdomain.ComputerUsePausedEvent) tea.Cmd
	HandleComputerUseResumed(msg agentdomain.ComputerUseResumedEvent) (cmd tea.Cmd, restart bool)
}

ApprovalCoordinator owns the "pause the assistant turn pending external decision" family of events: plan approval (the agent stops, presents a plan, awaits user accept/reject) and computer-use pause/resume (the user hits a key to interrupt computer-use execution and later resumes).

Response handlers return a restart bool so the orchestrator can fire ChatCompletionRunner.Start() after the cmds without ApprovalCoordinator having to depend on the runner.

type AutocompleteCompleteEvent added in v0.178.0

type AutocompleteCompleteEvent struct {
	Completion string
	CursorPos  int
}

AutocompleteCompleteEvent is fired when a completion is selected

type AutocompleteComponent added in v0.76.5

type AutocompleteComponent interface {
	Update(inputText string, cursorPos int)
	HandleKey(key tea.KeyPressMsg) (bool, string)
	IsVisible() bool
	SetWidth(width int)
	SetHeight(height int)
	Render() string
	GetSelectedShortcut() string
	GetCompletionCursorPos() int
	Hide()
	RefreshToolsList()
	GetUsageHint() string
	ClearUsageHint()
}

AutocompleteComponent defines the interface for autocomplete functionality

type AutocompleteHideEvent added in v0.178.0

type AutocompleteHideEvent struct{}

AutocompleteHideEvent is fired when autocomplete should be hidden

type AutocompleteUpdateEvent added in v0.178.0

type AutocompleteUpdateEvent struct {
	Text      string
	CursorPos int
}

AutocompleteUpdateEvent is fired when input text changes and autocomplete should update

type BashCommandCompletedEvent added in v0.178.0

type BashCommandCompletedEvent struct {
	History       []convdomain.ConversationEntry
	Failed        bool
	UserInitiated bool
	ErrorMessage  string
}

BashCommandCompletedEvent indicates a direct bash command (! prefix) has completed

type ChatCompletionRunner added in v0.178.0

type ChatCompletionRunner interface {
	Start(holder agentdomain.BashDetachChannelHolder) tea.Cmd
	HandleChatStart(msg agentdomain.ChatStartEvent) tea.Cmd
	HandleChatChunk(msg agentdomain.ChatChunkEvent) tea.Cmd
	HandleChatComplete(msg agentdomain.ChatCompleteEvent) tea.Cmd
	HandleChatError(msg agentdomain.ChatErrorEvent) tea.Cmd
	HandleOptimizationStatus(msg agentdomain.OptimizationStatusEvent) tea.Cmd
	SetPendingRestoration(originalModel string)
}

ChatCompletionRunner owns the LLM streaming lifecycle - initiating streaming, translating chat-start / chat-chunk / chat-complete / chat-error events into UI state transitions, and handling the model-restoration side effect after a temporary /model switch.

Start takes a BashDetachChannelHolder because the agent core needs that narrow interface attached to its context when launching tools that may require backgrounding. In #529 commit 3 that holder is the orchestrator itself; in commit 4 it becomes the DirectExecutionService.

type ChatEventListener added in v0.178.0

type ChatEventListener interface {
	ListenForChatEvents(eventChan <-chan agentdomain.ChatEvent) tea.Cmd
	ListenForEvents(eventChan <-chan tea.Msg) tea.Cmd
}

ChatEventListener wraps the small "read one message off a channel as a tea.Cmd" pattern used throughout the handlers. Extracted so services can chain channel reads back into the Bubble Tea event loop without each one re-implementing the same closure.

type ChatHandler added in v0.178.0

type ChatHandler interface {
	// Core event handling (to be deprecated as we move to component-based handling)
	Handle(msg tea.Msg) tea.Cmd

	// Specific event handlers
	HandleUserInputEvent(msg agentdomain.UserInputEvent) tea.Cmd
	HandleFileSelectionRequestEvent(msg FileSelectionRequestEvent) tea.Cmd
	HandleConversationSelectedEvent(msg ConversationSelectedEvent) tea.Cmd
	HandleToolApprovalRequestedEvent(msg agentdomain.ToolApprovalRequestedEvent) tea.Cmd
	HandleToolApprovalResponseEvent(msg agentdomain.ToolApprovalResponseEvent) tea.Cmd
	HandlePlanApprovalRequestedEvent(msg agentdomain.PlanApprovalRequestedEvent) tea.Cmd
	HandlePlanApprovalResponseEvent(msg PlanApprovalResponseEvent) tea.Cmd

	// Command handlers
	HandleCommand(commandText string) tea.Cmd
	HandleBashCommand(commandText string) tea.Cmd
	HandleToolCommand(commandText string) tea.Cmd
	HandleBackgroundShellRequest() tea.Cmd

	// Event channel listeners
	ListenForEvents(eventChan <-chan tea.Msg) tea.Cmd
	ListenForChatEvents(eventChan <-chan agentdomain.ChatEvent) tea.Cmd

	// State management
	GetActiveToolCallID() string
	SetActiveToolCallID(id string)

	// Utility methods
	ParseToolCall(input string) (string, map[string]any, error)
	ParseArguments(argsStr string) (map[string]any, error)
	SetBashDetachChan(chan<- struct{})
	GetBashDetachChan() chan<- struct{}
	ClearBashDetachChan()
}

ChatHandler defines the interface for the chat handler This interface enables testing handlers in isolation and provides a clear contract

type ClearErrorEvent added in v0.178.0

type ClearErrorEvent struct{}

ClearErrorEvent clears any displayed error

type ClearInputEvent added in v0.178.0

type ClearInputEvent struct{}

ClearInputEvent clears the input field

type ConversationRenderer

type ConversationRenderer interface {
	SetConversation([]convdomain.ConversationEntry)
	GetScrollOffset() int
	CanScrollUp() bool
	CanScrollDown() bool
	ToggleToolResultExpansion(index int)
	ToggleAllToolResultsExpansion()
	IsToolResultExpanded(index int) bool
	ToggleAllThinkingExpansion()
	IsThinkingExpanded(index int) bool
	ToggleRawFormat()
	IsRawFormat() bool
	ResetUserScroll()
	SetWidth(width int)
	SetHeight(height int)
	Render() string
}

ConversationRenderer interface for conversation display

type ConversationSelectedEvent added in v0.178.0

type ConversationSelectedEvent struct {
	ConversationID string
}

ConversationSelectedEvent indicates conversation selection

type ConversationsLoadedEvent added in v0.178.0

type ConversationsLoadedEvent struct {
	Conversations []any
	Error         error
}

ConversationsLoadedEvent indicates conversations have been loaded

type DebugKeyEvent added in v0.178.0

type DebugKeyEvent struct {
	Key     string
	Handler string
}

DebugKeyEvent provides debug information about key presses

type DefaultTheme

type DefaultTheme struct{}

DefaultTheme provides a concrete implementation of the Theme interface

func NewDefaultTheme

func NewDefaultTheme() *DefaultTheme

func (*DefaultTheme) GetAccentColor

func (t *DefaultTheme) GetAccentColor() string

func (*DefaultTheme) GetAssistantColor

func (t *DefaultTheme) GetAssistantColor() string

func (*DefaultTheme) GetBorderColor

func (t *DefaultTheme) GetBorderColor() string

func (*DefaultTheme) GetDiffAddColor added in v0.24.0

func (t *DefaultTheme) GetDiffAddColor() string

func (*DefaultTheme) GetDiffRemoveColor added in v0.24.0

func (t *DefaultTheme) GetDiffRemoveColor() string

func (*DefaultTheme) GetDimColor

func (t *DefaultTheme) GetDimColor() string

func (*DefaultTheme) GetErrorColor

func (t *DefaultTheme) GetErrorColor() string

func (*DefaultTheme) GetStatusColor

func (t *DefaultTheme) GetStatusColor() string

func (*DefaultTheme) GetSuccessColor added in v0.56.0

func (t *DefaultTheme) GetSuccessColor() string

func (*DefaultTheme) GetUserColor

func (t *DefaultTheme) GetUserColor() string

type DirectExecutionService added in v0.178.0

type DirectExecutionService interface {
	agentdomain.BashDetachChannelHolder

	HandleBashCommand(commandText string) tea.Cmd
	HandleToolCommand(commandText string) tea.Cmd
	HandleBackgroundShellRequest() tea.Cmd
	HandleBashOutputChunk(msg agentdomain.BashOutputChunkEvent) tea.Cmd
	HandleBashCommandCompleted(msg BashCommandCompletedEvent) tea.Cmd

	ParseToolCall(input string) (string, map[string]any, error)
	ParseArguments(argsStr string) (map[string]any, error)

	PendingBashChannel() <-chan tea.Msg
	PendingToolChannel() <-chan tea.Msg
}

DirectExecutionService owns user-typed `!command` (bash) and `!!Tool(...)` (tool) execution. It synthesizes the conversation entries, spawns the async goroutines, owns the per-call event/detach channels, and exposes the channels via PendingBashChannel / PendingToolChannel so the ToolExecutionCoordinator can keep pumping them.

Implements BashDetachChannelHolder so the agent core can find it on the request context (see WithChatHandler / GetChatHandler in context_helpers.go).

type DrainQueueRetryEvent added in v0.178.0

type DrainQueueRetryEvent struct{}

DrainQueueRetryEvent is the bounded retry behind DrainQueueEvent, and is NOT a clock. A DrainQueueEvent can land while the agent is momentarily busy (e.g. a background job finishes in the same instant the turn is still completing); the gate drops it, so without a retry the queue would strand. HandleDrainQueueEvent arms a single DrainQueueRetryEvent in that case, and the drainRetryArmed guard keeps it to exactly one outstanding timer no matter how many DrainQueueEvents arrived. When it fires, HandleDrainQueueRetryEvent re-runs the gate, which re-arms only while work is still stranded and stops the moment the queue drains.

type FileSelectionRequestEvent added in v0.178.0

type FileSelectionRequestEvent struct{}

FileSelectionRequestEvent requests file selection UI

type FileSelectionState added in v0.178.0

type FileSelectionState struct {
	Files         []string `json:"files"`
	SearchQuery   string   `json:"search_query"`
	SelectedIndex int      `json:"selected_index"`
}

FileSelectionState represents the state of file selection UI

type FocusStatusBarEvent added in v0.178.0

type FocusStatusBarEvent struct{}

FocusStatusBarEvent moves keyboard focus to the status-indicator row below the input, fired when arrow-down would otherwise be a no-op

type GitPRResolvedEvent added in v0.178.0

type GitPRResolvedEvent struct {
	PR string
}

GitPRResolvedEvent carries the PR number for the current branch, resolved asynchronously by the input view's fetch command. An empty PR means no PR exists (or gh is unavailable). Defined here rather than as a component-local msg because the chat application only routes domain-prefixed messages to UI components.

type HelpBarComponent added in v0.15.0

type HelpBarComponent interface {
	SetShortcuts(shortcuts []key.Binding)
	IsEnabled() bool
	SetEnabled(enabled bool)
	SetWidth(width int)
	SetHeight(height int)
	Render() string
}

HelpBarComponent interface for help bar

type HideHelpBarEvent added in v0.178.0

type HideHelpBarEvent struct{}

HideHelpBarEvent hides the help bar when typing other characters

type InputComponent

type InputComponent interface {
	GetInput() string
	ClearInput()
	SetPlaceholder(text string)
	GetCursor() int
	SetCursor(position int)
	SetText(text string)
	SetWidth(width int)
	SetHeight(height int)
	Render() string
	HandleKey(key tea.KeyPressMsg) (tea.Model, tea.Cmd)
	CanHandle(key tea.KeyPressMsg) bool
	NavigateHistoryUp()
	NavigateHistoryDown()
	IsNavigatingHistory() bool
	AddImageAttachment(image agentdomain.ImageAttachment)
	GetImageAttachments() []agentdomain.ImageAttachment
	ClearImageAttachments()
	AddToHistory(text string) error
	SetUsageHint(hint string)
	GetUsageHint() string
	IsDisabled() bool
}

InputComponent interface for input handling

type InputStatusBarComponent added in v0.76.2

type InputStatusBarComponent interface {
	SetWidth(width int)
	SetHeight(height int)
	SetInputText(text string)
	UpdateMCPStatus(status *MCPServerStatus)
	Focus() bool
	Blur()
	IsFocused() bool
	SelectNext()
	SelectPrev()
	SelectedAction() StatusIndicatorAction
	Render() string
}

InputStatusBarComponent interface for input status bar

type KeyShortcut added in v0.15.0

type KeyShortcut struct {
	Key         string
	Description string
}

KeyShortcut represents a keyboard shortcut with description

type MCPServerStatus added in v0.178.0

type MCPServerStatus struct {
	TotalServers     int `json:"total_servers"`
	ConnectedServers int `json:"connected_servers"`
	TotalTools       int `json:"total_tools"`
}

MCPServerStatus represents the status of MCP server connections

type MCPServerStatusUpdateEvent added in v0.178.0

type MCPServerStatusUpdateEvent struct {
	ServerName       string
	Connected        bool
	TotalServers     int
	ConnectedServers int
	TotalTools       int
	Tools            []agentdomain.MCPDiscoveredTool
}

MCPServerStatusUpdateEvent indicates MCP server status has changed

type MessageEditState added in v0.178.0

type MessageEditState struct {
	OriginalMessageIndex int `json:"original_message_index"`
}

MessageEditState represents the state when editing a message

type MessageHistoryEditEvent added in v0.178.0

type MessageHistoryEditEvent struct {
	RequestID       string
	Timestamp       time.Time
	MessageIndex    int
	MessageContent  string
	MessageSnapshot MessageSnapshot
}

MessageHistoryEditEvent is emitted when user wants to edit a selected message

func (MessageHistoryEditEvent) GetRequestID added in v0.178.0

func (e MessageHistoryEditEvent) GetRequestID() string

func (MessageHistoryEditEvent) GetTimestamp added in v0.178.0

func (e MessageHistoryEditEvent) GetTimestamp() time.Time

type MessageHistoryEditReadyEvent added in v0.178.0

type MessageHistoryEditReadyEvent struct {
	MessageIndex int
	Content      string
	Snapshot     MessageSnapshot
}

MessageHistoryEditReadyEvent indicates editing is ready to begin

type MessageHistoryReadyEvent added in v0.178.0

type MessageHistoryReadyEvent struct {
	Messages []MessageSnapshot
}

MessageHistoryReadyEvent indicates message history has been loaded and is ready to display

type MessageSnapshot added in v0.178.0

type MessageSnapshot struct {
	Index     int             `json:"index"`
	Role      sdk.MessageRole `json:"role"`
	Content   string          `json:"content"`
	Timestamp time.Time       `json:"timestamp"`
}

MessageSnapshot represents a snapshot of a message for the history view

type ModelSelectedEvent added in v0.178.0

type ModelSelectedEvent struct {
	Model string
}

ModelSelectedEvent indicates model selection

type PlanApprovalResponseEvent added in v0.178.0

type PlanApprovalResponseEvent struct {
	Action agentdomain.PlanApprovalAction
}

PlanApprovalResponseEvent captures the user's plan approval decision

type PlanApprovalSelectionChangedEvent added in v0.178.0

type PlanApprovalSelectionChangedEvent struct {
	NewIndex int
}

PlanApprovalSelectionChangedEvent signals that the plan-approval button selection has moved and the conversation viewport needs to re-render so the highlighted button reflects the new index.

type RestoreStatusStateEvent added in v0.178.0

type RestoreStatusStateEvent struct{}

RestoreStatusStateEvent restores a previously saved status state

type RolloverCompletedEvent added in v0.178.0

type RolloverCompletedEvent struct {
	Message sdk.Message
	Images  []agentdomain.ImageAttachment
}

RolloverCompletedEvent is dispatched when an asynchronous auto-rollover finishes in chat mode. It carries the already-built sdk.Message + images that were pending while the summary LLM call was in flight, so the post-rollover handler can resume the deferred AddMessage + start-chat completion flow without re-parsing user input.

type SaveStatusStateEvent added in v0.178.0

type SaveStatusStateEvent struct{}

SaveStatusStateEvent saves the current status state for later restoration

type ScrollDirection

type ScrollDirection int

ScrollDirection represents different scroll directions

const (
	ScrollUp ScrollDirection = iota
	ScrollDown
	ScrollLeft
	ScrollRight
	ScrollToTop
	ScrollToBottom
)

type ScrollRequestEvent added in v0.178.0

type ScrollRequestEvent struct {
	ComponentID string
	Direction   ScrollDirection
	Amount      int
}

ScrollRequestEvent requests scrolling in a component

type SetInputEvent added in v0.178.0

type SetInputEvent struct {
	Text string
}

SetInputEvent sets text in the input field

type SetStatusEvent added in v0.178.0

type SetStatusEvent struct {
	Message    string
	Spinner    bool
	StatusType StatusType
	Progress   *StatusProgress
	ToolName   string
}

SetStatusEvent sets a status message

type SetupFileSelectionEvent added in v0.178.0

type SetupFileSelectionEvent struct {
	Files []string
}

SetupFileSelectionEvent sets up file selection state with files

type ShowErrorEvent added in v0.178.0

type ShowErrorEvent struct {
	Error  string
	Sticky bool // Whether error persists until dismissed
}

ShowErrorEvent displays an error message

type StatusComponent

type StatusComponent interface {
	ShowStatus(message string)
	ShowError(message string)
	ShowSpinner(message string)
	ClearStatus()
	IsShowingError() bool
	IsShowingSpinner() bool
	SetWidth(width int)
	SetHeight(height int)
	Render() string
	SaveCurrentState()
	RestoreSavedState() tea.Cmd
	HasSavedState() bool
}

StatusComponent interface for status display

type StatusIndicatorAction added in v0.128.0

type StatusIndicatorAction int

StatusIndicatorAction identifies the view a status-bar indicator opens when activated; indicators without a view map to StatusIndicatorActionNone

const (
	StatusIndicatorActionNone StatusIndicatorAction = iota
	StatusIndicatorActionModelSelection
	StatusIndicatorActionTaskManagement
	StatusIndicatorActionThemeSelection
	StatusIndicatorActionToolsList
	StatusIndicatorActionA2AAgents
)

type StatusProgress added in v0.178.0

type StatusProgress struct {
	Current int
	Total   int
}

StatusProgress represents progress information for status messages

type StatusType added in v0.178.0

type StatusType int

StatusType represents different types of status messages

const (
	StatusDefault StatusType = iota
	StatusThinking
	StatusGenerating
	StatusWorking
	StatusProcessing
	StatusPreparing
	StatusError
)

type StreamingContentEvent added in v0.178.0

type StreamingContentEvent struct {
	RequestID        string
	Content          string
	ReasoningContent string
	Delta            bool
	Model            string
}

StreamingContentEvent delivers live streaming content for immediate UI display

type TaskCancelledEvent added in v0.178.0

type TaskCancelledEvent struct {
	TaskID string
	Error  error
}

TaskCancelledEvent indicates a task has been cancelled

type TasksLoadedEvent added in v0.178.0

type TasksLoadedEvent struct {
	ActiveTasks    []any
	CompletedTasks []any
	Error          error
}

TasksLoadedEvent indicates tasks have been loaded

type Theme

type Theme interface {
	GetUserColor() string
	GetAssistantColor() string
	GetErrorColor() string
	GetSuccessColor() string
	GetStatusColor() string
	GetAccentColor() string
	GetDimColor() string
	GetBorderColor() string
	GetDiffAddColor() string
	GetDiffRemoveColor() string
}

Theme interface for UI theming

type ThemeSelectedEvent added in v0.178.0

type ThemeSelectedEvent struct {
	Theme string
}

ThemeSelectedEvent indicates theme selection

type ThemeService added in v0.178.0

type ThemeService interface {
	ListThemes() []string
	GetCurrentTheme() Theme
	GetCurrentThemeName() string
	SetTheme(themeName string) error
}

ThemeService handles theme management

type TodoUpdateEvent added in v0.178.0

type TodoUpdateEvent struct {
	Todos []agentdomain.TodoItem
}

TodoUpdateEvent indicates the todo list has been updated

type ToggleHelpBarEvent added in v0.178.0

type ToggleHelpBarEvent struct{}

ToggleHelpBarEvent toggles the help bar visibility

type ToggleTodoBoxEvent added in v0.178.0

type ToggleTodoBoxEvent struct{}

ToggleTodoBoxEvent toggles the todo box expanded/collapsed state

type ToolExecutionCoordinator added in v0.178.0

type ToolExecutionCoordinator interface {
	GetActiveToolCallID() string
	SetActiveToolCallID(id string)

	HandleToolCallUpdate(msg agentdomain.ToolCallUpdateEvent) tea.Cmd
	HandleToolCallReady(msg agentdomain.ToolCallReadyEvent) tea.Cmd
	HandleToolApprovalRequested(msg agentdomain.ToolApprovalRequestedEvent) tea.Cmd
	HandleToolApprovalResponse(msg agentdomain.ToolApprovalResponseEvent) tea.Cmd
	HandleToolExecutionStarted(msg ToolExecutionStartedEvent) tea.Cmd
	HandleToolExecutionProgress(msg agentdomain.ToolExecutionProgressEvent) tea.Cmd
	HandleToolExecutionCompleted(msg agentdomain.ToolExecutionCompletedEvent) tea.Cmd
	HandleToolCancelled(msg agentdomain.ToolCancelledEvent) tea.Cmd
}

ToolExecutionCoordinator owns the tool round-trip: streaming-status updates emitted while the model is producing a tool call, approval coordination (forwarding the user's decision back to the agent), and execution-progress events while the tool runs. Also owns the active-tool-call indicator the UI uses to render the in-flight tool name.

type ToolExecutionStartedEvent added in v0.178.0

type ToolExecutionStartedEvent struct {
	SessionID  string
	TotalTools int
}

ToolExecutionStartedEvent indicates tool execution has started

type TriggerGithubActionSetupEvent added in v0.178.0

type TriggerGithubActionSetupEvent struct{}

TriggerGithubActionSetupEvent triggers the GitHub App setup flow

type TriggerHelpViewEvent added in v0.178.0

type TriggerHelpViewEvent struct{}

TriggerHelpViewEvent opens the full-screen, scrollable help overlay that lists every slash command and keybinding in two tables.

type UpdateHistoryEvent added in v0.178.0

type UpdateHistoryEvent struct {
	History []convdomain.ConversationEntry
}

UpdateHistoryEvent updates the conversation history display

type UpdateStatusEvent added in v0.178.0

type UpdateStatusEvent struct {
	Message    string
	StatusType StatusType
	ToolName   string
}

UpdateStatusEvent updates an existing status message without resetting timer

type VersionInfo added in v0.178.0

type VersionInfo struct {
	Version string
}

VersionInfo contains build-time version information

type ViewManager added in v0.178.0

type ViewManager interface {
	GetCurrentView() ViewState
	GetPreviousView() ViewState
	TransitionToView(newView ViewState) error
}

ViewManager handles view state transitions

type ViewState added in v0.178.0

type ViewState int

ViewState represents the current view with proper state management

const (
	ViewStateModelSelection ViewState = iota
	ViewStateChat
	ViewStateFileSelection
	ViewStateConversationSelection
	ViewStateThemeSelection
	ViewStateA2ATaskManagement
	ViewStatePlanApproval
	ViewStateGithubActionSetup
	ViewStateDiffViewer
	ViewStateExplorer
	ViewStateHelp
	ViewStateToolsList
	ViewStateA2AAgents
)

func (ViewState) String added in v0.178.0

func (v ViewState) String() string

Directories

Path Synopsis
diffview
Package diffview renders unified or side-by-side file diffs to a string of ANSI-styled output, using go-udiff for the underlying diff algorithm and chroma for in-line syntax highlighting.
Package diffview renders unified or side-by-side file diffs to a string of ANSI-styled output, using go-udiff for the underlying diff algorithm and chroma for in-line syntax highlighting.
Package inputsyntax highlights reserved tokens in the chat input field.
Package inputsyntax highlights reserved tokens in the chat input field.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL