tui

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAddModelChannel

func GetAddModelChannel() <-chan struct{}

GetAddModelChannel returns the channel that receives add-model requests.

func GetApprovalChannel

func GetApprovalChannel() chan ToolApprovalRequestMsg

GetApprovalChannel returns the channel that receives tool approval requests.

func GetAskUserResponseChannel

func GetAskUserResponseChannel() <-chan AskUserResponse

GetAskUserResponseChannel returns the channel for ask_user responses.

func GetAutoApproveChannel

func GetAutoApproveChannel() <-chan bool

GetAutoApproveChannel returns the channel that receives auto-approve mode changes.

func GetChannelActionChannel added in v0.1.1

func GetChannelActionChannel() <-chan ChannelAction

GetChannelActionChannel returns the channel for channel action events.

func GetCompactChannel

func GetCompactChannel() <-chan struct{}

GetCompactChannel returns the channel that receives compact requests.

func GetConfigChannel

func GetConfigChannel() <-chan *config.Config

GetConfigChannel returns the channel that receives configuration changes.

func GetPendingPromptChannel

func GetPendingPromptChannel() <-chan string

func GetPlanModeChannel

func GetPlanModeChannel() <-chan AgentMode

GetPlanModeChannel returns the channel that receives plan mode switch events.

func GetPlanResponseChannel

func GetPlanResponseChannel() <-chan PlanResponse

GetPlanResponseChannel returns the channel for plan responses.

func GetPromptChannel

func GetPromptChannel() <-chan string

func GetResumeChannel

func GetResumeChannel() <-chan string

GetResumeChannel returns the channel that receives session resume requests.

func GetSSHChannel

func GetSSHChannel() <-chan interface{}

func HeaderView

func HeaderView() string

func RenderCoordinatorPanel

func RenderCoordinatorPanel(ts *TeamViewState, width int) string

RenderCoordinatorPanel renders the team status panel at the bottom of the screen.

func RenderTeamStatusPill

func RenderTeamStatusPill(count int) string

RenderTeamStatusPill renders a small "N teammates" indicator for the status bar.

func RenderTeammateMessage

func RenderTeammateMessage(from, content, color, summary string) string

RenderTeammateMessage renders a message from a teammate with color and identity.

func RenderTeammateViewHeader

func RenderTeammateViewHeader(identity team.TeammateIdentity) string

RenderTeammateViewHeader renders the header when viewing a teammate's conversation.

func RunSetupTUI

func RunSetupTUI() (bool, error)

Types

type AddModelMsg

type AddModelMsg struct{}

AddModelMsg signals that the user wants to add a new model via setup wizard

type AgentDoneMsg

type AgentDoneMsg struct{ Err error }

type AgentMode

type AgentMode int

AgentMode represents the agent's operational mode.

const (
	ModeNormal    AgentMode = iota // Default mode
	ModePlanning                   // Plan mode — read-only exploration
	ModeExecuting                  // Executing an approved plan
)

type AgentTextMsg

type AgentTextMsg struct{ Text string }

type AgentsMdMsg

type AgentsMdMsg struct {
	Found bool
	Path  string
}

AgentsMdMsg is sent by the main goroutine to notify TUI that agents.md was loaded.

type ApprovalMode

type ApprovalMode int

ApprovalMode represents the approval mode state

const (
	ModeManual ApprovalMode = iota // Manual approval mode (default)
	ModeAuto                       // Auto-approve mode
)

type AskUserQuestionMsg

type AskUserQuestionMsg struct {
	Question string
	Options  []string // optional selectable choices
}

AskUserQuestionMsg is sent when the agent asks the user a question via ask_user tool.

type AskUserResponse

type AskUserResponse struct {
	Answer string
}

AskUserResponse is the user's answer to an ask_user question.

type BgTaskDoneMsg

type BgTaskDoneMsg struct {
	TaskID  string
	Command string
	Status  string
	Output  string
}

