tui

package
v0.223.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateInputHeight

func CalculateInputHeight(totalHeight int) int

Layout calculation utilities

func CalculateStatusHeight

func CalculateStatusHeight(totalHeight int) int

Types

type AgentReadinessState

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

type AgentStatus struct {
	Name        string               `json:"name"`
	URL         string               `json:"url"`
	Image       string               `json:"image"`
	State       a2adomain.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

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

AgentStatusUpdateEvent indicates an agent's status has changed

type ApplicationState

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

ApplicationState represents the overall application state with proper typing

func NewApplicationState

func NewApplicationState() *ApplicationState

NewApplicationState creates a new application state

func (*ApplicationState) AddQueuedMessage

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

AddQueuedMessage adds a message to the input queue

func (*ApplicationState) AreAllAgentsReady

func (s *ApplicationState) AreAllAgentsReady() bool

AreAllAgentsReady returns true if all agents are ready

func (*ApplicationState) ClearAgentReadiness

func (s *ApplicationState) ClearAgentReadiness()

ClearAgentReadiness clears the agent readiness state

func (*ApplicationState) ClearApprovalUIState

func (s *ApplicationState) ClearApprovalUIState()

ClearApprovalUIState clears the approval UI state

func (*ApplicationState) ClearComputerUsePauseState

func (s *ApplicationState) ClearComputerUsePauseState()

ClearComputerUsePauseState clears the pause state

func (*ApplicationState) ClearLastClickCoordinates

func (s *ApplicationState) ClearLastClickCoordinates()

ClearLastClickCoordinates clears the stored click coordinates

func (*ApplicationState) ClearLastFocusedApp

func (s *ApplicationState) ClearLastFocusedApp()

ClearLastFocusedApp clears the stored focused app

func (*ApplicationState) ClearMessageEditState

func (s *ApplicationState) ClearMessageEditState()

ClearMessageEditState clears the message edit state

func (*ApplicationState) ClearPlanApprovalUIState

func (s *ApplicationState) ClearPlanApprovalUIState()

ClearPlanApprovalUIState clears the plan approval UI state

func (*ApplicationState) ClearQueuedMessages

func (s *ApplicationState) ClearQueuedMessages()

ClearQueuedMessages clears all queued messages

func (*ApplicationState) ClearUserQuestionUIState

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

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

CompleteCurrentTool marks the current tool as completed and moves to next

func (*ApplicationState) CycleAgentMode

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

CycleAgentMode cycles to the next agent mode. The human shift+tab cycle is deliberately four-way (Standard -> Plan -> AutoAccept -> AutoWithJudge); 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

func (s *ApplicationState) EndChatSession()

EndChatSession cleans up the chat session

func (*ApplicationState) EndToolExecution

func (s *ApplicationState) EndToolExecution()

EndToolExecution cleans up the tool execution session

func (*ApplicationState) FailCurrentTool

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

FailCurrentTool marks the current tool as failed and moves to next

func (*ApplicationState) GetAgentMode

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

GetAgentMode returns the current agent mode

func (*ApplicationState) GetAgentReadiness

func (s *ApplicationState) GetAgentReadiness() *AgentReadinessState

GetAgentReadiness returns the current agent readiness state

func (*ApplicationState) GetApprovalUIState

func (s *ApplicationState) GetApprovalUIState() *ApprovalUIState

GetApprovalUIState returns the current approval UI state

func (*ApplicationState) GetChatSession

func (s *ApplicationState) GetChatSession() *ChatSession

GetChatSession returns the current chat session

func (*ApplicationState) GetCurrentView

func (s *ApplicationState) GetCurrentView() ViewState

GetCurrentView returns the current view state

func (*ApplicationState) GetDimensions

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

GetDimensions returns the current UI dimensions

func (*ApplicationState) GetLastClickCoordinates

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

GetLastClickCoordinates returns the coordinates of the last click

func (*ApplicationState) GetLastFocusedApp

func (s *ApplicationState) GetLastFocusedApp() string

GetLastFocusedApp returns the application ID of the last focused application

func (*ApplicationState) GetMessageEditState

func (s *ApplicationState) GetMessageEditState() *MessageEditState

GetMessageEditState returns the current message edit state

func (*ApplicationState) GetPausedRequestID

func (s *ApplicationState) GetPausedRequestID() string

GetPausedRequestID returns the request ID of the paused execution

func (*ApplicationState) GetPlanApprovalUIState

func (s *ApplicationState) GetPlanApprovalUIState() *PlanApprovalUIState

GetPlanApprovalUIState returns the current plan approval UI state

func (*ApplicationState) GetPreviousView

func (s *ApplicationState) GetPreviousView() ViewState

GetPreviousView returns the previous view state

func (*ApplicationState) GetQueuedMessages

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

GetQueuedMessages returns the current queued messages

func (*ApplicationState) GetRetryStatus

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

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

GetTodos returns the current todo list

func (*ApplicationState) GetToolExecution

func (s *ApplicationState) GetToolExecution() *ToolExecutionSession

GetToolExecution returns the current tool execution session

func (*ApplicationState) GetUserQuestionUIState

func (s *ApplicationState) GetUserQuestionUIState() *UserQuestionUIState

GetUserQuestionUIState returns the current AskUserQuestion form state, or nil.

func (*ApplicationState) InitializeAgentReadiness

func (s *ApplicationState) InitializeAgentReadiness(totalAgents int)

InitializeAgentReadiness initializes the agent readiness tracking

func (*ApplicationState) IsComputerUsePaused

func (s *ApplicationState) IsComputerUsePaused() bool

IsComputerUsePaused returns whether computer use is currently paused

func (*ApplicationState) IsDebugMode

func (s *ApplicationState) IsDebugMode() bool

IsDebugMode returns whether debug mode is enabled

func (*ApplicationState) IsEditingMessage

func (s *ApplicationState) IsEditingMessage() bool

IsEditingMessage returns true if currently editing a message

func (*ApplicationState) PopQueuedMessage

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

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

func (*ApplicationState) RemoveAgent

func (s *ApplicationState) RemoveAgent(name string)

RemoveAgent removes an agent from the readiness tracking

func (*ApplicationState) SetAgentError

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

SetAgentError sets an error for a specific agent

func (*ApplicationState) SetAgentMode

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

SetAgentMode sets the agent mode

func (*ApplicationState) SetChatPending

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

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

SetComputerUsePaused sets the paused state for computer use

func (*ApplicationState) SetDebugMode

func (s *ApplicationState) SetDebugMode(enabled bool)

SetDebugMode enables or disables debug mode

func (*ApplicationState) SetDimensions

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

SetDimensions updates the UI dimensions

func (*ApplicationState) SetLastClickCoordinates

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

SetLastClickCoordinates stores the coordinates of the last click

func (*ApplicationState) SetLastFocusedApp

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

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

SetMessageEditState sets the message edit state

func (*ApplicationState) SetPlanApprovalSelectedIndex

func (s *ApplicationState) SetPlanApprovalSelectedIndex(index int)

SetPlanApprovalSelectedIndex sets the plan approval selection index

func (*ApplicationState) SetRetryStatus

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

SetRetryStatus updates the retry status on the current chat session

func (*ApplicationState) SetTodos

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

SetTodos sets the todo list

func (*ApplicationState) SetupApprovalUIState

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

SetupApprovalUIState initializes approval UI state with the pending tool call

func (*ApplicationState) SetupPlanApprovalUIState

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

SetupPlanApprovalUIState initializes plan approval UI state

func (*ApplicationState) SetupUserQuestionUIState

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

SetupUserQuestionUIState initializes the AskUserQuestion form state for the given questions.

func (*ApplicationState) StartChatSession

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

StartChatSession initializes a new chat session

func (*ApplicationState) StartToolExecution

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

StartToolExecution initializes a new tool execution session

func (*ApplicationState) TouchChatActivity

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

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

TransitionToView changes the current view with validation

func (*ApplicationState) UpdateAgentPullProgress

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

UpdateAgentPullProgress updates the image pull layer counts for a specific agent

func (*ApplicationState) UpdateAgentStatus

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

UpdateAgentStatus updates the status of a specific agent

func (*ApplicationState) UpdateChatStatus

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

UpdateChatStatus updates the chat session status

type ApprovalCoordinator

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 ApprovalPrompt added in v0.207.0

type ApprovalPrompt interface {
	SetupApprovalUIState(toolCall *sdk.ChatCompletionMessageToolCall, responseChan chan agentdomain.ApprovalAction)
	GetApprovalUIState() *ApprovalUIState
	ClearApprovalUIState()
}

ApprovalPrompt handles tool approval UI state

type ApprovalUIState added in v0.207.0

type ApprovalUIState struct {
	PendingToolCall *sdk.ChatCompletionMessageToolCall `json:"pending_tool_call"`
	Context         string                             `json:"context,omitempty"`
	ResponseChan    chan agentdomain.ApprovalAction    `json:"-"`
}

ApprovalUIState represents the state of approval UI

type AutocompleteCompleteEvent

type AutocompleteCompleteEvent struct {
	Completion string
	CursorPos  int
	Submit     bool
}

AutocompleteCompleteEvent is fired when a completion is selected

type AutocompleteComponent

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

type AutocompleteHideEvent struct{}

AutocompleteHideEvent is fired when autocomplete should be hidden

type AutocompleteUpdateEvent

type AutocompleteUpdateEvent struct {
	Text      string
	CursorPos int
}

AutocompleteUpdateEvent is fired when input text changes and autocomplete should update

type BackgroundShellRequestEvent added in v0.207.0

type BackgroundShellRequestEvent struct{}

BackgroundShellRequestEvent requests that the current running Bash command be moved to background

type BashCommandCompletedEvent

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

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

type ChatChannelEvent added in v0.188.0

type ChatChannelEvent struct {
	Event  agentdomain.ChatEvent
	Source <-chan agentdomain.ChatEvent
}

ChatChannelEvent is what ListenForChatEvents yields: the event plus the channel it was read from. ChatHandler.Handle unwraps it and re-arms the listener on Source exactly once, so no handler re-arms by hand and a new event type needs no registration to keep the chain alive.

type ChatCompletionRequestedEvent added in v0.203.0

type ChatCompletionRequestedEvent struct {
	Session *ChatSession
}

ChatCompletionRequestedEvent resumes chat after asynchronous preparation.

type ChatCompletionRunner

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 restoring the model after a temporary /model switch. Start takes a BashDetachChannelHolder: the narrow interface the agent core needs on its context when launching tools that may require backgrounding.

type ChatEventListener

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

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
	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 ChatSession added in v0.207.0

type ChatSession struct {
	RequestID    string
	Status       ChatStatus
	StartTime    time.Time
	Model        string
	EventChannel <-chan agentdomain.ChatEvent
	IsFirstChunk bool
	HasToolCalls bool
	LastActivity time.Time
	RetryStatus  *agentdomain.RetryStatus
}

ChatSession represents an active chat session state

type ChatSessionState added in v0.207.0

type ChatSessionState interface {
	SetChatPending()
	StartChatSession(requestID, model string, eventChan <-chan agentdomain.ChatEvent) error
	UpdateChatStatus(status ChatStatus) error
	EndChatSession()
	GetChatSession() *ChatSession
	IsAgentBusy() bool
	SetRetryStatus(status *agentdomain.RetryStatus)
	GetRetryStatus() *agentdomain.RetryStatus
	TouchChatActivity()
}

ChatSessionState handles chat session lifecycle

type ChatStatus added in v0.207.0

type ChatStatus int

ChatStatus represents the current chat operation status

const (
	ChatStatusIdle ChatStatus = iota
	ChatStatusStarting
	ChatStatusThinking
	ChatStatusGenerating
	ChatStatusReceivingTools
	ChatStatusWaitingTools
	ChatStatusCompleted
	ChatStatusError
	ChatStatusCancelled
)

func (ChatStatus) String added in v0.207.0

func (c ChatStatus) String() string

type ChatStreamOpenedEvent added in v0.203.0

type ChatStreamOpenedEvent struct {
	Session   *ChatSession
	RequestID string
	Model     string
	Events    <-chan agentdomain.ChatEvent
	Err       error
}

ChatStreamOpenedEvent returns stream startup to Update, which owns session initialization. Session identifies the originating turn for cancellation.

type ClearErrorEvent

type ClearErrorEvent struct{}

ClearErrorEvent clears any displayed error

type ClearInputEvent

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

type ConversationSelectedEvent struct {
	ConversationID string
}

ConversationSelectedEvent indicates conversation selection

type ConversationsLoadedEvent

type ConversationsLoadedEvent struct {
	Conversations []any
	Error         error
}

ConversationsLoadedEvent indicates conversations have been loaded

type DebugKeyEvent

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

func (t *DefaultTheme) GetDiffAddColor() string

func (*DefaultTheme) GetDiffRemoveColor

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

func (t *DefaultTheme) GetSuccessColor() string

func (*DefaultTheme) GetUserColor

func (t *DefaultTheme) GetUserColor() string

func (*DefaultTheme) GetWarningColor added in v0.182.0

func (t *DefaultTheme) GetWarningColor() string

type DirectExecutionService

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

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 EventBridgeHolder added in v0.207.0

type EventBridgeHolder interface {
	SetEventBridge(bridge agentdomain.EventBridge)
	GetEventBridge() agentdomain.EventBridge
	BroadcastEvent(event agentdomain.ChatEvent)
}

EventBridgeHolder handles event multicast for external event consumers

type FocusStatusBarEvent

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

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 GitStatusResolvedEvent added in v0.188.0

type GitStatusResolvedEvent struct {
	Dirty    bool
	Unpushed bool
}

GitStatusResolvedEvent carries the workspace state for the branch icon, resolved asynchronously by the input view's fetch command. Dirty means the tree has uncommitted changes; Unpushed means local commits are ahead of the upstream (or there is no upstream). The zero value means clean or not a repo.

type HeartbeatEvent added in v0.207.0

type HeartbeatEvent struct {
	At time.Time
}

HeartbeatEvent is the app's single periodic tick, pushed through the UI notifier by one background goroutine (cmd/chat) at a fixed slow interval. It exists so freshness checks that cannot be event-driven (state changed outside the TUI, e.g. git status after an editor save) have one clock to ride instead of each re-arming its own tea.Tick. Handlers must stay cheap: kick off a tea.Cmd for any I/O, never do it inline. Consumers that want a slower cadence compare At against their own last-run time.

type HelpBarComponent

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

type HideHelpBarEvent struct{}

HideHelpBarEvent hides the help bar when typing other characters

type HistorySearchOpenEvent added in v0.219.0

type HistorySearchOpenEvent struct{}

HistorySearchOpenEvent opens the fuzzy prompt-history search overlay above the chat input

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

type InputStatusBarComponent interface {
	SetWidth(width int)
	SetHeight(height int)
	SetInputText(text string)
	UpdateMCPStatus(status *mcpdomain.ServerStatus)
	SetBrowserConnected(connected bool)
	SetScreenRecording(active bool)
	Focus() bool
	Blur()
	IsFocused() bool
	SelectNext()
	SelectPrev()
	SelectedAction() StatusIndicatorAction
	Render() string
}

InputStatusBarComponent interface for input status bar

type KeyShortcut

type KeyShortcut struct {
	Key         string
	Description string
}

KeyShortcut represents a keyboard shortcut with description

type MessageEditState

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

MessageEditState represents the state when editing a message

type MessageEditSubmitEvent added in v0.207.0

type MessageEditSubmitEvent struct {
	RequestID     string
	Timestamp     time.Time
	OriginalIndex int
	EditedContent string
	Images        []agentdomain.ImageAttachment
}

MessageEditSubmitEvent is emitted when edited message is submitted

func (MessageEditSubmitEvent) GetRequestID added in v0.207.0

func (e MessageEditSubmitEvent) GetRequestID() string

func (MessageEditSubmitEvent) GetTimestamp added in v0.207.0

func (e MessageEditSubmitEvent) GetTimestamp() time.Time

type MessageHistoryEditEvent

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

func (e MessageHistoryEditEvent) GetRequestID() string

func (MessageHistoryEditEvent) GetTimestamp

func (e MessageHistoryEditEvent) GetTimestamp() time.Time

type MessageHistoryEditReadyEvent

type MessageHistoryEditReadyEvent struct {
	MessageIndex int
	Content      string
	Snapshot     MessageSnapshot
}

MessageHistoryEditReadyEvent indicates editing is ready to begin

type MessageHistoryReadyEvent

type MessageHistoryReadyEvent struct {
	Messages []MessageSnapshot
}

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

type MessageHistoryRestoreEvent added in v0.207.0

type MessageHistoryRestoreEvent struct {
	RequestID      string
	Timestamp      time.Time
	RestoreToIndex int
}

MessageHistoryRestoreEvent is emitted when user selects a restore point in message history

func (MessageHistoryRestoreEvent) GetRequestID added in v0.207.0

func (e MessageHistoryRestoreEvent) GetRequestID() string

func (MessageHistoryRestoreEvent) GetTimestamp added in v0.207.0

func (e MessageHistoryRestoreEvent) GetTimestamp() time.Time

type MessageSnapshot

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 NavigateBackInTimeEvent struct {
	RequestID string
	Timestamp time.Time
}

NavigateBackInTimeEvent triggers the message history selector view

func (e NavigateBackInTimeEvent) GetRequestID() string
func (e NavigateBackInTimeEvent) GetTimestamp() time.Time

type PlanApprovalPrompt added in v0.207.0

type PlanApprovalPrompt interface {
	SetupPlanApprovalUIState(planContent, planID string, responseChan chan agentdomain.PlanApprovalAction)
	GetPlanApprovalUIState() *PlanApprovalUIState
	SetPlanApprovalSelectedIndex(index int)
	ClearPlanApprovalUIState()
}

PlanApprovalPrompt handles plan approval UI state

type PlanApprovalResponseEvent

type PlanApprovalResponseEvent struct {
	Action agentdomain.PlanApprovalAction
}

PlanApprovalResponseEvent captures the user's plan approval decision

type PlanApprovalSelectionChangedEvent

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 PlanApprovalUIState added in v0.207.0

type PlanApprovalUIState struct {
	SelectedIndex int                                 `json:"selected_index"`
	PlanContent   string                              `json:"plan_content"`
	PlanID        string                              `json:"plan_id"`
	ResponseChan  chan agentdomain.PlanApprovalAction `json:"-"`
}

PlanApprovalUIState represents the state of plan approval UI

type RefreshAutocompleteEvent added in v0.207.0

type RefreshAutocompleteEvent struct{}

RefreshAutocompleteEvent is sent when autocomplete needs to refresh (e.g., after mode change)

type RestoreStatusStateEvent

type RestoreStatusStateEvent struct{}

RestoreStatusStateEvent restores a previously saved status state

type RolloverCompletedEvent

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

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

type ScrollRequestEvent struct {
	ComponentID string
	Direction   ScrollDirection
	Amount      int
}

ScrollRequestEvent requests scrolling in a component

type SetInputEvent

type SetInputEvent struct {
	Text string
}

SetInputEvent sets text in the input field

type SetStatusEvent

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

SetStatusEvent sets a status message

type ShowErrorEvent

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

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
	StatusIndicatorActionThemeSelection
	StatusIndicatorActionToolsList
	StatusIndicatorActionA2AAgents
)

