composer

package
v1.19.1 Latest Latest
Warning

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

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

Documentation

Overview

Package composer implements the TUI's local editor-quality composer model.

Index

Constants

View Source
const (
	// MaxHistory bounds submitted local prompt history.
	MaxHistory = 50
	// MaxStash bounds explicitly stashed drafts.
	MaxStash = 50
	// MaxAutocompleteRows is the binding popup height.
	MaxAutocompleteRows = 10
)

Variables

View Source
var ErrDisabled = errors.New("composer: submission disabled")

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	ID, Name, Path, MIME, Disposition string
	Uploading, Failed                 bool
}

Attachment is a local upload reference and its optional Runtime disposition hint.

type Candidate

type Candidate struct{ Kind, Value, Detail string }

Candidate is one slash-command or structured-reference completion.

type Editor

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

Editor is a value-updated, bounded composer model. It contains interaction state only and never stores Runtime conversation rows.

func New

func New() Editor

New returns an empty composer.

func (Editor) AcceptCompletion

func (e Editor) AcceptCompletion() Editor

AcceptCompletion inserts the selected completion.

func (Editor) Attachments

func (e Editor) Attachments() []Attachment

Attachments returns an isolated copy.

func (Editor) Backspace

func (e Editor) Backspace() Editor

Backspace removes the selection or preceding rune.

func (Editor) BeforeCursor

func (e Editor) BeforeCursor() string

BeforeCursor returns the draft prefix ending at the cursor.

func (Editor) Candidates

func (e Editor) Candidates() []Candidate

Candidates returns the fixed-height autocomplete rows.

func (Editor) CommitSubmission

func (e Editor) CommitSubmission(submission Submission) Editor

CommitSubmission records history and clears the exact prepared payload only after the Runtime accepted it. A changed draft is retained.

func (Editor) Complete

func (e Editor) Complete(all []Candidate, query string) Editor

Complete filters, sorts, and caps slash/reference candidates to ten rows.

func (Editor) Cursor

func (e Editor) Cursor() int

Cursor returns the rune offset.

func (Editor) DisabledReason

func (e Editor) DisabledReason() string

DisabledReason returns the actionable reason submission is unavailable.

func (Editor) History

func (e Editor) History(direction int) Editor

History moves through bounded local prompt history, parking the in-progress working draft at the bottom of the stack so paging back down returns the user to exactly what they were typing. The parked draft is captured the moment browsing begins and is discarded once a real edit mutates the content.

func (Editor) HistoryEntries

func (e Editor) HistoryEntries() []string

HistoryEntries returns an isolated bounded history snapshot for local persistence.

func (Editor) Insert

func (e Editor) Insert(value string) Editor

Insert inserts text at the cursor, replacing a selection. Newlines are retained.

Consecutive single-character non-whitespace insertions at the same position coalesce into one undo group, so ordinary typing does not exhaust the bounded undo budget one rune at a time.

func (Editor) Move

func (e Editor) Move(delta int, selectText bool) Editor

Move moves by rune count and optionally extends selection.

func (Editor) MoveCompletion

func (e Editor) MoveCompletion(delta int) Editor

MoveCompletion wraps autocomplete selection.

func (Editor) MoveLine

func (e Editor) MoveLine(end, selectText bool) Editor

MoveLine moves to a line boundary.

func (Editor) MoveWord

func (e Editor) MoveWord(direction int, selectText bool) Editor

MoveWord moves to the adjacent word boundary.

func (Editor) Paste

func (e Editor) Paste(value string) Editor

Paste applies bracketed-paste content as one undoable edit.

func (Editor) PopStash

func (e Editor) PopStash() Editor

PopStash restores the newest stashed draft.

func (Editor) PrepareSubmission

func (e Editor) PrepareSubmission() (Submission, error)

PrepareSubmission validates and snapshots a turn without mutating the draft.

func (Editor) Redo

func (e Editor) Redo() Editor

Redo reapplies an undone edit.

func (Editor) RestoreLocal

func (e Editor) RestoreLocal(history, stash []string) Editor

RestoreLocal restores bounded interaction-only history and stash state.

func (Editor) Running

func (e Editor) Running() bool

Running reports follow-up queue posture.

func (Editor) SelectAll

func (e Editor) SelectAll() Editor

SelectAll selects the complete draft.

func (Editor) SelectedCandidate

func (e Editor) SelectedCandidate() (Candidate, bool)

SelectedCandidate returns the current autocomplete row.

func (Editor) Selection

func (e Editor) Selection() (int, int, bool)

Selection returns normalized rune offsets and whether a selection exists.

func (Editor) SetAttachments

func (e Editor) SetAttachments(values []Attachment) Editor

SetAttachments replaces local attachment lifecycle state.

func (Editor) SetDisabled

func (e Editor) SetDisabled(disabled bool, reason string) Editor

SetDisabled changes explicit availability and its actionable reason.

func (Editor) SetRunning

func (e Editor) SetRunning(running bool) Editor

SetRunning marks whether submission creates a local follow-up.

func (Editor) SetText

func (e Editor) SetText(value string) Editor

SetText replaces the draft and resets undo traversal.

func (Editor) Stash

func (e Editor) Stash() Editor

Stash stores the current draft and clears it.

func (Editor) StashEntries

func (e Editor) StashEntries() []string

StashEntries returns an isolated bounded stash snapshot for local persistence.

func (Editor) Submit

func (e Editor) Submit() (Editor, string, error)

Submit is retained for local queue callers that commit immediately.

func (Editor) Text

func (e Editor) Text() string

Text returns the complete multiline draft.

func (Editor) Undo

func (e Editor) Undo() Editor

Undo restores the preceding edit snapshot.

type Submission

type Submission struct {
	Text        string
	Attachments []Attachment
}

Submission is an immutable snapshot of one validated draft and its uploaded artifact references. Preparing it never mutates editor state.

Jump to

Keyboard shortcuts

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