handlers

package
v0.146.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatHandler added in v0.27.0

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

func NewChatHandler added in v0.27.0

func NewChatHandler(
	agentService domain.AgentService,
	conversationRepo domain.ConversationRepository,
	conversationOptimizer domain.ConversationOptimizer,
	sessionRolloverManager *services.SessionRolloverManager,
	modelService domain.ModelService,
	toolService domain.ToolService,
	fileService domain.FileService,
	imageService domain.ImageService,
	skillsService domain.SkillsService,
	githubIssueService domain.GitHubIssueService,
	shortcutRegistry *shortcuts.Registry,
	stateManager stateManager,
	messageQueue domain.MessageQueue,
	taskRetentionService domain.TaskRetentionService,
	backgroundTaskService domain.BackgroundTaskService,
	backgroundShellService domain.BackgroundShellService,
	agentManager domain.AgentManager,
	cfg *config.Config,
	a2aTaskCoordinator domain.A2ATaskCoordinator,
	approvalCoordinator domain.ApprovalCoordinator,
	completionRunner domain.ChatCompletionRunner,
	directExec domain.DirectExecutionService,
	toolCoordinator domain.ToolExecutionCoordinator,
) *ChatHandler

func (*ChatHandler) ClearBashDetachChan added in v0.81.0

func (h *ChatHandler) ClearBashDetachChan()

ClearBashDetachChan satisfies the legacy domain.ChatHandler interface by forwarding to DirectExecutionService.

func (*ChatHandler) ExtractMarkdownSummary added in v0.45.4

func (h *ChatHandler) ExtractMarkdownSummary(content string) (string, bool)

ExtractMarkdownSummary delegates to ChatMessageProcessor.

func (*ChatHandler) FormatMetrics added in v0.45.4

func (h *ChatHandler) FormatMetrics(metrics *domain.ChatMetrics) string

FormatMetrics formats LLM completion metrics for the status bar, computing the request wall-clock time from the most recent user message.

func (*ChatHandler) GetActiveToolCallID added in v0.97.0

func (h *ChatHandler) GetActiveToolCallID() string

