app

package
v0.94.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package app implements the flowbot-chat terminal UI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearConfirmState

func ClearConfirmState() (pendingID, tool, summary string)

ClearConfirmState resets confirmation UI state.

func ClearSessionID

func ClearSessionID(profile string) error

ClearSessionID removes the persisted session id.

func DefaultExportFilename

func DefaultExportFilename(sessionID string) string

DefaultExportFilename builds the default export filename for a session id.

func EstimateHistoryTokens

func EstimateHistoryTokens(msgs []client.ChatHistoryMessage) int

EstimateHistoryTokens approximates context usage from persisted message text.

func FormatAssistantBlock

func FormatAssistantBlock(text string, width int, styles *Styles) string

FormatAssistantBlock renders agent markdown with a left marker on the first line.

func FormatExportSuccess

func FormatExportSuccess(path string, count int) string

FormatExportSuccess returns the transcript line shown after a successful export.

func FormatFileWarning

func FormatFileWarning(att FileAttachment) string

FormatFileWarning returns a hint-line warning when a file was truncated or large.

func FormatHistoryLine

func FormatHistoryLine(role, text string, styles *Styles) string

FormatHistoryLine renders one transcript line for the viewport.

func FormatHistoryMessages

func FormatHistoryMessages(msgs []client.ChatHistoryMessage, width int, styles *Styles) string

FormatHistoryMessages renders persisted messages with separators only between turns.

func FormatSeparator

func FormatSeparator(width int, styles *Styles) string

FormatSeparator returns a horizontal rule between conversation turns.

func FormatSessionRow

func FormatSessionRow(summary client.ChatSessionSummary, currentID string, selected bool, styles *Styles) string

FormatSessionRow renders one session entry for the picker.

func FormatSystemLine

func FormatSystemLine(text string, styles *Styles) string

FormatSystemLine renders a neutral system/status line in the transcript.

func FormatThinkingBlock added in v0.94.0

func FormatThinkingBlock(text string, width int, styles *Styles) string

FormatThinkingBlock renders provider reasoning above the assistant reply.

func FormatToolLine added in v0.94.0

func FormatToolLine(ev client.ChatStreamEvent, styles *Styles) string

FormatToolLine renders a styled tool status line for the transcript.

func HandleCtrlC

func HandleCtrlC(phase RunPhase) (next RunPhase, action CtrlCAction)

HandleCtrlC applies Hermes-style Ctrl+C semantics for the current phase.

func LoadSessionID

func LoadSessionID(profile string) (string, error)

LoadSessionID reads a persisted session id.

func NewProgram

func NewProgram(m *Model) *tea.Program

NewProgram wraps the model in a bubbletea program.

func ParseSlashCommand

func ParseSlashCommand(line string) (command string, args string, ok bool)

ParseSlashCommand handles /commands entered in the input area.

func RenderBanner

func RenderBanner(width int, styles *Styles) string

RenderBanner returns the top ASCII banner, compact when width is narrow.

func RenderContextUsage

func RenderContextUsage(info *client.ChatContextUsage, styles *Styles) string

RenderContextUsage formats the /context panel from a server usage report.

func RenderDebounce

func RenderDebounce(buf string) time.Duration

RenderDebounce returns how long to wait before re-rendering markdown for buf. Shorter buffers refresh quickly; long replies and in-progress code fences back off to avoid re-running glamour on every streaming delta.

func RenderMarkdown

func RenderMarkdown(source string, width int) string

RenderMarkdown renders assistant markdown for terminal display via glamour.

func RenderSplash

func RenderSplash(width int, info *client.ChatAgentInfo, sessionID, serverHost string, styles *Styles) string

RenderSplash builds the Hermes-style startup panel.

func RenderStatusBar

func RenderStatusBar(snap StatusSnapshot, styles *Styles) string

RenderStatusBar formats the segmented status line.

func ResolveContextWindow

func ResolveContextWindow(chatModel, toolModel string) int

ResolveContextWindow returns the effective input token budget for chat and tool models.

func ResolveContextWindowFromInfo

func ResolveContextWindowFromInfo(info *client.ChatAgentInfo) int

