render

package
v0.101.3 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package render provides pure rendering functions for message blocks. These functions are stateless and can be used by both streaming and historical message rendering paths, eliminating code duplication.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlertBody added in v0.91.0

func AlertBody(content string, width int) string

AlertBody prepares content for a herald alert.

herald prefixes every line of an alert with a two-column gutter bar but does not wrap: given a long line it emits a long line, which then wraps in the terminal emulator instead of in lipgloss. That corrupts the scroll list's height accounting, so alert content is wrapped to the content column first.

func AssistantBlock

func AssistantBlock(content string, width int, theme style.Theme) string

AssistantBlock renders an assistant message with markdown styling.

func CustomBlock added in v0.58.1

func CustomBlock(content, label string, width int, theme style.Theme) string

CustomBlock renders a message with herald Note styling and a custom label. Content is rendered as markdown before being wrapped in the alert.

func ErrorBlock

func ErrorBlock(errorMsg string, width int, ty *herald.Typography, theme style.Theme) string

ErrorBlock renders an error message with herald Caution styling.

func HighlightFileTokens added in v0.58.1

func HighlightFileTokens(text string, theme style.Theme) string

HighlightFileTokens wraps @file tokens in the given text with the theme accent color so they stand out visually in rendered user messages.

func ReasoningBlock

func ReasoningBlock(content string, duration int64, width int, ty *herald.Typography, theme style.Theme) string

ReasoningBlock renders a reasoning/thinking block with muted italic text. If duration > 0, shows "Thought for Xs" label. Otherwise shows just "Thought". The width parameter is the full terminal width and controls soft-wrapping so long reasoning lines don't get cut off.

func ReasoningBlockFromContent added in v0.85.1

func ReasoningBlockFromContent(renderedContent string, duration int64, theme style.Theme) string

ReasoningBlockFromContent composes a pre-rendered reasoning content block (from ReasoningContent) with the duration label and bottom margin. This is cheap relative to ReasoningContent and safe to call per frame.

func ReasoningContent added in v0.85.1

func ReasoningContent(content string, width int, ty *herald.Typography) string

ReasoningContent renders just the styled content portion of a reasoning block (muted italic, soft-wrapped, indented to the shared content column) without the duration label. This is the expensive part of ReasoningBlock; callers that render repeatedly (e.g. a streaming item with a live duration counter) can cache this and compose it with ReasoningBlockFromContent per frame.

width is the full terminal width; the content column is derived from it.

func SystemBlock

func SystemBlock(content string, width int, ty *herald.Typography, theme style.Theme) string

SystemBlock renders a system message with herald Note styling.

Types

This section is empty.

Jump to

Keyboard shortcuts

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