model

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 71 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultStatusTTL = 5 * time.Second

DefaultStatusTTL is the default time-to-live for status messages.

View Source
const MouseScrollThreshold = 5

MouseScrollThreshold defines how many lines to scroll the chat when a mouse wheel event occurs.

View Source
const TextareaMaxHeight = 6

TextareaMaxHeight is the maximum height of the prompt textarea before scrolling.

View Source
const TextareaMinHeight = 1

TextareaMinHeight is the minimum height of the prompt textarea.

Variables

This section is empty.

Functions

func MouseEventFilter

func MouseEventFilter(m tea.Model, msg tea.Msg) tea.Msg

Types

type Chat

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

Chat represents the chat UI model that handles chat interactions and messages.

func NewChat

func NewChat(com *common.Common) *Chat

NewChat creates a new instance of Chat that handles chat interactions and messages.

func (*Chat) ActivateAskUserQuestion

func (m *Chat) ActivateAskUserQuestion(req agenttools.AskUserRequest) bool

ActivateAskUserQuestion finds the ask_user_question item by tool call ID, activates its interactive question UI, and selects it in the list. Returns true if the item was found and activated.

func (*Chat) Animate

func (m *Chat) Animate(msg anim.StepMsg) tea.Cmd

Animate animates items in the chat list. Only propagates animation messages to visible items to save CPU. When items are not visible, their animation ID is tracked so it can be restarted when they become visible again.

func (*Chat) AppendMessages

func (m *Chat) AppendMessages(msgs ...chat.MessageItem)

AppendMessages appends a new message item to the chat list.

func (*Chat) AtBottom

func (m *Chat) AtBottom() bool

AtBottom returns whether the chat list is currently scrolled to the bottom.

func (*Chat) Blur

func (m *Chat) Blur()

Blur removes the focus state from the chat component.

func (*Chat) ClearMessages

func (m *Chat) ClearMessages()

ClearMessages removes all messages from the chat list.

func (*Chat) ClearMouse

func (m *Chat) ClearMouse()

ClearMouse clears the current mouse interaction state.

func (*Chat) Draw

func (m *Chat) Draw(scr uv.Screen, area uv.Rectangle)

Draw renders the chat UI component to the screen and the given area.

The list's rendered output is cached in decoded form (see chatDrawCache) so that frames with byte-identical content skip the ANSI reparse that uv.StyledString.Draw performs on every call. The cache is keyed by the rendered string and the screen's width method; area / scroll changes do not invalidate it.

func (*Chat) Focus

func (m *Chat) Focus()

Focus sets the focus state of the chat component.

func (*Chat) Follow

func (m *Chat) Follow() bool

Follow returns whether the chat view is in follow mode (auto-scroll to bottom on new messages).

func (*Chat) HandleDelayedClick

func (m *Chat) HandleDelayedClick(msg DelayedClickMsg) bool

HandleDelayedClick handles a delayed single-click action (like expansion). It only executes if the click ID matches (i.e., no double-click occurred) and no text selection was made (drag to select).

func (*Chat) HandleKeyMsg

func (m *Chat) HandleKeyMsg(key tea.KeyMsg) (bool, tea.Cmd)

HandleKeyMsg handles key events for the chat component.

func (*Chat) HandleMouseDown

func (m *Chat) HandleMouseDown(x, y int) (bool, tea.Cmd)

HandleMouseDown handles mouse down events for the chat component. It detects single, double, and triple clicks for text selection. Returns whether the click was handled and an optional command for delayed single-click actions.

func (*Chat) HandleMouseDrag

func (m *Chat) HandleMouseDrag(x, y int) bool

HandleMouseDrag handles mouse drag events for the chat component.

func (*Chat) HandleMouseUp

func (m *Chat) HandleMouseUp(x, y int) bool

HandleMouseUp handles mouse up events for the chat component.

func (*Chat) HasHighlight

func (m *Chat) HasHighlight() bool

HasHighlight returns whether there is currently highlighted content.

func (*Chat) Height

func (m *Chat) Height() int

Height returns the height of the chat view port.

func (*Chat) HighlightContent

func (m *Chat) HighlightContent() string

HighlightContent returns the currently highlighted content based on the mouse selection. It returns an empty string if no content is highlighted.

func (*Chat) InsertMessagesAfter

func (m *Chat) InsertMessagesAfter(afterID string, msgs ...chat.MessageItem)

InsertMessagesAfter inserts message items immediately after the item with afterID. If afterID is not found, items are appended at the end. All index map entries from the insertion point onwards are rebuilt.