ResolveContextWindowFromInfo reads the context window from agent splash metadata.

func ResolveExportPath

func ResolveExportPath(args, sessionID string) (string, error)

ResolveExportPath returns the destination path for /export. An empty args value writes to the default filename in the current directory.

func SaveSessionID

func SaveSessionID(profile, sessionID string) error

SaveSessionID persists the active session id for resume.

func SessionStatusText

func SessionStatusText(sessionID string, messageCount int, mode string) string

SessionStatusText formats /status output.

func SlashHelp

func SlashHelp() string

SlashHelp returns the /help text.

func WrapUserMessage

func WrapUserMessage(att *FileAttachment, text string) string

WrapUserMessage wraps optional file content around the user text.

func WriteSessionExport

func WriteSessionExport(path string, export *client.ChatSessionExport) error

WriteSessionExport serializes one server session export to a JSON file.

Types

type CtrlCAction

type CtrlCAction int

CtrlCAction describes what Ctrl+C should trigger.

const (
	CtrlCNone CtrlCAction = iota
	CtrlCCancelRun
	CtrlCDenyConfirm
	CtrlCCancelSessionPick
	CtrlCQuit
)

type FileAttachment

type FileAttachment struct {
	Path      string
	Content   string
	Truncated bool
	OrigSize  int
	EstTokens int
}

FileAttachment holds a local file queued for the next user message.

func ReadLocalFile

func ReadLocalFile(path string) (FileAttachment, error)

ReadLocalFile loads a file for /file attachment with size limits.

type Model

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

Model is the bubbletea model for flowbot-chat.

func NewModel

func NewModel(cl *client.Client, profile string) *Model

NewModel constructs the chat TUI model.

func (*Model) Init

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

Init loads agent info and resumes any saved session.

func (*Model) Update

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

Update handles bubbletea messages.

func (*Model) View

func (m *Model) View() tea.View

View renders the chat TUI.

type ResourceOverlay added in v0.94.0

type ResourceOverlay struct {
	URI     string
	Title   string
	Content string
}

ResourceOverlay holds the full-screen resource preview state.

type RunPhase

type RunPhase int

RunPhase tracks whether the UI is idle, streaming, or awaiting confirmation.

const (
	PhaseIdle RunPhase = iota
	PhaseStreaming
	PhaseConfirming
	PhaseSessionPick
)

type SlashCommand

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

SlashCommand describes one slash command entry for autocomplete.

func MatchSlashCommands

func MatchSlashCommands(prefix string) []SlashCommand

MatchSlashCommands returns commands whose name prefix-matches prefix.

type StatusSnapshot

type StatusSnapshot struct {
	Model          string
	PlanMode       bool
	TotalTokens    int
	ContextWindow  int
	ContextPercent float64
	Elapsed        time.Duration
	TurnElapsed    time.Duration
	Streaming      bool
	SpinnerFrame   int
}

StatusSnapshot drives the fixed status bar.

type Styles

type Styles struct {
	BannerTitle    lipgloss.Style
	BannerDim      lipgloss.Style
	SplashBox      lipgloss.Style
	Rule           lipgloss.Style
	UserMsg        lipgloss.Style
	UserBar        lipgloss.Style
	UserPanel      lipgloss.Style
	Assistant      lipgloss.Style
	AssistantBar   lipgloss.Style
	AssistantPanel lipgloss.Style
	Thinking       lipgloss.Style
	ThinkingPanel  lipgloss.Style
	Hint           lipgloss.Style
	System         lipgloss.Style
	Warning        lipgloss.Style
	ConfirmBox     lipgloss.Style
	Status         lipgloss.Style
	SegLabel       lipgloss.Style
	SegValue       lipgloss.Style
	SegDivider     lipgloss.Style
	InputPrompt    lipgloss.Style
	InputBox       lipgloss.Style
	ToolLine       lipgloss.Style
	ToolSub        lipgloss.Style
	SectionTitle   lipgloss.Style
}

Styles holds lipgloss styles for the chat UI.

func NewStyles

func NewStyles() Styles

NewStyles builds the default Tokyo Night-inspired dark theme.

Jump to

Keyboard shortcuts

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