reasoningblock

package
v1.107.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 18 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 collapsible reasoning + tool calls block.

func New

func New(id, agentName string, sessionState service.SessionStateReader) *Model

New creates a new reasoning block.

func (*Model) AddToolCall

func (m *Model) AddToolCall(msg *types.Message) tea.Cmd

AddToolCall adds a tool call to the block.

func (*Model) AgentName

func (m *Model) AgentName() string

AgentName returns the agent name for this block.

func (*Model) AppendReasoning

func (m *Model) AppendReasoning(content string)

AppendReasoning appends to the reasoning content. Creates a new reasoning item if the last item was a tool, otherwise appends to the last reasoning item.

func (*Model) AppendToolOutput added in v1.70.2

func (m *Model) AppendToolOutput(toolCallID, output string) bool

AppendToolOutput appends incremental output to a running tool call.

func (*Model) GetSize

func (m *Model) GetSize() (int, int)

GetSize returns the current dimensions.

func (*Model) GetToolFadeProgress

func (m *Model) GetToolFadeProgress(toolCallID string) float64

GetToolFadeProgress returns the fade progress for a tool (0.0 = not fading, 0.0-1.0 = fading).

func (*Model) HasToolCall

func (m *Model) HasToolCall(toolCallID string) bool

HasToolCall returns true if the block contains the given tool call ID.

func (*Model) Height

func (m *Model) Height() int

Height calculates the rendered height.

func (*Model) ID

func (m *Model) ID() string

ID returns the block's unique identifier.

func (*Model) Init

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

Init initializes the component.

func (*Model) IsExpanded

func (m *Model) IsExpanded() bool

IsExpanded returns the current expanded state.

func (*Model) IsHeaderLine

func (m *Model) IsHeaderLine(lineIdx int) bool

IsHeaderLine returns true if the given line index is the header line.

func (*Model) IsToggleLine

func (m *Model) IsToggleLine(lineIdx int) bool

IsToggleLine returns true if clicking this line should toggle the block. Only the header is toggleable.

func (*Model) NeedsTick

func (m *Model) NeedsTick() bool

NeedsTick returns true if this reasoning block requires animation tick updates. This is true when:

  • Any tool is pending/running (needs spinner animation)
  • Any tool is still fading (fadeProgress < 1.0)

The messages list uses this to decide whether to invalidate its render cache on ticks. Use fadeProgress (updated on ticks) to stay consistent with renderCollapsed/hasFadingTools.

func (*Model) Reasoning

func (m *Model) Reasoning() string

Reasoning returns the full reasoning content (concatenated from all reasoning items).

func (*Model) SetExpanded

func (m *Model) SetExpanded(expanded bool)

SetExpanded sets the expanded state directly.

func (*Model) SetReasoning

func (m *Model) SetReasoning(content string)

SetReasoning sets reasoning content (replaces all content items with a single reasoning item).

func (*Model) SetSelected

func (m *Model) SetSelected(selected bool)

SetSelected sets the selected state for visual highlighting.

func (*Model) SetShowAgentBadge added in v1.104.0

func (m *Model) SetShowAgentBadge(show bool)

SetShowAgentBadge controls whether the block renders the agent badge above the Thinking header. The messages list enables it when the block does not visually continue content from the same agent (e.g. reasoning that starts a sub-agent's turn right after a transfer_task), mirroring the sender prefix on standard assistant messages.

func (*Model) SetSize

func (m *Model) SetSize(width, height int) tea.Cmd

SetSize sets the component dimensions.

func (*Model) StopAnimation

func (m *Model) StopAnimation()

StopAnimation stops all animation subscriptions for this reasoning block. This must be called when the block is removed from the UI to avoid leaked animation subscriptions.

func (*Model) Toggle

func (m *Model) Toggle()

Toggle switches between expanded and collapsed state.

func (*Model) ToolCount

func (m *Model) ToolCount() int

ToolCount returns the number of tool calls in this block.

func (*Model) Update

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

Update handles messages.

func (*Model) UpdateToolCall

func (m *Model) UpdateToolCall(toolCallID string, status types.ToolStatus, args string)

UpdateToolCall updates an existing tool call in the block.

func (*Model) UpdateToolResult

func (m *Model) UpdateToolResult(toolCallID, content string, status types.ToolStatus, result *tools.ToolCallResult) tea.Cmd

UpdateToolResult updates tool result for a tool call.

func (*Model) View

func (m *Model) View() string

View renders the block.

Jump to

Keyboard shortcuts

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