GetActiveToolCallID satisfies the legacy domain.ChatHandler interface by forwarding to ToolExecutionCoordinator (the actual owner post-#529).

func (*ChatHandler) GetBashDetachChan added in v0.81.0

func (h *ChatHandler) GetBashDetachChan() chan<- struct{}

GetBashDetachChan satisfies the legacy domain.ChatHandler interface by forwarding to DirectExecutionService.

func (*ChatHandler) Handle added in v0.27.0

func (h *ChatHandler) Handle(msg tea.Msg) tea.Cmd

Handle routes incoming messages to appropriate handler methods based on message type. TODO - refactor this

func (*ChatHandler) HandleA2ATaskCompletedEvent added in v0.53.0

func (h *ChatHandler) HandleA2ATaskCompletedEvent(
	msg domain.A2ATaskCompletedEvent,
) tea.Cmd

func (*ChatHandler) HandleA2ATaskFailedEvent added in v0.53.0

func (h *ChatHandler) HandleA2ATaskFailedEvent(
	msg domain.A2ATaskFailedEvent,
) tea.Cmd

func (*ChatHandler) HandleA2ATaskInputRequiredEvent added in v0.53.0

func (h *ChatHandler) HandleA2ATaskInputRequiredEvent(
	msg domain.A2ATaskInputRequiredEvent,
) tea.Cmd

func (*ChatHandler) HandleA2ATaskStatusUpdateEvent added in v0.53.0

func (h *ChatHandler) HandleA2ATaskStatusUpdateEvent(
	msg domain.A2ATaskStatusUpdateEvent,
) tea.Cmd

func (*ChatHandler) HandleA2ATaskSubmittedEvent added in v0.53.0

func (h *ChatHandler) HandleA2ATaskSubmittedEvent(
	msg domain.A2ATaskSubmittedEvent,
) tea.Cmd

func (*ChatHandler) HandleA2AToolCallExecutedEvent added in v0.53.0

func (h *ChatHandler) HandleA2AToolCallExecutedEvent(
	msg domain.A2AToolCallExecutedEvent,
) tea.Cmd

func (*ChatHandler) HandleAgentStatusUpdateEvent added in v0.67.0

func (h *ChatHandler) HandleAgentStatusUpdateEvent(_ domain.AgentStatusUpdateEvent) tea.Cmd

HandleAgentStatusUpdateEvent refreshes the agent indicator. The StateManager was already updated by the container's status callback before this event was pushed, so simply receiving it re-renders the indicator. There is no polling: the callback pushes a fresh event on every real status change and stops when the agents stop changing.

func (*ChatHandler) HandleBackgroundShellRequest added in v0.97.0

func (h *ChatHandler) HandleBackgroundShellRequest() tea.Cmd

HandleBackgroundShellRequest signals the currently-running bash command to detach to the background. Delegates to DirectExecutionService.

func (*ChatHandler) HandleBashCommand added in v0.97.0

func (h *ChatHandler) HandleBashCommand(commandText string) tea.Cmd

HandleBashCommand processes bash commands starting with !. Delegates to DirectExecutionService.

func (*ChatHandler) HandleBashCommandCompletedEvent added in v0.68.0

func (h *ChatHandler) HandleBashCommandCompletedEvent(
	msg domain.BashCommandCompletedEvent,
) tea.Cmd

func (*ChatHandler) HandleBashOutputChunkEvent added in v0.65.0

func (h *ChatHandler) HandleBashOutputChunkEvent(
	msg domain.BashOutputChunkEvent,
) tea.Cmd

func (*ChatHandler) HandleChatChunkEvent added in v0.53.0

func (h *ChatHandler) HandleChatChunkEvent(
	msg domain.ChatChunkEvent,
) tea.Cmd

func (*ChatHandler) HandleChatCompleteEvent added in v0.53.0

func (h *ChatHandler) HandleChatCompleteEvent(
	msg domain.ChatCompleteEvent,
) tea.Cmd

func (*ChatHandler) HandleChatErrorEvent added in v0.53.0

func (h *ChatHandler) HandleChatErrorEvent(
	msg domain.ChatErrorEvent,
) tea.Cmd

func (*ChatHandler) HandleChatStartEvent added in v0.53.0

func (h *ChatHandler) HandleChatStartEvent(
	msg domain.ChatStartEvent,
) tea.Cmd

func (*ChatHandler) HandleCommand added in v0.97.0

func (h *ChatHandler) HandleCommand(commandText string) tea.Cmd

HandleCommand parses a /shortcut and delegates to the registered handler.

func (*ChatHandler) HandleComputerUsePausedEvent added in v0.96.0

func (h *ChatHandler) HandleComputerUsePausedEvent(msg domain.ComputerUsePausedEvent) tea.Cmd

HandleComputerUsePausedEvent handles computer use pause events

func (*ChatHandler) HandleComputerUseResumedEvent added in v0.96.0

func (h *ChatHandler) HandleComputerUseResumedEvent(msg domain.ComputerUseResumedEvent) tea.Cmd

HandleComputerUseResumedEvent handles computer use resume events

func (*ChatHandler) HandleConversationSelectedEvent added in v0.53.0

func (h *ChatHandler) HandleConversationSelectedEvent(
	msg domain.ConversationSelectedEvent,
) tea.Cmd

func (*ChatHandler) HandleDrainQueueEvent added in v0.126.0

func (h *ChatHandler) HandleDrainQueueEvent(_ domain.DrainQueueEvent) tea.Cmd

HandleDrainQueueEvent gates draining queued work into a fresh agent turn. When the chat view is active and the agent is idle, it marks the session pending and starts a turn whose CheckingQueue state drains the queue.

When work is stranded (chat view, non-empty queue) it also arms a single bounded retry. A background job can finish at the exact instant the agent is still finishing its own turn; the supervisor's one-shot DrainQueueEvent would then be gate-dropped and, without a retry, the queue would be stranded forever (the old always-on ticker's repetition was the de-facto retry). armDrainRetry restores that robustness without an idle clock AND without multiplying timers: the drainRetryArmed guard keeps exactly one retry chain no matter how many DrainQueueEvents arrive, and the chain stops the moment the queue drains (so it never fires when idle on chat or off-chat - no /model flicker regression).

SetChatPending() marks the session busy synchronously (StartChatSession only runs later inside the async Cmd), so the retry sees "busy" and cannot double-start. The Bubble Tea Update loop is single-threaded, so this check-then-mark is race-free.

func (*ChatHandler) HandleDrainQueueRetryEvent added in v0.126.0

func (h *ChatHandler) HandleDrainQueueRetryEvent(_ domain.DrainQueueRetryEvent) tea.Cmd

HandleDrainQueueRetryEvent fires when the bounded retry tick elapses. It clears the armed flag (this timer is spent) and re-runs the drain gate, which re-arms a single fresh timer iff work is still stranded. A dedicated event type - rather than re-emitting DrainQueueEvent - is what lets the guard distinguish "the retry fired" from "a fresh external push", so exactly one retry chain stays alive regardless of how many DrainQueueEvents were pushed.

