Skip to main content

Component · Inputs

Prompt Composer

Flagship agent prompt composer with chips, policy, and completion overlays.

Kind
widget
Input
interactive
Canvas
120×40

Live preview

Loading terminal preview.

Static terminal poster. Choose Run live to start the Rust demo.

Ghosttyprompt-composer/basic
Loading terminal poster…
○ loading posterNo input — rendered state only
Prompt Composer · exact mounted Rust story

01 · Purpose

What it is for

Flagship agent prompt composer with chips, policy, and completion overlays.

Best fit: Inputs · input · widget

02 · Behavior

What the mounted story proves

  1. 01

    PromptComposer

    Representative 120×40 terminal state.

  2. 02

    Passive paint

    No keyboard or pointer action is claimed by this representative story.

  3. 03

    Evidence stays explicit

    3 covered · 8 partial · 5 missing axes.

03 · Implement

Install, then start from exact code

Install

cargo add termrock --git https://github.com/tailrocks/termrock.git --rev 5283c2acf9154d0cfcd37b1ffe821c00faf90ea2

Add TermRock once. Keep domain effects in the host application.

Minimal implementation

Exact Rust setup used by prompt-composer/basic.

Open to load code.

04 · Adapt

Variants and composition

Variants

Use the preview Variant menu when alternate registered stories exist. Each selection mounts a fresh configuration.

Composition

Inputs · input · widget

05 · Reference

API, tokens, accessibility

API

PromptComposerOpen source ↗

Tokens

DesignSystemInspect exact story code for roles and capability projection.

Accessibility

Input contract mountedNo input claim in the representative story.

Contract

Evidence in progress3/23 axes covered

06 · Go deeper

Advanced guidance

Authored implementation guidance

The editor uses a semantic sunken surface with the catalog-owned ❯ prompt mark; the muted information line remains separate from editable content.

Primary human → agent input: grapheme-safe multiline editing, attachments, slash/@/# completion, mode/model chrome, queue while busy — without embedding provider SDKs or clearing the draft when permission/plan overlays take input.

When to use / when not

Use PromptComposerPrefer
Agent / chat / studio prompts—
SQL / log queriesQueryEditor
Simple one-line fieldsTextInput
Plain notesTextArea
Trust gatesPermissionPrompt

Separation (five buckets)

BucketOwns
Text editingTextAreaState, undo/redo, history, selection
TokensComposerChip (file / paste / mention / media)
CompletionCompletionQuery only — host supplies candidates
Presentationcompact / normal / expanded / fullscreen
PolicySubmitPolicy, busy, connection

Focus law

ConcernOwner
Surface input gateHost set_accepts_input (false when overlay tops)
Editor caretTextAreaState inside composer
Chip cursorchip_cursor (local)
Completion candidatesConsumer list + OverlayStack
Draft lifetimeNever cleared by accepts_input alone

Outcomes (selected)

  • Submit / Queued / Cancel / Interrupt
  • Changed / DismissRequest
  • Completion / CompletionClosed / CompletionCommitted
  • ChipRemoved / ChipActivated / AttachRequest
  • ExternalEditor / SelectionCopied
  • ValidationFailed / PresentationChanged / fullscreen

Integrate

PieceHow
CompletionMenuOn Completion open menu; commit → commit_completion
HistoryPickersubmit_history_to_entries(state.submit_history())
KeyboardHelpprompt_composer_help_entries() + live keymap
TokenMeterStatus strip when ContextEstimate.limit > 0
OverlayStackopen_completion_overlay / open_fullscreen_overlay

Intents

default_prompt_composer_intent — bare Enter → Submit, Esc → Cancel. Product chords (Ctrl+Z/Y, history, attach) stay on handle_key.

Non-color

  • ASCII badges via set_ascii_fallback / set_colorless
  • Chip remove × / x
  • Panel Focused only when accepts_input
  • Status always worded (BUSY, offline, queue:N)

Public API

APIWhy
set_accepts_input(false)Permission/plan takeover without clearing draft
set_busy + queue policyEnter enqueues while agent runs
handle_pasteLarge paste → chip
detect_completion / set_completionPure trigger detect + streaming host refresh
commit_completionSlash/@ insert without owning candidates
submit_history / submit_history_to_entriesHistoryPicker bridge
prompt_composer_help_entriesKeyboardHelp seed
Overlay helpersCompletion + fullscreen
Ownership boundary

TermRock owns reusable terminal rendering and interaction state. The host owns domain data, policy, persistence, authorization, and side effects.

Evidence status

3 covered, 8 partial, and 5 missing contract axes. Missing evidence is not a behavior claim.