type StatusProgress

type StatusProgress struct {
	Current int
	Total   int
}

StatusProgress represents progress information for status messages

type StatusType

type StatusType int

StatusType represents different types of status messages

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

type StreamingContentEvent

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

StreamingContentEvent delivers live streaming content for immediate UI display

type TaskCancelledEvent

type TaskCancelledEvent struct {
	TaskID string
	Error  error
}

TaskCancelledEvent indicates a task has been cancelled

type TasksLoadedEvent

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
	GetWarningColor() string
	GetStatusColor() string
	GetAccentColor() string
	GetDimColor() string
	GetBorderColor() string
	GetDiffAddColor() string
	GetDiffRemoveColor() string
}

Theme interface for UI theming

type ThemeSelectedEvent

type ThemeSelectedEvent struct {
	Theme string
}

ThemeSelectedEvent indicates theme selection

type ThemeService

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

ThemeService handles theme management

type TodoUpdateEvent

type TodoUpdateEvent struct {
	Todos []agentdomain.TodoItem
}

TodoUpdateEvent indicates the todo list has been updated

type ToggleHelpBarEvent

type ToggleHelpBarEvent struct{}

ToggleHelpBarEvent toggles the help bar visibility

type ToggleTodoBoxEvent

type ToggleTodoBoxEvent struct{}