func (*Chat) InsertMessagesBefore

func (m *Chat) InsertMessagesBefore(beforeID string, msgs ...chat.MessageItem)

InsertMessagesBefore inserts message items immediately before the item with beforeID. If beforeID is not found, items are appended at the end. All index map entries from the insertion point onwards are rebuilt.

func (*Chat) InvalidateRenderCaches

func (m *Chat) InvalidateRenderCaches()

InvalidateRenderCaches drops cached rendered output on every message item so the next draw re-renders with the current styles.

func (*Chat) Len

func (m *Chat) Len() int

Len returns the number of items in the chat list.

func (*Chat) MessageItem

func (m *Chat) MessageItem(id string) chat.MessageItem

MessageItem returns the message item with the given ID, or nil if not found.

func (*Chat) RemoveMessage

func (m *Chat) RemoveMessage(id string)

RemoveMessage removes a message from the chat list by its ID.

func (*Chat) RestartPausedVisibleAnimations

func (m *Chat) RestartPausedVisibleAnimations() tea.Cmd

RestartPausedVisibleAnimations restarts animations for items that were paused due to being scrolled out of view but are now visible again.

func (*Chat) ScrollBy

func (m *Chat) ScrollBy(lines int)

ScrollBy scrolls the chat view by the given number of line deltas.

func (*Chat) ScrollByAndAnimate

func (m *Chat) ScrollByAndAnimate(lines int) tea.Cmd

ScrollByAndAnimate scrolls the chat view by the given number of line deltas and returns a command to restart any paused animations that are now visible.

func (*Chat) ScrollToBottom

func (m *Chat) ScrollToBottom()

ScrollToBottom scrolls the chat view to the bottom.

func (*Chat) ScrollToBottomAndAnimate

func (m *Chat) ScrollToBottomAndAnimate() tea.Cmd

ScrollToBottomAndAnimate scrolls the chat view to the bottom and returns a command to restart any paused animations that are now visible.

func (*Chat) ScrollToIndex

func (m *Chat) ScrollToIndex(index int)

ScrollToIndex scrolls the chat view to the item at the given index.

func (*Chat) ScrollToSelected

func (m *Chat) ScrollToSelected()

ScrollToSelected scrolls the chat view to the selected item.

func (*Chat) ScrollToSelectedAndAnimate

func (m *Chat) ScrollToSelectedAndAnimate() tea.Cmd

ScrollToSelectedAndAnimate scrolls the chat view to the selected item and returns a command to restart any paused animations that are now visible.

func (*Chat) ScrollToTop

func (m *Chat) ScrollToTop()

ScrollToTop scrolls the chat view to the top.

func (*Chat) ScrollToTopAndAnimate

func (m *Chat) ScrollToTopAndAnimate() tea.Cmd

ScrollToTopAndAnimate scrolls the chat view to the top and returns a command to restart any paused animations that are now visible.

func (*Chat) SelectFirst

func (m *Chat) SelectFirst()

SelectFirst selects the first message in the chat list.

func (*Chat) SelectFirstInView

func (m *Chat) SelectFirstInView()

SelectFirstInView selects the first message currently in view.

func (*Chat) SelectLast

func (m *Chat) SelectLast()

SelectLast selects the last message in the chat list.

func (*Chat) SelectLastInView

func (m *Chat) SelectLastInView()

SelectLastInView selects the last message currently in view.

func (*Chat) SelectNext

func (m *Chat) SelectNext()

SelectNext selects the next message in the chat list.

func (*Chat) SelectPrev

func (m *Chat) SelectPrev()

SelectPrev selects the previous message in the chat list.

func (*Chat) SelectedItemInView

func (m *Chat) SelectedItemInView() bool

SelectedItemInView returns whether the selected item is currently in view.

func (*Chat) SetMessages

func (m *Chat) SetMessages(msgs ...chat.MessageItem)

SetMessages sets the chat messages to the provided list of message items.

func (*Chat) SetSelected

func (m *Chat) SetSelected(index int)

SetSelected sets the selected message index in the chat list.

func (*Chat) SetSize

func (m *Chat) SetSize(width, height int)

SetSize sets the size of the chat view port.

func (*Chat) ToggleExpandedSelectedItem

func (m *Chat) ToggleExpandedSelectedItem()

ToggleExpandedSelectedItem expands the selected message item if it is expandable.

func (*Chat) UpdateNestedToolIDs

func (m *Chat) UpdateNestedToolIDs(containerID string)

UpdateNestedToolIDs updates the ID map for nested tools within a container. Call this after modifying nested tools to ensure animations work correctly.