func (*ChatHandler) HandleFileSelectionRequestEvent added in v0.53.0

func (h *ChatHandler) HandleFileSelectionRequestEvent(
	msg domain.FileSelectionRequestEvent,
) tea.Cmd

func (*ChatHandler) HandleMessageQueuedEvent added in v0.53.0

func (h *ChatHandler) HandleMessageQueuedEvent(
	_ domain.MessageQueuedEvent,
) tea.Cmd

func (*ChatHandler) HandleOptimizationStatusEvent added in v0.53.0

func (h *ChatHandler) HandleOptimizationStatusEvent(
	msg domain.OptimizationStatusEvent,
) tea.Cmd

func (*ChatHandler) HandlePlanApprovalRequestedEvent added in v0.68.0

func (h *ChatHandler) HandlePlanApprovalRequestedEvent(
	msg domain.PlanApprovalRequestedEvent,
) tea.Cmd

func (*ChatHandler) HandlePlanApprovalResponseEvent added in v0.68.0

func (h *ChatHandler) HandlePlanApprovalResponseEvent(
	msg domain.PlanApprovalResponseEvent,
) tea.Cmd

func (*ChatHandler) HandleRolloverCompletedEvent added in v0.114.0

func (h *ChatHandler) HandleRolloverCompletedEvent(
	msg domain.RolloverCompletedEvent,
) tea.Cmd

HandleRolloverCompletedEvent resumes the deferred work after the async rollover (kicked off by ChatMessageProcessor.compactThenContinue) finishes.

func (*ChatHandler) HandleSubagentCompletedEvent added in v0.124.0

func (h *ChatHandler) HandleSubagentCompletedEvent(_ domain.SubagentCompletedEvent) tea.Cmd

func (*ChatHandler) HandleSubagentFailedEvent added in v0.124.0

func (h *ChatHandler) HandleSubagentFailedEvent(_ domain.SubagentFailedEvent) tea.Cmd

func (*ChatHandler) HandleSubagentSubmittedEvent added in v0.124.0

func (h *ChatHandler) HandleSubagentSubmittedEvent(_ domain.SubagentSubmittedEvent) tea.Cmd

Subagent lifecycle events drive the live tree in the conversation view (see ConversationView.renderSubagentTree). The handler here only needs to keep the chat event listener pumping, since these events arrive on the chat event channel and the conversation view consumes them for rendering.

func (*ChatHandler) HandleTodoUpdateChatEvent added in v0.63.1

func (h *ChatHandler) HandleTodoUpdateChatEvent(
	msg domain.TodoUpdateChatEvent,
) tea.Cmd

HandleTodoUpdateChatEvent converts the chat event to a UI event for the todo component

func (*ChatHandler) HandleToolApprovalRequestedEvent added in v0.56.0

func (h *ChatHandler) HandleToolApprovalRequestedEvent(
	msg domain.ToolApprovalRequestedEvent,
) tea.Cmd

func (*ChatHandler) HandleToolApprovalResponseEvent added in v0.56.0

func (h *ChatHandler) HandleToolApprovalResponseEvent(
	msg domain.ToolApprovalResponseEvent,
) tea.Cmd

func (*ChatHandler) HandleToolCallReadyEvent added in v0.53.0

func (h *ChatHandler) HandleToolCallReadyEvent(
	msg domain.ToolCallReadyEvent,
) tea.Cmd

func (*ChatHandler) HandleToolCallUpdateEvent added in v0.53.0

func (h *ChatHandler) HandleToolCallUpdateEvent(
	msg domain.ToolCallUpdateEvent,
) tea.Cmd

func (*ChatHandler) HandleToolCancelledEvent added in v0.110.1

func (h *ChatHandler) HandleToolCancelledEvent(
	msg domain.ToolCancelledEvent,
) tea.Cmd

func (*ChatHandler) HandleToolCommand added in v0.97.0

func (h *ChatHandler) HandleToolCommand(commandText string) tea.Cmd

HandleToolCommand processes tool commands starting with !!. Delegates to DirectExecutionService.

func (*ChatHandler) HandleToolExecutionCompletedEvent added in v0.53.0

func (h *ChatHandler) HandleToolExecutionCompletedEvent(
	msg domain.ToolExecutionCompletedEvent,
) tea.Cmd

func (*ChatHandler) HandleToolExecutionProgressEvent added in v0.53.0

func (h *ChatHandler) HandleToolExecutionProgressEvent(
	msg domain.ToolExecutionProgressEvent,
) tea.Cmd

