chat

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package chat implements an interactive TUI chat interface using bubbletea. It provides a coding-agent cockpit for conversing with the Lango agent, including streaming responses, inline tool approval, slash commands, and turn-state visibility.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApprovalRequestMsg

type ApprovalRequestMsg struct {
	Request   approval.ApprovalRequest
	ViewModel approval.ApprovalViewModel
	Response  chan<- approval.ApprovalResponse
}

ApprovalRequestMsg delivers an approval request from the agent runtime.

type BudgetWarningMsg

type BudgetWarningMsg struct {
	Used int
	Max  int
}

BudgetWarningMsg signals that delegation budget is approaching its limit.

type ChannelMessageMsg

type ChannelMessageMsg struct {
	Channel    string
	SessionKey string
	SenderName string
	Text       string
	Timestamp  time.Time
	Metadata   map[string]string
}

ChannelMessageMsg is sent when a channel message is received via EventBus.

type ChatModel

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

ChatModel is the root bubbletea model for the interactive TUI chat.

func New

func New(deps Deps) *ChatModel

New creates a new ChatModel with the given dependencies.

func (*ChatModel) Init

func (m *ChatModel) Init() tea.Cmd

Init implements tea.Model.

func (*ChatModel) RenderParts

func (m *ChatModel) RenderParts() ChatParts

View implements tea.Model. RenderParts returns the discrete rendered sections of the chat view.

func (*ChatModel) SetProgram

func (m *ChatModel) SetProgram(p *tea.Program)

SetProgram stores a reference to the tea.Program for sending messages from callbacks.

func (*ChatModel) Update

func (m *ChatModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update implements tea.Model.

func (*ChatModel) View

func (m *ChatModel) View() string

View implements tea.Model.

type ChatParts

type ChatParts struct {
	Header    string
	TurnStrip string
	Main      string
	Pending   string // empty when not in pending state
	TaskStrip string // empty when no background tasks
	Footer    string
	Approval  string // empty when no approval pending
}

ChatParts holds the discrete rendered sections of the chat view.

type ChunkMsg

type ChunkMsg struct {
	Chunk string
}

ChunkMsg delivers a streaming text chunk from the agent.

type CursorTickMsg

type CursorTickMsg time.Time

CursorTickMsg triggers cursor blink toggle during streaming.

type DelegationMsg

type DelegationMsg struct {
	From   string
	To     string
	Reason string
}

DelegationMsg signals an agent-to-agent delegation event.

type Deps

type Deps struct {
	TurnRunner        *turnrunner.Runner
	Config            *config.Config
	SessionKey        string
	BackgroundManager *background.Manager // optional, nil when background tasks unavailable
}

Deps holds the dependencies injected into the chat model.

type DoneMsg

type DoneMsg struct {
	Result turnrunner.Result
}

DoneMsg signals that a turn has finished.

type ErrorMsg

type ErrorMsg struct {
	Err error
}

ErrorMsg signals a runtime error.

type PendingIndicatorTickMsg

type PendingIndicatorTickMsg time.Time

PendingIndicatorTickMsg triggers pending indicator update (submit → first event).

type RecoveryMsg

type RecoveryMsg struct {
	CauseClass string
	Action     string
	Attempt    int
	Backoff    time.Duration
}

RecoveryMsg signals a recovery decision during structured orchestration.

type SystemMsg

type SystemMsg struct {
	Text string
}

SystemMsg is a locally generated informational message.

type TUIApprovalProvider

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

TUIApprovalProvider implements approval.Provider for the interactive TUI. It sends approval requests to the bubbletea program and waits for the user to respond with a/s/d keys.

func NewTUIApprovalProvider

func NewTUIApprovalProvider(sender func(msg interface{})) *TUIApprovalProvider

NewTUIApprovalProvider creates a TUI approval provider that uses the given bubbletea program send function for dispatching approval UI messages.

func (*TUIApprovalProvider) CanHandle

func (t *TUIApprovalProvider) CanHandle(_ string) bool

CanHandle returns false — TUI provider is a fallback, not a session-prefix router.

func (*TUIApprovalProvider) Name

func (t *TUIApprovalProvider) Name() string

Name returns the provider name for logging.

func (*TUIApprovalProvider) RequestApproval

RequestApproval sends an approval request to the TUI and blocks until the user responds or the context is cancelled.

type TaskStripTickMsg

type TaskStripTickMsg time.Time

TaskStripTickMsg triggers periodic task strip refresh.

type ThinkingFinishedMsg

type ThinkingFinishedMsg struct {
	AgentName string
	Duration  time.Duration
	Summary   string
}

ThinkingFinishedMsg signals that the agent has finished thinking/reasoning.

type ThinkingStartedMsg

type ThinkingStartedMsg struct {
	AgentName string
	Summary   string
}

ThinkingStartedMsg signals that the agent has started thinking/reasoning.

type ToolFinishedMsg

type ToolFinishedMsg struct {
	CallID   string
	ToolName string
	Success  bool
	Duration time.Duration
	Output   string
}

ToolFinishedMsg signals that a tool invocation has completed.

type ToolItemState

type ToolItemState string

ToolItemState represents the lifecycle state of a tool invocation.

type ToolStartedMsg

type ToolStartedMsg struct {
	CallID   string
	ToolName string
	Params   map[string]any
}

ToolStartedMsg signals that a tool invocation has begun.

type TurnTokenUsageMsg

type TurnTokenUsageMsg struct {
	InputTokens  int64
	OutputTokens int64
	TotalTokens  int64
	CacheTokens  int64
}

TurnTokenUsageMsg delivers per-turn token usage summary.

type WarningMsg

type WarningMsg struct {
	Elapsed     time.Duration
	HardCeiling time.Duration
}

WarningMsg signals that a turn is approaching its timeout.

Jump to

Keyboard shortcuts

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