type DelayedClickMsg

type DelayedClickMsg struct {
	ClickID int
	ItemIdx int
	X, Y    int
}

DelayedClickMsg is sent after the double-click threshold to trigger a single-click action (like expansion) if no double-click occurred.

type KeyMap

type KeyMap struct {
	Editor struct {
		AddFile     key.Binding
		SendMessage key.Binding
		OpenEditor  key.Binding
		Newline     key.Binding
		AddImage    key.Binding
		PasteImage  key.Binding
		MentionFile key.Binding
		Commands    key.Binding

		// Attachments key maps
		AttachmentDeleteMode key.Binding
		Escape               key.Binding
		DeleteAllAttachments key.Binding

		// History navigation
		HistoryPrev key.Binding
		HistoryNext key.Binding
	}

	Chat struct {
		NewSession     key.Binding
		AddAttachment  key.Binding
		Cancel         key.Binding
		Tab            key.Binding
		Details        key.Binding
		TogglePills    key.Binding
		PillLeft       key.Binding
		PillRight      key.Binding
		Down           key.Binding
		Up             key.Binding
		UpDown         key.Binding
		DownOneItem    key.Binding
		UpOneItem      key.Binding
		UpDownOneItem  key.Binding
		PageDown       key.Binding
		PageUp         key.Binding
		HalfPageDown   key.Binding
		HalfPageUp     key.Binding
		Home           key.Binding
		End            key.Binding
		Copy           key.Binding
		ClearHighlight key.Binding
		Expand         key.Binding
	}

	Initialize struct {
		Yes,
		No,
		Enter,
		Switch key.Binding
	}

	// Global key maps
	Quit            key.Binding
	Help            key.Binding
	Commands        key.Binding
	Models          key.Binding
	Providers       key.Binding
	Suspend         key.Binding
	Sessions        key.Binding
	Tab             key.Binding
	ToggleYolo      key.Binding
	CopyLastMessage key.Binding
}

func DefaultKeyMap

func DefaultKeyMap() KeyMap

type LSPInfo

type LSPInfo struct {
	app.LSPClientInfo
	Diagnostics map[protocol.DiagnosticSeverity]int
}

LSPInfo wraps LSP client information with diagnostic counts by severity.

type SessionFile

type SessionFile struct {
	FirstVersion  history.File
	LatestVersion history.File
	Additions     int
	Deletions     int
}

SessionFile tracks the first and latest versions of a file in a session, along with the total additions and deletions.

type Status

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

Status is the status bar and help model.

func NewStatus

func NewStatus(com *common.Common, km help.KeyMap) *Status

NewStatus creates a new status bar and help model.

func (*Status) ClearInfoMsg

func (s *Status) ClearInfoMsg()

ClearInfoMsg clears the status info message.

func (*Status) Draw

func (s *Status) Draw(scr uv.Screen, area uv.Rectangle)

Draw draws the status bar onto the screen. The help/notification row is anchored to the bottom of area rather than the top, so any extra height in the allotted rect (from layout rounding) shows up above the row — where it's invisible against the chat content — instead of as a blank gap below it, at the very bottom of the screen.

func (*Status) SetHideHelp

func (s *Status) SetHideHelp(hideHelp bool)

SetHideHelp sets whether the app is on the onboarding flow.

func (*Status) SetInfoMsg

func (s *Status) SetInfoMsg(msg util.InfoMsg)

SetInfoMsg sets the status info message.

func (*Status) SetWidth

func (s *Status) SetWidth(width int)

SetWidth sets the width of the status bar and help view.

func (*Status) ShowingAll

func (s *Status) ShowingAll() bool

ShowingAll returns whether the full help view is shown.

func (*Status) ToggleHelp

func (s *Status) ToggleHelp()

ToggleHelp toggles the full help view.

type UI

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

UI represents the main user interface model.

func New

func New(com *common.Common, initialSessionID string, continueLast bool) *UI

New creates a new instance of the UI model.

func (*UI) Draw

func (m *UI) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor

Draw implements uv.Drawable and draws the UI model.

func (*UI) FullHelp

func (m *UI) FullHelp() [][]key.Binding

FullHelp implements help.KeyMap.

func (*UI) Init

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

Init initializes the UI model.

func (*UI) ShortHelp

func (m *UI) ShortHelp() []key.Binding

ShortHelp implements help.KeyMap.

func (*UI) Update

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

Update handles updates to the UI model.

func (*UI) View

func (m *UI) View() tea.View

View renders the UI model's view.

Jump to

Keyboard shortcuts

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