func (*ChatHandler) HandleToolExecutionStartedEvent added in v0.53.0

func (h *ChatHandler) HandleToolExecutionStartedEvent(
	msg domain.ToolExecutionStartedEvent,
) tea.Cmd

func (*ChatHandler) HandleUserInputEvent added in v0.53.0

func (h *ChatHandler) HandleUserInputEvent(
	msg domain.UserInputEvent,
) tea.Cmd

func (*ChatHandler) HandleUserQuestionRequestedEvent added in v0.124.0

func (h *ChatHandler) HandleUserQuestionRequestedEvent(
	msg domain.UserQuestionRequestedEvent,
) tea.Cmd

HandleUserQuestionRequestedEvent sets up the AskUserQuestion form. The agent loop stays blocked in the tool until the user answers, so there is no restart.

func (*ChatHandler) ListenForChatEvents added in v0.97.0

func (h *ChatHandler) ListenForChatEvents(eventChan <-chan domain.ChatEvent) tea.Cmd

ListenForChatEvents creates a tea.Cmd that listens for the next event from the channel. Wraps the shared eventlistener service so callers within this package and the legacy domain.ChatHandler interface continue to work.

func (*ChatHandler) ListenForEvents added in v0.97.0

func (h *ChatHandler) ListenForEvents(eventChan <-chan tea.Msg) tea.Cmd

ListenForEvents reads one event off a generic tea.Msg channel as a tea.Cmd. Kept on the orchestrator because domain.ChatHandler still exposes it and the runner-internal handlers (tool execution progress) call it directly.

func (*ChatHandler) ParseArguments added in v0.45.4

func (h *ChatHandler) ParseArguments(argsStr string) (map[string]any, error)

ParseArguments satisfies the legacy domain.ChatHandler interface by delegating to DirectExecutionService.

func (*ChatHandler) ParseToolCall added in v0.45.4

func (h *ChatHandler) ParseToolCall(input string) (string, map[string]any, error)

ParseToolCall satisfies the legacy domain.ChatHandler interface by delegating to DirectExecutionService.

func (*ChatHandler) SetActiveToolCallID added in v0.97.0

func (h *ChatHandler) SetActiveToolCallID(id string)

SetActiveToolCallID satisfies the legacy domain.ChatHandler interface by forwarding to ToolExecutionCoordinator.

func (*ChatHandler) SetBashDetachChan added in v0.81.0

func (h *ChatHandler) SetBashDetachChan(ch chan<- struct{})

SetBashDetachChan satisfies the legacy domain.ChatHandler interface by forwarding to DirectExecutionService (the actual owner post-#529).

type ChatMessageProcessor added in v0.45.4

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

ChatMessageProcessor handles message processing logic

func NewChatMessageProcessor added in v0.45.4

func NewChatMessageProcessor(handler *ChatHandler) *ChatMessageProcessor

NewChatMessageProcessor creates a new message processor

func (*ChatMessageProcessor) ExtractMarkdownSummary added in v0.45.4

func (p *ChatMessageProcessor) ExtractMarkdownSummary(content string) (string, bool)

ExtractMarkdownSummary extracts the "## Summary" section from markdown content (exposed for testing)

type ChatShortcutHandler added in v0.45.4

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

ChatShortcutHandler handles shortcut execution and side effects

func NewChatShortcutHandler added in v0.45.4

func NewChatShortcutHandler(handler *ChatHandler) *ChatShortcutHandler

NewChatShortcutHandler creates a new shortcut handler

type MessageHistoryHandler added in v0.91.0

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

MessageHistoryHandler handles message history navigation and restoration

func NewMessageHistoryHandler added in v0.91.0

func NewMessageHistoryHandler(
	conversationRepo domain.ConversationRepository,
) *MessageHistoryHandler

NewMessageHistoryHandler creates a new message history handler

func (*MessageHistoryHandler) HandleEdit added in v0.92.0

HandleEdit processes the message history edit event

func (*MessageHistoryHandler) HandleEditSubmit added in v0.92.0

func (h *MessageHistoryHandler) HandleEditSubmit(event domain.MessageEditSubmitEvent) tea.Cmd

HandleEditSubmit processes the message edit submission

func (*MessageHistoryHandler) HandleNavigateBackInTime added in v0.91.0

func (h *MessageHistoryHandler) HandleNavigateBackInTime(event domain.NavigateBackInTimeEvent) tea.Cmd

HandleNavigateBackInTime processes the navigate back in time event

func (*MessageHistoryHandler) HandleRestore added in v0.91.0

HandleRestore processes the message history restore event

Jump to

Keyboard shortcuts

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