round

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: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model represents a complete user→assistant exchange, potentially with multiple turns if tools are involved. A round starts with explicit user input and ends when the assistant stops (no more tool calls). It is a fixed-height component - height is determined by content.

func New

func New(
	theme styles.Theme,
	conversationID domain.ConversationID,
	accountID domain.AccountID,
	userMessageID domain.MessageID,
	input msgs.UserSubmittedInput,
	width int,
	db sqlite.DB,
	chatClient chatclient.Client,
	toolRegistry *chattools.Registry,
	scope log.Scope,
) *Model

New creates a new round from explicit user input.

func (*Model) Blocks

func (m *Model) Blocks() []block.Block

Blocks returns all visual blocks from all turns in this round. The thinking animation is appended at the end while the round is active.

func (*Model) Cancel

func (m *Model) Cancel()

Cancel stops all in-flight turns and marks the round cancelled.

func (*Model) Duration

func (m *Model) Duration() time.Duration

Duration returns the elapsed time for this round.

func (*Model) Err added in v1.14.0

func (m *Model) Err() error

Err returns the error that caused the round to fail, or nil.

func (*Model) HasAssistantContent added in v1.14.0

func (m *Model) HasAssistantContent() bool

HasAssistantContent returns true if any turn has assistant blocks.

func (*Model) HasTurn added in v1.22.3

func (m *Model) HasTurn(turnID domain.MessageID) bool

HasTurn reports whether this round owns turnID.

func (*Model) ID

func (m *Model) ID() domain.MessageID

ID returns the round's ID (first user message ID).

func (*Model) Init

func (m *Model) Init() tea.Cmd

Init starts the thinking animation.

func (*Model) IsActive added in v1.12.0

func (m *Model) IsActive() bool

IsActive returns true if the round is in-flight (active or awaiting next turn).

func (*Model) LastTurnMessageIDs added in v1.14.0

func (m *Model) LastTurnMessageIDs() []domain.MessageID

LastTurnMessageIDs returns the message IDs that should be deleted on failure. For turn 1: the user message ID. For turn 2+: the tool result message ID (current turn) + the previous turn's assistant message ID.

func (*Model) SetWidth

func (m *Model) SetWidth(width int)

SetWidth sets the width for all turns.

func (*Model) StartStream

func (m *Model) StartStream(messages []domain.Message, context []domain.ContextEntity) tea.Cmd

StartStream begins streaming for the first turn.

func (*Model) State

func (m *Model) State() State

State returns the round's current state.

func (*Model) Update

func (m *Model) Update(msg tea.Msg) tea.Cmd

Update handles messages.

type State

type State int

State represents the current state of a round.

const (
	StateActive           State = iota
	StateAwaitingNextTurn       // async DB work in progress before next turn
	StateComplete
	StateCancelled
	StateFailed
)

Directories

Path Synopsis
assistant/blocks/tools/action
Package action provides a generic tool UI model for simple tools that accumulate input, execute, and show status — with no custom body.
Package action provides a generic tool UI model for simple tools that accumulate input, execute, and show status — with no custom body.
assistant/blocks/tools/show
Package show renders entity cards inside tool chrome.
Package show renders entity cards inside tool chrome.

Jump to

Keyboard shortcuts

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