ToggleTodoBoxEvent toggles the todo box expanded/collapsed state

type ToolApprovalNotificationEvent added in v0.207.0

type ToolApprovalNotificationEvent struct {
	RequestID string
	Timestamp time.Time
	ToolName  string
	Message   string
}

ToolApprovalNotificationEvent is sent to notify the Computer Use dialog when tool approval is required in TUI

func (ToolApprovalNotificationEvent) GetRequestID added in v0.207.0

func (e ToolApprovalNotificationEvent) GetRequestID() string

func (ToolApprovalNotificationEvent) GetTimestamp added in v0.207.0

func (e ToolApprovalNotificationEvent) GetTimestamp() time.Time

type ToolCall added in v0.207.0

type ToolCall struct {
	ID        string                           `json:"id"`
	Name      string                           `json:"name"`
	Arguments map[string]any                   `json:"arguments"`
	Status    ToolCallStatus                   `json:"status"`
	Result    *agentdomain.ToolExecutionResult `json:"result,omitempty"`
	StartTime time.Time                        `json:"start_time"`
	EndTime   *time.Time                       `json:"end_time,omitempty"`
}

ToolCall represents a tool call with proper typing

type ToolCallPreviewEvent added in v0.207.0

type ToolCallPreviewEvent struct {
	RequestID  string
	Timestamp  time.Time
	ToolCallID string
	ToolName   string
	Arguments  string
	Status     ToolCallStreamStatus
	IsComplete bool
}