BgTaskDoneMsg is sent when a background task completes.

type ChannelAction added in v0.1.1

type ChannelAction struct {
	ChannelID string // "wechat"
	Action    string // "login", "logout", "enable", "disable"
}

ChannelAction represents an action the user wants to perform on a channel.

type ChannelInboundMsg added in v0.1.1

type ChannelInboundMsg struct {
	ChannelID string
	From      string
	Text      string
}

ChannelInboundMsg is sent when an inbound message arrives from a channel.

type ChannelQRCodeMsg added in v0.1.1

type ChannelQRCodeMsg struct {
	ChannelID     string
	QRCodeURL     string // image data or URL
	QRCodeContent string // raw content to encode as terminal QR
	Message       string
}

ChannelQRCodeMsg is sent when a QR code is available for scanning.

type ChannelStateMsg added in v0.1.1

type ChannelStateMsg struct {
	ChannelID string // "wechat"
	State     string // "none", "disabled", "enabled"
	Message   string // status message (e.g. "已连接", "扫码中...")
}

ChannelStateMsg is sent from the main goroutine to update channel state display in TUI.

type CompactDoneMsg

type CompactDoneMsg struct {
	OldTokens int64
	NewTokens int64
	Err       error
}

CompactDoneMsg is sent when context compaction completes.

type CompactRequestMsg

type CompactRequestMsg struct{}

CompactRequestMsg is sent when the user requests manual context compaction.

type ConfigUpdatedMsg

type ConfigUpdatedMsg struct {
	Provider string
	Model    string
	Message  string
}

ConfigUpdatedMsg is sent when the provider/model configuration is updated via setup wizard

type CopyNoticeMsg

type CopyNoticeMsg struct {
	Message string
}

CopyNoticeMsg is sent after text is copied to clipboard

type CopyNoticeTimeoutMsg

type CopyNoticeTimeoutMsg struct{}

CopyNoticeTimeoutMsg clears the copy notice

type ExitTimeoutMsg

type ExitTimeoutMsg struct{}

ExitTimeoutMsg is sent after 5s to clear exit confirmation

type MCPStatusItem

type MCPStatusItem struct {
	Name      string
	ToolCount int
	Running   bool
	ErrMsg    string
}

type MCPStatusMsg

type MCPStatusMsg struct {
	Statuses []MCPStatusItem
}

type Mode

type Mode int
const (
	ModeAgent Mode = iota
)

type Model

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

func NewModel

func NewModel(hasPrompt bool, pwd string, todoStore *tools.TodoStore) Model

func RunTUI

func RunTUI(hasPrompt bool, pwd string, todoStore *tools.TodoStore) (*tea.Program, Model)

func (Model) Init

func (m Model) Init() tea.Cmd

func (*Model) SetTeamManager

func (m *Model) SetTeamManager(manager *team.Manager)

SetTeamManager sets the team manager on the model for TUI integration.

func (Model) Update

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

func (Model) View

func (m Model) View() tea.View

type PlanApprovalMsg

type PlanApprovalMsg struct {
	PlanContent string
	PlanPath    string
}

PlanApprovalMsg is sent when the agent wants to show a plan for approval.

type PlanApprovedMsg

type PlanApprovedMsg struct{}

PlanApprovedMsg is sent when the user approves a plan.

type PlanRejectedMsg

type PlanRejectedMsg struct {
	Feedback string
}

PlanRejectedMsg is sent when the user rejects a plan.

type PlanResponse

type PlanResponse struct {
	Approved bool
	Feedback string // non-empty on rejection
}

PlanResponse is the user's response to a plan approval.

type PromptSubmitMsg

type PromptSubmitMsg struct{ Prompt string }

type ProviderProfile

type ProviderProfile struct {
	ID           string
	Name         string
	BaseURL      string
	NeedURL      bool // if true, prompt for custom URL
	NeedKey      bool // if true, prompt for API Key
	FromRegistry bool // true if provider exists in models.dev
}

