Documentation
¶
Overview ¶
Package ui provides shared UI components and utilities for the AutoCmd terminal interface.
Index ¶
- Constants
- func AnsweredQuestionCount(d domain.QuestionDisplay, per []QuestionPerState) int
- func HandleQuestionKey(d domain.QuestionDisplay, s QuestionUIState, key tea.KeyMsg) (QuestionUIState, QuestionOutcome)
- func IsVisuallyEmpty(s string) bool
- func NormalizeBlock(s string) string
- func OnReview(d domain.QuestionDisplay, s QuestionUIState) bool
- func QuestionHasAnswer(q domain.QuestionInfo, st QuestionPerState) bool
- func ShortNum(n int) string
- func ToAdaptiveColor(c ColorInfo) lipgloss.AdaptiveColor
- func TrimVisuallyEmpty(s string) string
- func UnansweredIndices(d domain.QuestionDisplay, per []QuestionPerState) []int
- type Action
- type ActionBlockSpec
- type ColorInfo
- type Config
- type ContentTruncateMode
- type GlamourRenderer
- type Item
- type NoOpGater
- type PassthroughRenderer
- type Picker
- type QuestionOutcome
- type QuestionPerState
- type QuestionUIState
- type RenderSpecOptions
- type Renderer
- type SpinnerRenderer
- type Theme
- func (t *Theme) ActionBlock(content string, status ToolStatus, _ string) string
- func (t *Theme) Box(content string, _ int, status ToolStatus) string
- func (t *Theme) Error(s string) string
- func (t *Theme) ErrorColor() lipgloss.AdaptiveColor
- func (t *Theme) Muted(s string) string
- func (t *Theme) MutedColor() lipgloss.AdaptiveColor
- func (t *Theme) Primary(s string) string
- func (t *Theme) PrimaryColor() lipgloss.AdaptiveColor
- func (t *Theme) RenderActionBlock(spec ActionBlockSpec) string
- func (t *Theme) Separator(width int, status ToolStatus) string
- func (t *Theme) StatusPrefix(status ToolStatus, frame string) string
- func (t *Theme) Success(s string) string
- func (t *Theme) SuccessColor() lipgloss.AdaptiveColor
- func (t *Theme) TextColor() lipgloss.AdaptiveColor
- type ToolOutputGater
- type ToolRenderer
- func (r *ToolRenderer) RenderBash(d domain.BashDisplay, output string, status ToolStatus, err string, ...) string
- func (r *ToolRenderer) RenderDiff(d domain.DiffDisplay, status ToolStatus, err string, frame string) string
- func (r *ToolRenderer) RenderQuestion(d domain.QuestionDisplay, state QuestionUIState, status ToolStatus, err string, ...) string
- func (r *ToolRenderer) RenderString(d domain.StringDisplay, status ToolStatus, err string, frame string) string
- type ToolStatus
- type TruncatingGater
Constants ¶
const ( // ToolInsetPrefix is the standard horizontal padding for tool execution blocks. ToolInsetPrefix = " " // ToolFirstContentGutterPrefix is the prefix used for the first line of tool output. ToolFirstContentGutterPrefix = " ⎿ " // ToolContentGutterPrefix is the prefix used for subsequent lines of tool output. ToolContentGutterPrefix = " " )
Variables ¶
This section is empty.
Functions ¶
func AnsweredQuestionCount ¶
func AnsweredQuestionCount(d domain.QuestionDisplay, per []QuestionPerState) int
AnsweredQuestionCount returns how many questions have a non-empty answer (for the review summary).
func HandleQuestionKey ¶
func HandleQuestionKey(d domain.QuestionDisplay, s QuestionUIState, key tea.KeyMsg) (QuestionUIState, QuestionOutcome)
HandleQuestionKey applies one logical key to state and returns updated state and outcome.
func IsVisuallyEmpty ¶
IsVisuallyEmpty returns true if the string contains only ANSI escape codes and whitespace.
func NormalizeBlock ¶
NormalizeBlock ensures a block has at least one leading newline and no trailing newlines. It respects larger gaps by prepending N-1 newlines if the source has more than 2 leading newlines. It also trims any visually empty lines (ANSI/whitespace only) from the start and end.
func OnReview ¶
func OnReview(d domain.QuestionDisplay, s QuestionUIState) bool
OnReview reports whether the UI is on the synthetic review step (Active == n with n > 1).
func QuestionHasAnswer ¶
func QuestionHasAnswer(q domain.QuestionInfo, st QuestionPerState) bool
QuestionHasAnswer is true if the question has a non-empty selection or custom text.
func ToAdaptiveColor ¶
func ToAdaptiveColor(c ColorInfo) lipgloss.AdaptiveColor
ToAdaptiveColor converts a ColorInfo (e.g. from config) to lipgloss.AdaptiveColor.
func TrimVisuallyEmpty ¶
TrimVisuallyEmpty removes leading and trailing lines that contain only ANSI escape codes and whitespace.
func UnansweredIndices ¶
func UnansweredIndices(d domain.QuestionDisplay, per []QuestionPerState) []int
UnansweredIndices returns the 1-based indices of questions without answers.
Types ¶
type ActionBlockSpec ¶
type ActionBlockSpec struct {
Frame string
HeaderLines []string
ContentLines []string
Status ToolStatus
}
ActionBlockSpec is the semantic rendering contract passed from ToolRenderer to Theme. Theme consumes this structure for placement and styling only.
type Config ¶
type Config struct {
Title string
Items []Item
// Theme controls the visual styling of the picker.
// If nil, a default style that roughly matches the global theme is used.
Theme *Theme
Actions []Action
}
Config configures the picker.
type ContentTruncateMode ¶
type ContentTruncateMode int
ContentTruncateMode defines how large tool outputs should be truncated for display.
type GlamourRenderer ¶
type GlamourRenderer struct {
// contains filtered or unexported fields
}
GlamourRenderer wraps glamour.TermRenderer to implement Renderer.
func (*GlamourRenderer) Render ¶
func (g *GlamourRenderer) Render(markdown string) string
Render implements Renderer. On error, it returns the original markdown and logs.
type NoOpGater ¶
type NoOpGater struct{}
NoOpGater implements a gater that performs no truncation.
func NewNoOpGater ¶
func NewNoOpGater() *NoOpGater
NewNoOpGater returns a gater that performs no truncation.
type PassthroughRenderer ¶
type PassthroughRenderer struct{}
PassthroughRenderer is a no-op renderer that returns markdown as-is.
func (*PassthroughRenderer) Render ¶
func (p *PassthroughRenderer) Render(markdown string) string
Render returns the original markdown without modification.
type Picker ¶
type Picker struct {
// contains filtered or unexported fields
}
Picker is a reusable grouped list selection model.
func (*Picker) CursorItem ¶
CursorItem returns the item currently under the cursor.
func (*Picker) RefreshItems ¶
RefreshItems allows the caller to update the list (e.g. after a rename or delete).
type QuestionOutcome ¶
QuestionOutcome is the reducer result when the user submits or cancels.
type QuestionPerState ¶
type QuestionPerState struct {
CustomBuffer string
MultiSelected []bool
Cursor int
SingleSelected int
CustomInputFocused bool
CustomSelected bool
}
QuestionPerState is state for one question in the toolbox.
type QuestionUIState ¶
type QuestionUIState struct {
Per []QuestionPerState
Active int
ReviewCursor int
Submitted bool
}
QuestionUIState is interactive UI state for QuestionDisplay (prompt-owned; lives in ui to avoid import cycles with ToolRenderer).
func NewQuestionUIState ¶
func NewQuestionUIState(d domain.QuestionDisplay) QuestionUIState
NewQuestionUIState initializes state for d.Questions (one QuestionPerState each).
type RenderSpecOptions ¶
type RenderSpecOptions struct {
TruncateMode ContentTruncateMode
TruncateFromContentIndex int
Scrollable bool
}
RenderSpecOptions configures the behavior of the tool rendering pipeline.
type Renderer ¶
Renderer renders markdown to ANSI strings. Failure should be handled internally.
func NewGlamourRenderer ¶
NewGlamourRenderer creates a Renderer using glamour with the given width. If glamour initialization fails, it logs the error and returns a PassthroughRenderer.
type SpinnerRenderer ¶
SpinnerRenderer handles braille spinner animations.
func NewSpinnerRenderer ¶
func NewSpinnerRenderer(style lipgloss.Style) *SpinnerRenderer
NewSpinnerRenderer creates a new SpinnerRenderer.
func (*SpinnerRenderer) Frame ¶
func (r *SpinnerRenderer) Frame(tick int) string
Frame returns the spinner character for a given tick.
type Theme ¶
type Theme struct {
PrimaryCol lipgloss.AdaptiveColor
SuccessCol lipgloss.AdaptiveColor
ErrorCol lipgloss.AdaptiveColor
MutedCol lipgloss.AdaptiveColor
TextCol lipgloss.AdaptiveColor
}
Theme provides styling and configuration for the UI.
func (*Theme) ActionBlock ¶
func (t *Theme) ActionBlock(content string, status ToolStatus, _ string) string
ActionBlock renders a simple action block with header and content.
func (*Theme) Box ¶
func (t *Theme) Box(content string, _ int, status ToolStatus) string
Box exists for compatibility while tests migrate from box-style assertions.
func (*Theme) ErrorColor ¶
func (t *Theme) ErrorColor() lipgloss.AdaptiveColor
ErrorColor returns the theme's error adaptive color.
func (*Theme) MutedColor ¶
func (t *Theme) MutedColor() lipgloss.AdaptiveColor
MutedColor returns the theme's muted adaptive color.
func (*Theme) PrimaryColor ¶
func (t *Theme) PrimaryColor() lipgloss.AdaptiveColor
PrimaryColor returns the theme's primary adaptive color.
func (*Theme) RenderActionBlock ¶
func (t *Theme) RenderActionBlock(spec ActionBlockSpec) string
RenderActionBlock renders an action execution block using status markers and colors.
func (*Theme) Separator ¶
func (t *Theme) Separator(width int, status ToolStatus) string
Separator returns a styled horizontal line.
func (*Theme) StatusPrefix ¶
func (t *Theme) StatusPrefix(status ToolStatus, frame string) string
StatusPrefix returns a styled icon with a trailing space.
func (*Theme) SuccessColor ¶
func (t *Theme) SuccessColor() lipgloss.AdaptiveColor
SuccessColor returns the theme's success adaptive color.
func (*Theme) TextColor ¶
func (t *Theme) TextColor() lipgloss.AdaptiveColor
TextColor returns the theme's text adaptive color.
type ToolOutputGater ¶
type ToolOutputGater struct {
// contains filtered or unexported fields
}
ToolOutputGater implements tool-specific truncation logic.
func NewToolOutputGater ¶
func NewToolOutputGater(maxLines int) *ToolOutputGater
NewToolOutputGater creates a gater optimized for tool output (bash.diff).
type ToolRenderer ¶
ToolRenderer provides rendering for tool outputs (StringDisplay, DiffDisplay, BashDisplay).
func NewToolRenderer ¶
func NewToolRenderer(theme *Theme, width int, g gater) *ToolRenderer
NewToolRenderer creates a new ToolRenderer.
func (*ToolRenderer) RenderBash ¶
func (r *ToolRenderer) RenderBash(d domain.BashDisplay, output string, status ToolStatus, err string, frame string) string
RenderBash renders BashDisplay.
func (*ToolRenderer) RenderDiff ¶
func (r *ToolRenderer) RenderDiff(d domain.DiffDisplay, status ToolStatus, err string, frame string) string
RenderDiff renders DiffDisplay.
func (*ToolRenderer) RenderQuestion ¶
func (r *ToolRenderer) RenderQuestion(d domain.QuestionDisplay, state QuestionUIState, status ToolStatus, err string, frame string) string
RenderQuestion renders QuestionDisplay with interactive state (cursor, toggles, custom text). Unlike other tool renderers, it never prepends a status prefix (spinner/checkmark); the question header is the first line.
func (*ToolRenderer) RenderString ¶
func (r *ToolRenderer) RenderString(d domain.StringDisplay, status ToolStatus, err string, frame string) string
RenderString renders StringDisplay.
type ToolStatus ¶
type ToolStatus int
ToolStatus represents tool lifecycle state for display rendering.
const ( // StatusRunning indicates that a tool or process is currently active. StatusRunning ToolStatus = iota // StatusAwaitingApproval indicates that a tool is blocked waiting for user consent. StatusAwaitingApproval // StatusSuccess indicates that a tool or process completed successfully. StatusSuccess // StatusError indicates that a tool or process failed. StatusError )
type TruncatingGater ¶
type TruncatingGater struct {
// contains filtered or unexported fields
}
TruncatingGater implements viewport-style truncation.
func NewTruncatingGater ¶
func NewTruncatingGater(maxLines int) *TruncatingGater
NewTruncatingGater creates a gater that truncates content after maxLines.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package authui provides the UI components for the authentication workflow.
|
Package authui provides the UI components for the authentication workflow. |
|
Package history provides components for rendering the conversation history in the terminal.
|
Package history provides components for rendering the conversation history in the terminal. |
|
Package info provides UI components for displaying system information and settings.
|
Package info provides UI components for displaying system information and settings. |
|
Package model_picker provides UI components for selecting LLM models.
|
Package model_picker provides UI components for selecting LLM models. |
|
Package prompt provides the main interactive prompt and tool execution UI.
|
Package prompt provides the main interactive prompt and tool execution UI. |
|
Package session_picker provides UI components for selecting and managing chat sessions.
|
Package session_picker provides UI components for selecting and managing chat sessions. |