chat

package
v1.102.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractCoords

func ExtractCoords(msg tea.Msg) (x, y int, ok bool)

ExtractCoords extracts x, y coordinates from a mouse message.

Types

type HitTest

type HitTest struct {
	AgentName string // populated when At() returns TargetSidebarAgent
	// contains filtered or unexported fields
}

HitTest determines what UI element is at the given coordinates. This centralizes all hit-testing logic in one place, making it easier to understand the clickable regions and their priorities.

func NewHitTest

func NewHitTest(page *chatPage) *HitTest

NewHitTest creates a hit tester for the given chat page.

func (*HitTest) At

func (h *HitTest) At(x, y int) MouseTarget

At determines what target is at the given coordinates. It checks regions in priority order (most specific first).

type KeyMap

type KeyMap struct {
	Cancel          key.Binding
	ToggleSplitDiff key.Binding
	ToggleSidebar   key.Binding
}

KeyMap defines key bindings for the chat page

type MouseTarget

type MouseTarget int

MouseTarget represents what the mouse is interacting with.

const (
	TargetNone MouseTarget = iota
	TargetSidebarToggle
	TargetSidebarResizeHandle
	TargetSidebarStar
	TargetSidebarTitle
	TargetSidebarWorkingDir
	TargetSidebarAgent
	TargetSidebarContent
	TargetMessages
)

type Page

type Page interface {
	layout.Model
	layout.Sizeable
	layout.Help
	CompactSession(additionalPrompt string) tea.Cmd
	// SetSessionStarred updates the sidebar star indicator
	SetSessionStarred(starred bool)
	// SetTitleRegenerating sets the title regenerating state on the sidebar
	SetTitleRegenerating(regenerating bool) tea.Cmd
	// ScrollToBottom scrolls the messages viewport to the bottom if auto-scroll is active.
	ScrollToBottom() tea.Cmd
	// IsWorking returns whether the agent is currently working
	IsWorking() bool
	// IsInlineEditing returns true if a past user message is being edited inline
	IsInlineEditing() bool
	// IsSelecting returns true while a text-selection drag is active in the messages panel
	IsSelecting() bool
	// QueueLength returns the number of queued messages
	QueueLength() int
	// FocusMessages gives focus to the messages panel for keyboard scrolling
	FocusMessages() tea.Cmd
	// FocusMessageAt gives focus and selects the message at the given screen coordinates
	FocusMessageAt(x, y int) tea.Cmd
	// BlurMessages removes focus from the messages panel
	BlurMessages()
	// GetSidebarSettings returns the current sidebar display settings
	GetSidebarSettings() SidebarSettings
	// SetSidebarSettings applies sidebar display settings
	SetSidebarSettings(settings SidebarSettings)
	// SetLayoutSettings applies layout customization (sidebar position,
	// section spacing, and section visibility) and relayouts the page.
	SetLayoutSettings(settings msgtypes.LayoutSettings) tea.Cmd
}

Page represents the main chat content area (messages + sidebar). The editor and resize handle are owned by the parent (tui.Model).

func New

func New(ctx context.Context, a *app.App, sessionState *service.SessionState, opts ...PageOption) Page

New creates a new chat page

type PageOption added in v1.41.0

type PageOption func(*chatPage)

PageOption configures a chat page.

func WithCommandParser added in v1.44.0

func WithCommandParser(p *commands.Parser) PageOption

WithCommandParser injects a command parser for handling slash commands in the editor.

func WithHideSidebar added in v1.69.0

func WithHideSidebar() PageOption

WithHideSidebar hides the sidebar without enabling lean mode. The sidebar cannot be re-shown via the TUI.

func WithLayoutSettings added in v1.102.0

func WithLayoutSettings(settings msgtypes.LayoutSettings) PageOption

WithLayoutSettings applies initial layout customization (sidebar position, section spacing, and section visibility).

func WithLeanMode added in v1.41.0

func WithLeanMode() PageOption

WithLeanMode creates a lean chat page with no sidebar.

type SidebarSettings

type SidebarSettings struct {
	Collapsed      bool
	PreferredWidth int
}

SidebarSettings holds the sidebar display settings that should persist across session changes.

Jump to

Keyboard shortcuts

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