ProviderProfile holds the minimal info needed for the setup wizard flow.

type ResumeRequestMsg

type ResumeRequestMsg struct{ UUID string }

ResumeRequestMsg is sent when the user requests to resume a session by UUID.

type SSHCancelMsg

type SSHCancelMsg struct{}

SSHCancelMsg is sent when user cancels the SSH dir picker via Esc.

type SSHConnectMsg

type SSHConnectMsg struct {
	Addr string // user@host
	Path string // remote working dir (optional)
}

SSHConnectMsg is sent when user initially requests connection

type SSHDirResultsMsg

type SSHDirResultsMsg struct {
	Path  string
	Items []string
	Err   error
}

SSHDirResultsMsg is sent from main to TUI with directory contents

type SSHListDirReqMsg

type SSHListDirReqMsg struct {
	Path string
}

SSHListDirReqMsg is sent when TUI needs to list a directory on the remote machine

type SSHStatusMsg

type SSHStatusMsg struct {
	Success bool
	Label   string // e.g. "root@myserver:22"
	Err     error
}

SSHStatusMsg carries the result of an SSH connection attempt.

type SessionEntry

type SessionEntry struct {
	Type         string
	Content      string
	Name         string
	Args         string
	Output       string
	Error        string
	SubagentName string
	SubagentType string
}

SessionEntry is a display-ready record from a replayed session.

func ConvertSessionEntries

func ConvertSessionEntries(entries []session.Entry) []SessionEntry

ConvertSessionEntries converts recorded session entries to display-ready SessionEntry values for the TUI session-replay view.

type SessionResumedMsg

type SessionResumedMsg struct {
	UUID    string
	Entries []SessionEntry
}

SessionResumedMsg is sent by the main goroutine to replay a session in the TUI.

type SetupDoneMsg

type SetupDoneMsg struct{}

type SetupModel

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

func NewSetupModel

func NewSetupModel() SetupModel

func (SetupModel) Init

func (m SetupModel) Init() tea.Cmd

func (SetupModel) IsDone

func (m SetupModel) IsDone() bool

func (SetupModel) Update

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

func (SetupModel) View

func (m SetupModel) View() tea.View

type SetupState

type SetupState int
const (
	StateProvider SetupState = iota
	StateModel
	StateCustomModel
	StateURL
	StateAPIKey
)

type SkillSlashInfo

type SkillSlashInfo struct {
	Slash       string
	Description string
}

SkillSlashInfo describes a skill's slash command for TUI hint display.

type SkillSlashMsg

type SkillSlashMsg struct {
	SkillName string // skill name to load
	UserInput string // additional user input after the slash command
}

SkillSlashMsg is sent when a user triggers a slash command mapped to a skill.

type SkillsLoadedMsg

type SkillsLoadedMsg struct {
	SlashCommands []SkillSlashInfo
}

SkillsLoadedMsg is sent at startup to inform the TUI about available skill slash commands.

type StatusBarComponent

type StatusBarComponent struct {
}

StatusBarComponent is a stateless-like component in Bubble Tea.

func NewStatusBarComponent

func NewStatusBarComponent() *StatusBarComponent

func (*StatusBarComponent) View

func (s *StatusBarComponent) View(state StatusBarState) string

View returns the rendered status bar.

type StatusBarState

type StatusBarState struct {
	Width             int
	ActiveProvider    string
	ActiveModel       string
	AutoApprove       bool
	TotalTokens       int64
	ModelContextLimit int
	MCPStatuses       []MCPStatusItem
	Mode              AgentMode
	BgRunning         int
	TeammateCount     int
	CopyNotice        string
}

StatusBarState holds the props supplied to the StatusBar component

type SubagentDoneMsg

type SubagentDoneMsg struct {
	Name   string
	Result string
	Err    error
}

SubagentDoneMsg is sent when a subagent finishes.

