input

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package input owns the v2 TUI's bottom textarea: prompt composition, paste compaction, and history navigation.

The Input is a tea.Model-ish wrapper around bubbles/textarea that adds three behaviors not in the underlying widget:

  1. Bracketed-paste compaction. Multi-line or >200-char pastes are stored in an internal buffer and replaced with a compact placeholder so the input box stays readable. On submit, placeholders are swapped back to raw content (agent-facing) or to bracketed paste chips (view-facing).

  2. Prompt history. Submitted prompts are pushed to a history stack; Up/Down walks back/forward through them. The user's in-progress draft is preserved when nav engages and restored when nav exits past the newest entry.

  3. Submission. The App routes Enter through Input.Submit, which returns the two prompt forms (for-agent / for-view) plus a boolean indicating "this is a real submission, not an empty line". The App decides what to do next — start a Run, intercept a slash command, or queue mid-run.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Input

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

Input is the textarea wrapper. Construct with New; mount in the App's layout slot. The App calls Update to feed it tea.Msg values and View to render it.

func New

func New(th *theme.Theme) *Input

New constructs an Input with v1-matching styling. The caller is responsible for calling SetWidth on every WindowSizeMsg and Focus when the input is the active focus.

func (*Input) BlinkCmd

func (i *Input) BlinkCmd() tea.Cmd

Cursor's blink command — re-exposed so the App can include it in its initial tea.Batch.

func (*Input) Blur

func (i *Input) Blur()

func (*Input) Empty

func (i *Input) Empty() bool

Empty reports whether the (trimmed) input is blank.

func (*Input) Focus

func (i *Input) Focus() tea.Cmd

Focus / Blur — Wrap the textarea's focus methods so the App's focus stack can drive them.

func (*Input) Reset

func (i *Input) Reset()

Reset clears the textarea and the paste buffer. Called after a successful submission.

func (*Input) SetValue

func (i *Input) SetValue(s string)

SetValue replaces the textarea content. Used by history nav.

func (*Input) SetWidth

func (i *Input) SetWidth(w int)

SetWidth updates the textarea's visible column count. Called on every WindowSizeMsg by the App.

func (*Input) Update

func (i *Input) Update(msg tea.Msg) tea.Cmd

Update routes a tea.Msg through the input. Returns a tea.Cmd that the App should chain. Special keys (Enter on non-empty, Up/Down for history, bracketed-paste) are consumed here; every other key falls through to the textarea.

Returning a tea.Cmd that emits a SubmitMsg is how submission signals up to the App — keeps the App's Update loop the single place that owns "start a run" semantics.

func (*Input) Value

func (i *Input) Value() string

Value returns the current raw text in the textarea, paste placeholders included.

func (*Input) View

func (i *Input) View() string

View renders the textarea wrapped in the input border. M5 may pull the border out into the layout layer; for M4 it stays here.

type SubmitMsg

type SubmitMsg struct {
	// ForAgent is the prompt the agent sees: raw paste content
	// inlined, no markers. Byte-for-byte what the user composed.
	ForAgent string
	// ForView is the transcript-facing form: paste blocks wrapped
	// in visible chips so the scrollback shows where each paste
	// starts and ends.
	ForView string
}

SubmitMsg is dispatched as a tea.Cmd return when the user presses Enter with non-empty content. The App handles this message: routes slash commands, queues mid-run prompts, or starts a fresh Run.

Jump to

Keyboard shortcuts

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