Documentation
¶
Overview ¶
Package app implements the flowbot-chat terminal UI.
Index ¶
- func ClearConfirmState() (pendingID, tool, summary string)
- func ClearSessionID(profile string) error
- func DefaultExportFilename(sessionID string) string
- func EstimateHistoryTokens(msgs []client.ChatHistoryMessage) int
- func FormatAssistantBlock(text string, width int, styles *Styles) string
- func FormatExportSuccess(path string, count int) string
- func FormatFileWarning(att FileAttachment) string
- func FormatHistoryLine(role, text string, styles *Styles) string
- func FormatHistoryMessages(msgs []client.ChatHistoryMessage, width int, styles *Styles) string
- func FormatSeparator(width int, styles *Styles) string
- func FormatSessionRow(summary client.ChatSessionSummary, currentID string, selected bool, ...) string
- func FormatSystemLine(text string, styles *Styles) string
- func HandleCtrlC(phase RunPhase) (next RunPhase, action CtrlCAction)
- func LoadSessionID(profile string) (string, error)
- func NewProgram(m *Model) *tea.Program
- func ParseSlashCommand(line string) (command string, args string, ok bool)
- func RenderBanner(width int, styles *Styles) string
- func RenderContextUsage(info *client.ChatContextUsage, styles *Styles) string
- func RenderDebounce(buf string) time.Duration
- func RenderMarkdown(source string, width int) string
- func RenderSplash(width int, info *client.ChatAgentInfo, sessionID, serverHost string, ...) string
- func RenderStatusBar(snap StatusSnapshot, styles *Styles) string
- func ResolveContextWindow(chatModel, toolModel string) int
- func ResolveContextWindowFromInfo(info *client.ChatAgentInfo) int
- func ResolveExportPath(args, sessionID string) (string, error)
- func SaveSessionID(profile, sessionID string) error
- func SessionStatusText(sessionID string, messageCount int) string
- func SlashHelp() string
- func WrapUserMessage(att *FileAttachment, text string) string
- func WriteSessionExport(path string, export *client.ChatSessionExport) error
- type CtrlCAction
- type FileAttachment
- type Model
- type RunPhase
- type SlashCommand
- type StatusSnapshot
- type Styles
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 ¶
ClearSessionID removes the persisted session id.
func DefaultExportFilename ¶
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 ¶
FormatAssistantBlock renders agent markdown with a left marker on the first line.
func FormatExportSuccess ¶
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 ¶
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 ¶
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 ¶
FormatSystemLine renders a neutral system/status line in 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 ¶
LoadSessionID reads a persisted session id.
func NewProgram ¶
NewProgram wraps the model in a bubbletea program.
func ParseSlashCommand ¶
ParseSlashCommand handles /commands entered in the input area.
func RenderBanner ¶
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 ¶
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 ¶
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 Hermes-style status line.
func ResolveContextWindow ¶
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 ¶
ResolveExportPath returns the destination path for /export. An empty args value writes to the default filename in the current directory.
func SaveSessionID ¶
SaveSessionID persists the active session id for resume.
func SessionStatusText ¶
SessionStatusText formats /status output.
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 ¶
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.
type RunPhase ¶
type RunPhase int
RunPhase tracks whether the UI is idle, streaming, or awaiting confirmation.
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
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
Assistant lipgloss.Style
Hint lipgloss.Style
Warning lipgloss.Style
ConfirmBox lipgloss.Style
Status lipgloss.Style
InputPrompt lipgloss.Style
}
Styles holds lipgloss styles for the chat UI.