type SubagentProgressMsg

type SubagentProgressMsg struct {
	AgentName string
	Event     string // "tool_call" or "tool_result"
	ToolName  string
	Detail    string
}

SubagentProgressMsg is sent for intermediate subagent events (tool calls / results).

type SubagentStartMsg

type SubagentStartMsg struct {
	Name string
	Type string
}

SubagentStartMsg is sent when a subagent begins executing.

type SubagentTokenUpdateMsg

type SubagentTokenUpdateMsg struct {
	TotalTokens int64 // cumulative tokens used by the subagent since it started
}

SubagentTokenUpdateMsg is sent after each model turn to update the subagent's token usage.

type TeamViewMode

type TeamViewMode int

TeamViewMode represents what the user is viewing.

const (
	TeamViewLeader   TeamViewMode = iota // viewing leader's conversation
	TeamViewTeammate                     // viewing a teammate's conversation
	TeamViewPanel                        // navigating coordinator panel
)

type TeamViewState

type TeamViewState struct {
	Manager       *team.Manager
	ViewingAgent  string // agentID of currently viewed teammate ("" = leader)
	PanelVisible  bool   // show coordinator panel
	PanelSelected int    // selected index in coordinator panel
	ViewMode      TeamViewMode
	Teammates     []*team.TeammateState // cached snapshot

	// Per-teammate display lines, keyed by agentID.
	TeammateLines       map[string][]string
	TeammateCurrentText map[string]*strings.Builder
}

TeamViewState tracks team-related TUI state.

func (*TeamViewState) AppendTeammateLine

func (t *TeamViewState) AppendTeammateLine(agentID string, lines ...string)

AppendTeammateLine adds a formatted display line for a teammate.

func (*TeamViewState) AppendTeammateText

func (t *TeamViewState) AppendTeammateText(agentID, text string)

AppendTeammateText appends streaming text for a teammate.

func (*TeamViewState) FlushTeammateText

func (t *TeamViewState) FlushTeammateText(agentID string)

FlushTeammateText flushes any buffered streaming text for a teammate into a line.

func (*TeamViewState) GetTeammateDisplayLines

func (t *TeamViewState) GetTeammateDisplayLines(agentID string) []string

GetTeammateDisplayLines returns the accumulated display lines for a teammate.

func (*TeamViewState) HasTeam

func (t *TeamViewState) HasTeam() bool

HasTeam returns true if a team is active.

func (*TeamViewState) RefreshTeammates

func (t *TeamViewState) RefreshTeammates()

RefreshTeammates updates the cached teammate list.

type TodoUpdateMsg

type TodoUpdateMsg struct{}

TodoUpdateMsg signals that the todo store has been updated.

type TokenUpdateMsg

type TokenUpdateMsg struct {
	PromptTokens      int64
	CompletionTokens  int64
	TotalTokens       int64
	ModelContextLimit int // 0 if unknown
}

TokenUpdateMsg is sent periodically to update token usage display

type ToolApprovalRequestMsg

type ToolApprovalRequestMsg struct {
	Name        string
	Args        string
	Resp        chan ToolApprovalResponse
	IsExternal  bool   // Whether this is an external path access (for read tool)
	WorkerName  string // Non-empty when approval is from a teammate (e.g. "@backend")
	WorkerColor string // Teammate's color for TUI display
}

ToolApprovalRequestMsg is sent when a tool needs user approval

type ToolApprovalResponse

type ToolApprovalResponse struct {
	Approved bool
	Mode     ApprovalMode // Mode after this response (stay MANUAL or switch to AUTO)
}

ToolApprovalResponse is the user's response to a tool approval request

type ToolCallMsg

type ToolCallMsg struct{ Name, Args string }

type ToolResultMsg

type ToolResultMsg struct {
	Name, Output string
	Err          error
}

type UserPromptMsg

type UserPromptMsg struct{ Prompt string }

Jump to

Keyboard shortcuts

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