ToolCallPreviewEvent shows a tool call as it's being streamed (before execution)

func (ToolCallPreviewEvent) GetRequestID added in v0.207.0

func (e ToolCallPreviewEvent) GetRequestID() string

func (ToolCallPreviewEvent) GetTimestamp added in v0.207.0

func (e ToolCallPreviewEvent) GetTimestamp() time.Time

type ToolCallStatus added in v0.207.0

type ToolCallStatus int

ToolCallStatus represents the status of an individual tool call

const (
	ToolCallStatusPending ToolCallStatus = iota
	ToolCallStatusWaitingApproval
	ToolCallStatusExecuting
	ToolCallStatusCompleted
	ToolCallStatusFailed
	ToolCallStatusCancelled
	ToolCallStatusDenied
)

func (ToolCallStatus) String added in v0.207.0

func (t ToolCallStatus) String() string

type ToolCallStreamStatus added in v0.207.0

type ToolCallStreamStatus string

ToolCallStreamStatus represents the status of a tool call during streaming

const (
	ToolCallStreamStatusStreaming ToolCallStreamStatus = "streaming"
	ToolCallStreamStatusComplete  ToolCallStreamStatus = "completed"
	ToolCallStreamStatusReady     ToolCallStreamStatus = "ready"
)

type ToolExecutionCoordinator

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

	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 ToolExecutionSession added in v0.207.0

