render

package
v0.85.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 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 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. This creates a one-off Typography instance with the given label so callers can use any title (e.g. "Help", "Warning") without changing the shared typography's default "Info" label.

func ErrorBlock

func ErrorBlock(errorMsg string, 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 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) 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.

func SystemBlock

func SystemBlock(content string, 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