Skip to main content

Pattern · Composites

Query Editor

Application recipe composed from public TermRock building blocks; domain state and effects remain host-owned.

Kind
paint
Input
interactive
Canvas
120×40

Live preview

Loading terminal preview.

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

Ghosttyquery-editor/basic
Loading terminal poster…
○ loading posterNo input — rendered state only
Query Editor · exact mounted Rust story

01 · Purpose

What it is for

Application recipe composed from public TermRock building blocks; domain state and effects remain host-owned.

Best fit: Composites · composite · CodeFrame · TextArea

02 · Behavior

What the mounted story proves

  1. 01

    QueryEditor

    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

    0 covered · 9 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 query-editor/basic.

Open to load code.

04 · Adapt

Variants and composition

Public building blocks

CodeFrame · TextArea

Supporting types

CodeFrameLine · Diagnostic · DiagnosticSeverity · HelpEntry · HistoryEntry · SourceLabel · SourceRange · SpanStyle · StatefulWidget · TextCursor · TextWrap

05 · Reference

API, tokens, accessibility

API

QueryEditorOpen source ↗

Tokens

DesignSystemInspect exact story code for roles and capability projection.

Accessibility

Input contract mountedNo input claim in the representative story.

Contract

Evidence in progress0/23 axes covered

06 · Go deeper

Advanced guidance

Authored implementation guidance

Multiline query workbench for SQL, logs, search DSLs, and structured queries. TermRock owns draft editing, focus zones, run/stop chrome, parameters, and typed requests. Host owns language services, execution, formatting, and result grids.

When to use / when not

Use QueryEditorPrefer
DB / log / metrics query pane—
Agent chat promptPromptComposer
Plain notes / formsTextArea
Result table onlyDataTable (future ResultGrid)

Ownership

ConcernOwner
Draft, cursor, selection, undoTextAreaState inside QueryEditorState
Completer, parser, formatter, executorHost
Result rows / types / pagingHost DataTable (or ResultGrid) in slots.results
Persist history / saved queriesHost via outcomes

Draft survival

Moving focus to Results / Diagnostics / Parameters never clears the draft or cursor. Only accepts_input and focus change. Same rule for completion overlays and help modals.

Outcomes (requests)

  • RunRequested · StopRequested
  • FormatRequested · SaveQueryRequested · OpenSavedQueries
  • OpenHistory · HistoryApplied
  • CompletionRequested · CompletionCommitted · CompletionClosed
  • JumpToDiagnostic · ParameterEditRequested
  • OpenKeyboardHelp · FocusChanged · ModeChanged · fullscreen

Integrate

PieceHow
CompletionMenuOn CompletionRequested, host opens menu; commit → insert
CodeFrame / DiagnosticPass diagnostics to paint; jump via labels
KeyboardHelpSeed with query_editor_help_entries() + live keymap
HistoryPickerOpenHistory / saved_queries_to_history
DataTablePaint into state.slots.results after workbench render

Keys

KeyAction
Ctrl+R / Ctrl+EnterRun
Ctrl+Shift+SStop
Ctrl+F · Ctrl+S · Ctrl+HFormat · save · history
Ctrl+SpaceCompletion
Ctrl+J · Ctrl+1..4Focus zones
Ctrl+M · Ctrl+Shift+FMode · fullscreen
Ctrl+?Help
Ownership boundary

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

Evidence status

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