type ToolExecutionSession struct {
	CurrentTool    *ToolCall
	RemainingTools []ToolCall
	TotalTools     int
	CompletedTools int
	Status         ToolExecutionStatus
	StartTime      time.Time
}

ToolExecutionSession represents an active tool execution session

type ToolExecutionStartedEvent

type ToolExecutionStartedEvent struct {
	SessionID  string
	TotalTools int
}

ToolExecutionStartedEvent indicates tool execution has started

type ToolExecutionState added in v0.207.0

type ToolExecutionState interface {
	StartToolExecution(toolCalls []sdk.ChatCompletionMessageToolCall) error
	CompleteCurrentTool(result *agentdomain.ToolExecutionResult) error
	FailCurrentTool(result *agentdomain.ToolExecutionResult) error
	EndToolExecution()
	GetToolExecution() *ToolExecutionSession
}

ToolExecutionState handles tool execution sessions

type ToolExecutionStatus added in v0.207.0

type ToolExecutionStatus int

ToolExecutionStatus represents the overall tool execution session status

const (
	ToolExecutionStatusIdle ToolExecutionStatus = iota
	ToolExecutionStatusProcessing
	ToolExecutionStatusExecuting
	ToolExecutionStatusCompleted
	ToolExecutionStatusFailed
)

