block

package
v1.22.3 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package block defines the shared interface for all visual blocks in the message list viewport.

Index

Constants

View Source
const BorderWidth = 1

BorderWidth is the width of the left border on blocks. The messagelist applies a left border; blocks handle their own internal padding.

View Source
const PaddingX = 2

PaddingX is the horizontal padding inside each block.

View Source
const PaddingY = 1

PaddingY is the vertical padding inside elevated blocks (text, tools, user).

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block interface {
	// View renders the block at the width set by SetWidth.
	View() string

	// Height returns the number of lines this block renders.
	Height() int

	// Update handles messages.
	Update(tea.Msg) tea.Cmd

	// SetWidth sets the available width for rendering.
	SetWidth(int)

	// SetFocused sets whether this block is the focused block in the viewport.
	SetFocused(bool)

	// Focused returns whether this block is currently focused.
	Focused() bool

	// Kind returns the block type.
	Kind() Kind
}

Block is the interface for all visual atoms in the message list. Each block is an independently focusable, renderable unit. Width is set via SetWidth before View is called.

type Kind

type Kind int

Kind identifies the type of a block for layout and styling decisions.

const (
	KindUser Kind = iota
	KindAssistantText
	KindThinking
	KindTool
	KindThinkingAnimation
)

type Toggleable

type Toggleable interface {
	Toggle(y int)
}

Toggleable is an optional interface for blocks that can be toggled (e.g. expand/collapse thinking blocks, show/hide tool body). y is the click position relative to the block's top edge. Blocks should only toggle when the click is on the header line.

Jump to

Keyboard shortcuts

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