Documentation
¶
Index ¶
- Constants
- Variables
- func BottomLeftRect(area uv.Rectangle, width, height int) uv.Rectangle
- func Button(t *styles.Styles, opts ButtonOpts) string
- func ButtonGroup(t *styles.Styles, buttons []ButtonOpts, spacing string) string
- func CenterRect(area uv.Rectangle, width, height int) uv.Rectangle
- func CopyToClipboard(text, successMessage string) tea.Cmd
- func CopyToClipboardWithCallback(text, successMessage string, callback tea.Cmd) tea.Cmd
- func DialogTitle(t *styles.Styles, title string, width int, fromColor, toColor color.Color) string
- func DiffFormatter(s *styles.Styles) *diffview.DiffView
- func FormatCredits(n int) string
- func FormatReasoningEffort(effort string) string
- func InvalidateMarkdownRendererCache()
- func IsFileTooBig(filePath string, sizeLimit int64) (bool, error)
- func LockMarkdownRenderer(r *glamour.TermRenderer) *sync.Mutex
- func MarkdownRenderer(sty *styles.Styles, width int) *glamour.TermRenderer
- func ModelInfo(t *styles.Styles, modelName, providerName, reasoningInfo string, ...) string
- func PrettyPath(t *styles.Styles, path string, width int) string
- func QueryCmd(env uv.Environ) tea.Cmd
- func QuietMarkdownRenderer(sty *styles.Styles, width int) *glamour.TermRenderer
- func Scrollbar(s *styles.Styles, height, contentSize, viewportSize, offset int) string
- func Section(t *styles.Styles, text string, width int, info ...string) string
- func Status(t *styles.Styles, opts StatusOpts, width int) string
- func SyntaxHighlight(st *styles.Styles, source, fileName string, bg color.Color) (string, error)
- type ButtonOpts
- type Capabilities
- type Common
- type Model
- type ModelContextInfo
- type StatusOpts
Constants ¶
const MaxAttachmentSize = int64(5 * 1024 * 1024)
MaxAttachmentSize defines the maximum allowed size for file attachments (5 MB).
Variables ¶
var AllowedImageTypes = []string{".jpg", ".jpeg", ".png"}
AllowedImageTypes defines the permitted image file types.
Functions ¶
func BottomLeftRect ¶
BottomLeftRect returns a new [Rectangle] positioned at the bottom-left within the given area with the specified width and height.
func Button ¶
func Button(t *styles.Styles, opts ButtonOpts) string
Button creates a button with an underlined character and selection state
func ButtonGroup ¶
func ButtonGroup(t *styles.Styles, buttons []ButtonOpts, spacing string) string
ButtonGroup creates a row of selectable buttons Spacing is the separator between buttons Use " " or similar for horizontal layout Use "\n" for vertical layout Defaults to " " (horizontal)
func CenterRect ¶
CenterRect returns a new [Rectangle] centered within the given area with the specified width and height.
func CopyToClipboard ¶
CopyToClipboard copies the given text to the clipboard using both OSC 52 (terminal escape sequence) and native clipboard for maximum compatibility. Returns a command that reports success to the user with the given message.
func CopyToClipboardWithCallback ¶
CopyToClipboardWithCallback copies text to clipboard and executes a callback before showing the success message. This is useful when you need to perform additional actions like clearing UI state.
func DialogTitle ¶
DialogTitle renders a dialog title without decorative diagonal lines.
func DiffFormatter ¶
DiffFormatter returns a diff formatter with the given styles that can be used to format diff outputs.
func FormatCredits ¶
FormatCredits formats an integer with comma separators for thousands.
func FormatReasoningEffort ¶
FormatReasoningEffort formats a reasoning effort level for display.
func InvalidateMarkdownRendererCache ¶
func InvalidateMarkdownRendererCache()
InvalidateMarkdownRendererCache drops every cached renderer AND every per-renderer mutex in a single atomic critical section so the two maps cannot disagree mid-toggle. Call this whenever the active styles change so subsequent renderers pick up the new ansi.StyleConfig.
Existing holders of an old mutex (mid-Render goroutines) keep their reference safely; new renderers minted after the invalidation get freshly minted mutexes.
Lock ordering: mdCacheMu is acquired first, then rendererLocksMu — see the comments on each mutex.
func IsFileTooBig ¶
IsFileTooBig checks if the file at the given path exceeds the specified size limit.
func LockMarkdownRenderer ¶
func LockMarkdownRenderer(r *glamour.TermRenderer) *sync.Mutex
LockMarkdownRenderer returns the per-renderer mutex used to serialize concurrent Render calls on a shared glamour.TermRenderer instance. The returned *sync.Mutex is stable for the lifetime of the renderer (i.e. until InvalidateMarkdownRendererCache is called).
Callers that issue more than one Render call in the same logical operation should hold the mutex for the entire sequence so other goroutines do not interleave their own Render calls and corrupt the renderer state. F8's streamingMarkdown is the immediate consumer; other call sites that today issue exactly one Render call per item render are safe without locking under the single-threaded TUI Update loop, but should adopt this lock if they ever run in parallel (e.g. background prerender workers).
func MarkdownRenderer ¶
func MarkdownRenderer(sty *styles.Styles, width int) *glamour.TermRenderer
MarkdownRenderer returns a glamour glamour.TermRenderer configured with the given styles and width. Renderers are memoized per width and shared across callers; call InvalidateMarkdownRendererCache when the active styles change.
The returned renderer is NOT safe for concurrent Render calls (goldmark's BlockStack carries state across the public Render API). Seshat's TUI is single-threaded so production never contends, but parallel callers (most notably parallel tests) must serialize via LockMarkdownRenderer. Treat the renderer as effectively pinned to one goroutine at a time.
func ModelInfo ¶
func ModelInfo(t *styles.Styles, modelName, providerName, reasoningInfo string, context *ModelContextInfo, width int, hyperCredits *int) string
ModelInfo renders model information including name, provider, reasoning settings, and optional context usage/cost.
func PrettyPath ¶
PrettyPath formats a file path with home directory shortening and applies muted styling.
func QuietMarkdownRenderer ¶
func QuietMarkdownRenderer(sty *styles.Styles, width int) *glamour.TermRenderer
QuietMarkdownRenderer returns a glamour glamour.TermRenderer with no colors (plain text with structure) and the given width. Renderers are memoized per width and shared across callers. Same concurrency contract as MarkdownRenderer: serialize via LockMarkdownRenderer.
func Scrollbar ¶
Scrollbar renders a vertical scrollbar based on content and viewport size. Returns an empty string if content fits within viewport (no scrolling needed).
func Section ¶
Section renders a section header with a title and a horizontal line filling the remaining width.
Types ¶
type ButtonOpts ¶
type ButtonOpts struct {
// Text is the button label
Text string
// UnderlineIndex is the 0-based index of the character to underline (-1 for none)
UnderlineIndex int
// Selected indicates whether this button is currently selected
Selected bool
// Padding inner horizontal padding defaults to 2 if this is 0
Padding int
}
ButtonOpts defines the configuration for a single button
type Capabilities ¶
type Capabilities struct {
// Profile is the terminal color profile used to determine how colors are
// rendered.
Profile colorprofile.Profile
// Columns is the number of character columns in the terminal.
Columns int
// Rows is the number of character rows in the terminal.
Rows int
// PixelX is the width of the terminal in pixels.
PixelX int
// PixelY is the height of the terminal in pixels.
PixelY int
// KittyGraphics indicates whether the terminal supports the Kitty graphics
// protocol.
KittyGraphics bool
// SixelGraphics indicates whether the terminal supports Sixel graphics.
SixelGraphics bool
// Env is the terminal environment variables.
Env uv.Environ
// TerminalVersion is the terminal version string.
TerminalVersion string
// ReportFocusEvents indicates whether the terminal supports focus events.
ReportFocusEvents bool
// OSC99Notifications indicates whether the terminal supports OSC 99 notifications.
OSC99Notifications bool
}
Capabilities define different terminal capabilities supported.
func (Capabilities) CellSize ¶
func (c Capabilities) CellSize() (width, height int)
CellSize returns the size of a single terminal cell in pixels.
func (Capabilities) SupportsKittyGraphics ¶
func (c Capabilities) SupportsKittyGraphics() bool
SupportsKittyGraphics returns true if the terminal supports Kitty graphics.
func (Capabilities) SupportsSixelGraphics ¶
func (c Capabilities) SupportsSixelGraphics() bool
SupportsSixelGraphics returns true if the terminal supports Sixel graphics.
func (Capabilities) SupportsTrueColor ¶
func (c Capabilities) SupportsTrueColor() bool
SupportsTrueColor returns true if the terminal supports true color.
func (*Capabilities) Update ¶
func (c *Capabilities) Update(msg any)
Update updates the capabilities based on the given message.
type Common ¶
Common defines common UI options and configurations.
func DefaultCommon ¶
DefaultCommon returns the default common UI configurations. When the workspace has a large model selected, the theme is chosen based on its provider; otherwise the default theme is used.
type ModelContextInfo ¶
type ModelContextInfo struct {
ContextUsed int64
ModelContext int64
Cost float64
EstimatedUsage bool
}
ModelContextInfo contains token usage and cost information for a model.
type StatusOpts ¶
type StatusOpts struct {
Icon string // if empty no icon will be shown
Title string
TitleColor color.Color
Description string
DescriptionColor color.Color
ExtraContent string // additional content to append after the description
}
StatusOpts defines options for rendering a status line with icon, title, description, and optional extra content.