func (ToolExecutionStatus) String added in v0.207.0

func (t ToolExecutionStatus) String() string

type ToolFormatter added in v0.207.0

type ToolFormatter interface {
	// FormatToolCall formats a tool call for consistent display
	FormatToolCall(toolName string, args map[string]any) string

	// RenderToolSummary renders the shared "<icon> Name(args) <trailing>" line used by
	// the collapsed status line, live preview, approval summary and queue preview.
	RenderToolSummary(icon, toolName string, args map[string]any, trailing string, terminalWidth int) string

	// FormatToolResultForUI formats tool execution results for UI display
	FormatToolResultForUI(result *agentdomain.ToolExecutionResult, terminalWidth int) string

	// FormatToolResultExpanded formats expanded tool execution results
	FormatToolResultExpanded(result *agentdomain.ToolExecutionResult, terminalWidth int) string

	// FormatToolResultForLLM formats tool execution results for LLM consumption
	FormatToolResultForLLM(result *agentdomain.ToolExecutionResult) string

	// ShouldAlwaysExpandTool checks if a tool result should always be expanded
	ShouldAlwaysExpandTool(toolName string) bool
}

ToolFormatter provides formatting capabilities for tool results

type TriggerHelpViewEvent

type TriggerHelpViewEvent struct{}

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

