composer

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package composer is the multi-line message input plus a slash-command completion list and an @-mention file picker.

Package composer - mention.go: @ workspace-mention menu.

A mention is a workspace entity (file, symbol, session) the user inserts by typing "@" at any token boundary. It shares the same menu scaffold as slash completion but uses different trigger logic and a different candidate list.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Name string // without the leading "/"
	Desc string
}

Command is one completion candidate.

type Mention

type Mention struct {
	Path    string
	Display string
}

Mention is one workspace entity the user may reference via "@". Path is the workspace-relative path that gets inserted into the text. Display is the label shown in the picker (may equal Path).

type Model

type Model struct {
	Theme theme.Theme
	Tier  theme.Tier
	// contains filtered or unexported fields
}

Model wraps bubbles/v2 textarea for the multi-line input, the slash-completion menu, and the @-mention picker.

Dynamic height: the textarea grows from 1 line to maxInputLines as the user types, and shrinks when lines are removed. The frame around the input always occupies a fixed gutter (top and bottom border rows) so the rest of the cockpit layout never reflows (ux-rules.md rule 2.7, 2.8).

func New

func New(t theme.Theme, tier theme.Tier, width int) Model

New returns a focused, empty composer sized to width.

func (Model) AcceptCommonPrefix

func (m Model) AcceptCommonPrefix() (Model, bool)

AcceptCommonPrefix extends the slash-command input by the longest shared prefix.

func (Model) AcceptMention

func (m Model) AcceptMention() Model

AcceptMention replaces the "@query" fragment with the selected mention path.

func (Model) AcceptSelected

func (m Model) AcceptSelected() Model

AcceptSelected replaces the input with the highlighted slash-command.

func (*Model) Blur

func (m *Model) Blur()

Blur blurs the composer input.

func (*Model) Clear

func (m *Model) Clear()

Clear resets the input after a message is sent.

func (*Model) ClickToColumn

func (m *Model) ClickToColumn(x int)

ClickToColumn places the cursor under a click at display column x of the composer's first row. The prompt occupies the first promptWidth columns.

func (Model) Commands

func (m Model) Commands() []Command

Commands returns the active slash-command candidate list.

func (Model) CursorLine

func (m Model) CursorLine() int

CursorLine returns the current line index (0-based) of the cursor.

func (*Model) Focus

func (m *Model) Focus()

Focus focuses the composer input.

func (Model) Height

func (m Model) Height() int

Height is the total row count View draws. It is: border-top(1) + textarea-rows (dynamic 1–maxInputLines) + border-bottom(1) + completion-menu-rows (when open). Below minFramedWidth the border is omitted, so height equals textarea-rows + menu-rows.

func (Model) InputColumnOffset

func (m Model) InputColumnOffset() int

InputColumnOffset is how many display columns the left border and padding put before the prompt. Mouse clicks subtract it to land on the input's own column space.

func (Model) InputRowFromBottom

func (m Model) InputRowFromBottom() int

InputRowFromBottom is how many rows above the screen's status row the top input line sits (for mouse routing). When framed, the bottom border is 1 row above the status row, so the input is 2 above. When bare, the input is 1 above.

func (Model) IsEmpty

func (m Model) IsEmpty() bool

IsEmpty reports whether the input has no text or only whitespace.

func (Model) MentionMenuActive

func (m Model) MentionMenuActive() bool

MentionMenuActive reports whether the @-mention picker is showing.

func (Model) MentionMenuDismiss

func (m Model) MentionMenuDismiss() Model

MentionMenuDismiss closes the @-mention picker without changing the text.

func (Model) MentionMenuNext

func (m Model) MentionMenuNext() Model

MentionMenuNext / MentionMenuPrev move the highlighted row in the mention picker.

func (Model) MentionMenuPrev

func (m Model) MentionMenuPrev() Model

func (Model) Mentions

func (m Model) Mentions() []Mention

Mentions returns the active @-mention candidate list.

func (Model) MenuActive

func (m Model) MenuActive() bool

MenuActive reports whether the slash-command completion menu is showing.

func (*Model) MenuClickRow

func (m *Model) MenuClickRow(row int) bool

MenuClickRow accepts the completion row at rendered index row (0 = top). Returns false when the menu is closed or the row is out of range.

func (Model) MenuDismiss

func (m Model) MenuDismiss() Model

MenuDismiss closes the slash-command menu without changing the text.

func (Model) MenuNext

func (m Model) MenuNext() Model

MenuNext / MenuPrev move the highlighted row in the slash menu.

func (Model) MenuPrev

func (m Model) MenuPrev() Model

func (Model) MenuRows

func (m Model) MenuRows() int

MenuRows returns the row count the active completion or mention menu occupies (0 when closed).

func (*Model) SetCommands

func (m *Model) SetCommands(cmds []Command)

SetCommands sets the slash-completion candidate list.

func (*Model) SetMentions

func (m *Model) SetMentions(mentions []Mention)

SetMentions sets the workspace-entity candidate list for the @-picker. The caller (the conversation screen or demo harness) builds this list; the composer holds no filesystem access.

func (*Model) SetTheme

func (m *Model) SetTheme(t theme.Theme, tier theme.Tier)

SetTheme adopts a new theme and restyles the embedded textarea.

func (*Model) SetValue

func (m *Model) SetValue(s string)

SetValue replaces the input text (e.g. when a cancelled turn is restored).

func (*Model) SetWidth

func (m *Model) SetWidth(width int)

SetWidth resizes the input. The caller passes the full column count.

func (Model) SubmitText

func (m Model) SubmitText() string

SubmitText returns the text to send: strips a trailing backslash-newline escape used for portable multi-line entry (ux-rules.md rule 4.3).

func (Model) Update

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

Update forwards the message to the textarea and refreshes both menus.

func (Model) Value

func (m Model) Value() string

Value returns the current input text (may be multi-line).

func (Model) View

func (m Model) View() string

View renders the active menu above the textarea, which is styled with the subtle card background (RoleBGSubtle) matching the web app, and optionally wrapped in a themed frame. The textarea is the last block, so it never moves as the menu grows or shrinks (ux-rules.md rule 2.8).

Jump to

Keyboard shortcuts

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