type TriggerOpentaskSetupEvent added in v0.182.0

type TriggerOpentaskSetupEvent struct{}

TriggerOpentaskSetupEvent triggers the GitHub App setup flow

type UpdateHistoryEvent

type UpdateHistoryEvent struct {
	History []convdomain.ConversationEntry
}

UpdateHistoryEvent updates the conversation history display

type UpdateStatusEvent

type UpdateStatusEvent struct {
	Message    string
	StatusType StatusType
	ToolName   string
}

UpdateStatusEvent updates an existing status message without resetting timer

type UserQuestionPrompt added in v0.207.0

type UserQuestionPrompt interface {
	SetupUserQuestionUIState(questions []agentdomain.UserQuestion, responseChan chan []agentdomain.UserQuestionAnswer)
	GetUserQuestionUIState() *UserQuestionUIState
	ClearUserQuestionUIState()
}

UserQuestionPrompt handles AskUserQuestion form state

type UserQuestionUIState added in v0.207.0

type UserQuestionUIState struct {
	Questions    []agentdomain.UserQuestion            `json:"questions"`
	ResponseChan chan []agentdomain.UserQuestionAnswer `json:"-"`
}

UserQuestionUIState drives the interactive AskUserQuestion form. The agent loop is blocked in the tool goroutine while the form is up; the answer-in-progress state lives in the QuestionFormView's huh form. ResponseChan delivers the final answers slice back to the blocked tool; closing it without a send signals cancellation.

type VersionInfo

type VersionInfo struct {
	Version        string
	GatewayVersion string
}

VersionInfo contains build-time version information plus the detected version of the gateway serving this session (empty when unknown).

type ViewNavigator added in v0.207.0

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

ViewNavigator handles view state transitions

type ViewState

type ViewState int

ViewState represents the current view with proper state management

const (
	ViewStateModelSelection ViewState = iota
	ViewStateChat
	ViewStateConversationSelection
	ViewStateThemeSelection
	ViewStateA2ATaskManagement
	ViewStatePlanApproval
	ViewStateOpentaskSetup
	ViewStateDiffViewer
	ViewStateExplorer
	ViewStateHelp
	ViewStateToolsList
	ViewStateAgents
)

func (ViewState) String

func (v ViewState) String() string

Jump to

Keyboard shortcuts

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