Kite Architecture
This document serves as the high-level architectural overview for Kite (v2) based on our design sessions.
1. Core Principles
Section titled “1. Core Principles”- Terminal UI Framework: A modern, DOM-like terminal UI framework for Go. It brings web-like development paradigms to the terminal environment.
- In-memory operation: No external database/storage requirements.
- Clear Separation of Concerns: Strict package isolation between DOM, Style, Layout, Paint, and Render layers to maintain an efficient rendering pipeline.
- Performance-Oriented: The pipeline targets 60FPS on the main thread, with expensive or asynchronous operations handled in a concurrent worker pool managed by a global
terminal.Scheduler. Promises seamlessly bridge background work back to the main thread via microtasks.
2. Rendering Pipeline Overview
Section titled “2. Rendering Pipeline Overview”The framework operates via a central nervous system called the Engine (/engine). The engine acts purely as a coordinator, running a continuous frame loop that orchestrates a unified pipeline:
- Input Buffering & Coalescing: Collect raw input events from the backend into a buffer. Just before the frame renders, drain the buffer and coalesce high-frequency events (e.g., aggregate wheel deltas, squash mouse moves) into semantic events, dispatching them through the DOM.
- Task Draining: The engine coordinates with the
terminal.Schedulerto drain macrotasks (budget-capped) and microtasks (drained completely) on the main thread. This executes user events, effect hooks, and resolved Promise callbacks. - Synchronize Phase (Pre-Layout): Walk the logical DOM and project structural changes into the render tree. The Engine uses an internal map (
map[dom.Node]render.Object) to link the independent logical and physical trees. It flags dirty layout and style nodes. - Style Phase: Traverse the render tree to resolve inherited and explicit styles into
Computedvalues. - Layout Phase: Traverse the dirty nodes, executing LayoutNG-inspired algorithms (Block, Flex, Inline) to produce immutable physical
Fragmenttrees. - Paint Phase: Draw the resulting
Fragmenttrees onto the framebuffer via absolute coordinates and clipping. - Commit: Push the framebuffer surface to the terminal via the decoupling backend (
/backend).
3. Subsystems
Section titled “3. Subsystems”3.1. DOM (Logical Tree)
Section titled “3.1. DOM (Logical Tree)”- Strict Isolation: The logical DOM has zero knowledge of the physical rendering pipeline. It does not contain any references to
render.Object. - View Proxy: To query physical properties like
GetBoundingClientRectorComputedStylewithout coupling, the DOM defines adom.Viewinterface. Theengine.Engineimplements this interface and injects itself into thedom.Document. Elements proxy layout queries up to this View. - Terminal Context: The DOM has no knowledge of OS clipboards or render loops. It exposes a
Terminal()accessor that returns aterminal.Terminalinterface, which is implemented by the Engine to bridge OS capabilities (Clipboard, Window frames, Hardware Cursor, Scheduler). - Hardware Cursor: The hardware cursor is managed via a hybrid, style-driven model. Elements declare their cursor preferences (shape, color, blink) via a
Cursorstruct in theirstyle.Style. By default, the Engine automatically translates a collapseddom.Selectioninto physical coordinates and applies the focused element’s cursor style. The legacycursor.Providerinterface has been removed. - Responsibility: Maintains the structural tree and interactivity states (
Focusable,Disabled). - Core Entities:
Document,Element,TextNode. - Adoption & Identity: Uses a self back-pointer (
outer) set during the attach walk. Ensuresevent.Target()andGetElementByID()return the outermost user-visible wrapper (useful for custom widgets). - Events: Responsible for the Capture -> Target -> Bubble event propagation model. Uses $O(1)$ checks for connectivity (
IsConnected()). - Selection API: The Document maintains a global
dom.Selectionstate containing logicaldom.Rangeboundaries acrossdom.Textnodes. This acts as the single source of truth for user text highlights. - UA Shadow Subtree: Replaced and compound elements (e.g.,
<input>,<textarea>, future<checkbox>,<radio>,<select>) own a closed UA subtree via an internaluaRootfield ondom.Element(ADR-009). The subtree is invisible to public traversal (Children(),GetElementByID()), invisible to event dispatch, and never focusable; engine phases (Sync/Style/Layout/Paint) walk it as if it were a regular child. Identity retargeting reuses the existingouterback-pointer soevent.Target()always resolves to the host. Text-based controls locally manage their ownSelectionStartandSelectionEnd, projecting this to the document’s global selection only for visual rendering, protecting the shadow tree. - Scroll Model: Every
dom.ElementexposesScroll(),ScrollTo(x, y),ScrollBy(dx, dy)and firesevent.EventScrollon mutation (ADR-012). Scroll state is held in a lazy*scrollStatepointer allocated only when the element is observed to need scrolling. An element is a scroll container when its computedOverflowXorOverflowYisScrollorAuto; the framework provides a defaultScrollablewheel handler for those containers (overridable per-element). Programmatic scroll on non-containers stores state and fires events but has no visual effect, matching browser semantics.
3.2. Style Engine (/style)
Section titled “3.2. Style Engine (/style)”- Responsibility: Parses and resolves CSS-like styling definitions.
- Paradigm: Uses an
Optional[T]pattern for sparse definitions instyle.Style(differentiating unset fields from zero-values). - Resolution: The
Resolverapplies inheritance, default application, and merges everything into a rawstyle.Computedstructure (no Optionals) that is consumed directly by the layout and render phases. - Cascade Origins: Three layers contribute property values per element in increasing precedence:
DefaultStyle()(UA defaults, author-overridable),RawStyle()(author input), andIntrinsicStyle()(UA-intrinsic, NOT author-overridable; ADR-010). Inherited values from the parent’sComputedsit below all three. Internally the intrinsic layer is taggedOriginUserAgentfor spec alignment. - Overflow Model:
OverflowXandOverflowYare per-axis properties acceptingVisible,Hidden,Clip,Scroll, orAuto. A fluent.Overflow(v)shorthand onstyle.Stylesets both axes at once for ergonomic cases while preserving asymmetric expressiveness (e.g., horizontal-only scroll).ScrollandAutomake the element a scroll container (ADR-012);HiddenandClipclip without scrolling (ADR-011). - Isolation: Has no dependencies on other Kitex packages.
3.3. Layout Engine (/layout)
Section titled “3.3. Layout Engine (/layout)”- Responsibility: High-performance layout computations.
- Design: Inspired by Blink’s LayoutNG. It computes layout in terms of logical geometry (agnostic of reading direction or physical coordinates initially) and returns immutable
Fragmenttrees. - Constraint Propagation:
ConstraintSpacecarries two spatial references that flow from parent to child (ADR-018):ContainingSpace: The parent’s border-box dimensions. All percentage-based sizes resolve against this (e.g.,width: 50%→ContainingSpace.Width * 50 / 100), consistent with the strict border-box model (ADR-017).ContainerSpace: The parent’s content-box dimensions (border-box minus border and padding). This is the available space for children before individual child margins are subtracted.- A shared
BuildChildSpacefunction centralizes child constraint generation, eliminating duplicated decoration math across formatting contexts.
- Contexts:
- Block Formatting Context (BFC): Stacks elements vertically.
- Flex Formatting Context (FFC): Lays out elements in one-dimensional rows or columns (supports growing, shrinking, alignment).
- Grid Formatting Context (GFC): Lays out elements in a two-dimensional grid using a 3-phase matrix builder (Track Sizing, Auto-Placement, Layout). Supports explicit sizing, fractional (
fr) distributions, andgaps. - Inline Formatting Context (IFC): Lays out text and atomic inlines horizontally, wrapping them into line boxes. Uses a flat representation of
InlineItems.
3.4. Render Pipeline (/render)
Section titled “3.4. Render Pipeline (/render)”- Engine Mapping: The physical Render Tree is completely detached from the logical DOM Tree. The
engine.Enginemaintains the mapping between them using a dictionary structure.render.Objectmaintains a strongly-typed back-pointer to its sourcedom.Node. - Replaced & Compound Elements: Form controls and other compound widgets compose their visuals as a closed UA Shadow Subtree on the logical element (ADR-009). They get a plain
render.Boxand rely on standard formatting contexts — no per-widget render object or layout algorithm. Text-based form controls (<input>,<textarea>) share a commontextControlBase. Toggle controls (<checkbox>,<radio>) manage hidden text nodes for their glyphs. Buttons (<button>) handle click semantics and provide visual feedback for active/pressed states. Complex composites like<select>combine a shadow trigger button with dynamic, out-of-flowelement.Overlaypopups and temporaryfocus.Scopetrapping. - Selection Resolution: Implements a decoupled “Push Model” for text selection. The active
dom.Selectionis resolved against the layout fragment tree to produce an independent list of physicalpaint.Rects before the paint phase begins. This avoids $O(N)$ DOM lookups during text rasterization and ensures immutable layout fragments remain perfectly cacheable. - Responsibility: The visual bridge between the logical DOM and physical layout.
- Stateless Styling: The Render Engine stores the resolved
style.Computedstate, but delegates the reading of declarative input styles (RawStyle,DefaultStyle,IntrinsicStyle) directly to the associateddom.Node. - Node Mirroring: It strictly mirrors the DOM structure using a unified
render.Boxorrender.Text(no explicit block/flex types here; the engine delegates algorithms at layout time based onComputedStyle.Display). - Dirty Tracking: Carries lifecycle synchronization flags (
NeedsSync,DirtyStyle,DirtyLayout) without doing actual math calculations itself.
3.5. Event System (/event)
Section titled “3.5. Event System (/event)”- Responsibility: Dispatching semantic interactions and input routing.
- Event Coalescing: The engine decouples raw input arrival from DOM dispatch. Incoming events are buffered and coalesced per-frame (e.g., squashing intermediate mouse movements, summing fast scroll wheel deltas) to guarantee UI resilience under high-frequency inputs (ADR-015).
- Phases: Advanced dispatcher supporting Capture, Target, and Bubble phases.
- Synthesizer: Translates raw terminal input (e.g., from Charmbracelet’s
ultraviolet) into semantic events (like key combinations or clicks). Supports multi-MIME rich data (e.g., images) by delegating complex handshakes to terminal extensions.
3.6. Focus & Spatial Navigation (/focus)
Section titled “3.6. Focus & Spatial Navigation (/focus)”- Responsibility: Managing interaction focus state.
- Operation: Focus state operates strictly on the logical
dom.Nodetree, utilizingdom.Focusableanddom.Disableableinterfaces. - Spatial Navigation: Queries physical geometry by accessing the physical
Fragment()from the logical node’sRenderObject().
3.7. Paint & Backend (/paint & /backend)
Section titled “3.7. Paint & Backend (/paint & /backend)”- Responsibility: Terminal output decoupling and drawing.
- Paint: Interfaces with a logical framebuffer. Handles operations like clipping, filling cells, and applying formatted text.
- Overflow Clipping: During fragment recursion the paint engine composes
Surface.Clip()calls to enforceOverflowX/Yin {Hidden,Clip,Scroll,Auto} (ADR-011). The fragment’s own background and border paint unclipped at the parent’s level; descendants paint onto a clipped sub-surface restricted to the content box. Nested overflow boxes compose via rect intersection. - Scroll Translation: For scroll containers (computed overflow =
ScrollorAuto), paint reads the element’s raw scroll offset, clamps it on read to[0, contentSize - viewportSize], and translates descendant origins by the negative clamped offset (ADR-012). Element state stores raw author intent and is never mutated by paint. - Scrollbar Rendering: If an element is a scroll container and its
ComputedStyle.Scrollbar.X/Yis true, the layout phase reserves a 1-column/row gutter. The paint phase automatically computes the viewport-to-content ratio and draws a customizable scrollbar track and thumb in that reserved gutter. - Selection Masking: The paint context accepts a pre-calculated list of selection bounding rectangles. When rendering cells, it acts as an overlay mask, inverting or restyling colors for any cell that intersects a selection rect.
- Border Post-Processing: To automatically form correct Unicode junctions (e.g.,
┼,├) without manual coordinate math in layout, thePaintEngineruns a global $O(W \times H)$ post-processing pass over the framebuffer. Every cell explicitly tagged as a border is resolved against its cardinal neighbors. Junction merging for overlapping borders of varying weights is handled via a strict “Heaviest Style Wins” precedence rule (using an explicitBorderStyleenum stored per-cell). The resolver runs once on the root surface only; it must never be invoked on a clipped sub-surface. - Backend: Decouples Kite from the actual terminal emulator. The
backendpackage is completely agnostic of internal types (likepaint.Cellorstyle.Cursor). Implementations likeultravioletandmockconsume a genericbackend.Bufferpopulated by theEngineat the end of each frame. This strict isolation allows backends to focus purely on I/O and protocol translation. - Inline Mode & Scrollback Insertion (
InsertAbove): Configured viaengine.Options{Inline: true}. When enabled, the engine configuresRenderViewwithSetIsFixedBlockSize(false), enabling auto-height layout constrained to the terminal viewport width rather than forcing fullscreen height. The pipeline dynamically adjusts the rendered frame buffer height per frame without entering the terminal alternate screen buffer (altscreen), ensuring terminal cursor positioning is relative and scrollback is preserved. To support terminal scrollback logging above the active inline frame,Engine.InsertAbove(dom.Node)lays out, paints, and resolves borders for a detached DOM node subtree and forwards the rendered*backend.BuffertoBackend.InsertAbove(*Buffer), permanently committing it into the terminal scrollback buffer directly above the live inline viewport.
3.8. Developer Tools (/devtools)
Section titled “3.8. Developer Tools (/devtools)”- Responsibility: Provide utilities to inspect, test, and debug Kite applications without bloating the core runtime.
- Inspector (
/devtools/inspector): A lightweight HTTP server utilizing Server-Sent Events (SSE) to stream the live logical DOM tree and computed styles. The frontend is built with Preact and Vite (ADR-020), compiled into a single embedded HTML file to provide a rich, component-based UI without requiring Node.js for end-users. It supports a genericExtensioninterface allowing external packages (likekitex) to inject additional inspection tabs and payloads out-of-band. - Profiler: A built-in performance tracing system using a Hybrid Architecture (ADR-019). The core engine delegates phases to a
Pipelineinterface wrapped in a Decorator to capture high-level phase times cleanly. For deep-tree granular timings (like specific layout algorithms), an inlineableTraceContextstruct is injected into contexts (e.g.,LayoutContext), ensuring zero allocations when disabled. DevTools features an internal Flamechart/Waterfall view and exports data in the Chrome Trace Event Format (JSON). Startup tracing can be activated viaengine.WithProfiler(true). - X-Ray Mode: An optional rendering flag built into the core
paintengine but toggled via devtools. Overlays colored bounding boxes (margin, padding, content) for visual layout debugging. - Test Environment (
/testenv): A headless testing harness that wraps the existingbackend/mock. Provides high-level APIs for structural DOM assertions (GetNodeByID), simulated input routing (Type,Click), layout verification, and golden/visual snapshot testing (producing HTML or ANSI dumps).
3.9. Overlay System
Section titled “3.9. Overlay System”- Responsibility: Management and rendering of out-of-flow components like dropdowns, tooltips, and modal dialogs.
- Document Integration: The
dom.Documentmaintains an explicit list of overlays viaShowOverlayandHideOverlay. Overlays are sorted byzIndex. - Anchored Positioning:
element.Overlayuses a custom layout algorithm that queries the physical bounds of anAnchorelement (viaGetBoundingClientRect) to position itself. - Smart Flipping: If an overlay would overflow the viewport, the layout engine automatically flips it to the opposite side or chooses the “best fit” placement with the most available space.
- Modal Dialogs:
element.Dialogprovides a full-screen modal container that automatically traps focus usingfocus.Scope.
3.10. Animation System (/animation)
Section titled “3.10. Animation System (/animation)”- Responsibility: Providing smooth, time-based property interpolation.
- Paradigm: The framework uses an explicit, imperative animation architecture (ADR-021) rather than declarative CSS transitions. This keeps the Style and Layout engines pure and stateless.
- Engine Integration: Developers register generic
Tween[T]objects with theEngine. The engine ticks active animations at the start of its frame loop. If animations are active, the engine automatically invokesRequestFrame()to maintain a continuous 60FPS loop, returning to an idle sleep state once all animations complete.
3.11. Reactive UI Framework (/extras/kitex)
Section titled “3.11. Reactive UI Framework (/extras/kitex)”- Responsibility: Provide a high-level, React-like Virtual DOM architecture for complex application state management.
- Components: Custom components are defined as pure functions strongly typed with Go Generics (
react.FC<P>). The framework wraps them in lightweight VDOM boundary nodes. - State Management: Components declare reactive state using hook functions (e.g.,
kitex.UseState). The engine manages an internal execution stack to persist hook context implicitly, removing the need to pass context variables through rendering closures. - Refs: The framework provides
kitex.UseRefandkitex.CreateRefhooks, backed by a genericRef[T]type, to safely retain mutable references (such as real DOM nodes) across renders without triggering state updates. - Memoization: Like the React Compiler,
kitexutilizes an automatic, Just-In-Time (JIT) memoization architecture. Components calculate their structural complexity bottom-up during allocation. When a component’s complexity exceeds a safe threshold, the engine automatically memoizes it, bypassing futureRenderFnexecutions and reconciliation passes by performing a depth-limited reflection check (deepEqualProps) on properties. An explicitUseMemohook is also available. - Side Effects (ADR-026): The framework provides dual-variant effect hooks —
UseEffect/UseEffectCleanupfor post-commit effects andUseLayoutEffect/UseLayoutEffectCleanupfor synchronous post-reconciliation effects. Layout effects fire synchronously afterreconcile()within theOnComponentDirtycallback. Regular effects are deferred viaengine.PostMacroand flushed at the start of the next frame’s Task Draining phase, matching React’sflushPassiveEffectsguarantee. AflushPendingEffects()call at the top ofOnComponentDirtyensures effects from frame N complete before frame N+1’s reconciliation. - Reducers:
UseReducer[S, A](reducer, initial)provides a(state, action) → statepattern for complex state machines, wrappingUseStateinternally with a dispatch function that applies the reducer. - Callback Memoization:
UseCallback[T](callback, deps)stabilizes function references across re-renders, delegating toUseMemointernally. - Context System (ADR-026): A React-style context API for sharing state without prop-drilling.
CreateContext[T](defaultValue)produces a typedContext[T]identity.ProviderNode[T]pushes acontextEntryonto the context’s internal stack during render;UseContext[T]reads from the stack on first mount (O(1)), then from a stored provider reference on re-renders (O(1)). Providers maintain subscriber sets and mark consumers dirty on value change, bypassing automatic memoization via a!oldComp.IsDirty()guard inUpdate(). ThelastSeenValueon hook state prevents duplicate re-renders for consumers already processed during normal reconciliation. - Component Lifecycle —
Destroy(): When the reconciler removes a component (unmount, tag mismatch), it callsDestroy()on theComponentNodebefore DOM removal.Destroy()runs all effect cleanups, unsubscribes from context providers, and recursively destroys nested component subtrees. - Reconciliation: On state change, the component re-executes. A VDOM diffing engine compares the new lightweight tree against the previous frame and generates a minimal set of imperative patches (mutations) to the underlying logical
dom.Nodetree. - VDOM Primitives: The
kitexpackage defines lightweight, fully-typed VDOM representations (e.g.,kitex.Button(kitex.ButtonProps{...})) that map 1:1 to the real, heavy DOM nodes in the rootelementpackage. The reconciler translates these VDOM nodes into imperative updates on the underlyingelementnodes. - Convenience Hooks (
/extras/kitex/hooks): Terminal-specific hooks built on the core primitives:UseFocus(ref): Subscribes to focus/blur events and returns a reactive boolean.UseKeyboard(handler, deps): Registers scoped keyboard handlers.UseTitle(initialTitle): Sets and updates the terminal window title.UseBell(): Triggers the terminal hardware bell.UseWindowFocus(): Subscribes to terminal window focus events and returns a reactive boolean.UseProgressBar(): Updates the terminal window’s native progress bar. These demonstrate composability and are shipped as a separate sub-package.
3.12. Global State Management (/extras/kites)
Section titled “3.12. Global State Management (/extras/kites)”- Responsibility: Provide a thread-safe, external state management solution (“Kite Store”) decoupled from the VDOM.
- Architecture: Follows a Zustand/Redux-style “External Store” model. Global state is instantiated via
kites.Create[T](initialState), wrapping the state in async.RWMutex. This allows concurrent mutations from background goroutines or network handlers without data races. - Kitex Integration: Components subscribe to state slices using the
kites.Use(store, selector)hook. The selector function extracts a specific slice of the global state. - Render Optimization: The
kites.Usehook leverages Go’scomparableconstraint on the selector’s return type. When the global store updates, the hook evaluates the new slice; it only triggers a component re-render if the new slice differs from the previous one, providing automatic performance bailouts for unaffected components.
3.13. Navigation & Routing (/extras/flight)
Section titled “3.13. Navigation & Routing (/extras/flight)”- Responsibility: Provide a stack-based navigation system for switching between full-screen views in
kitexapplications. - Architecture: Bypasses web-style URL/Path routing in favor of a “Stack Navigator” paradigm, which is more natural for TUIs (drill-down and pop). The
flight.Stackcomponent maintains a history slice of pushed routes. - Type Safety: Routes are defined as an empty interface (
flight.Route). Developers define routes using standard Go structs (e.g.,type ProfileRoute struct { ID string }), ensuring strict type safety for route parameters without resorting to maps or generic dictionaries. TheRenderRoutefunction resolves the component via a standard Go type switch. - Explicit Interaction: The framework does not magically hijack keys (like
Esc) for navigation. Developers explicitly bind navigation actions usingkitexkeyboard hooks. - Focus Isolation: The
flight.Stackautomatically wraps the currently active route in anelement.FocusScope. This guarantees that when a new screen is pushed, keyboard navigation (Tabbing) cannot accidentally interact with buttons on the hidden screens beneath it.
3.14. Async Data Fetching & Caching (/extras/wind)
Section titled “3.14. Async Data Fetching & Caching (/extras/wind)”- Responsibility: Provide robust async data fetching, caching, and background refetching for Kitex components.
- Architecture: Inspired by React Query. Uses a
QueryClientprovided via Kitex Context. - Type-Safe Keys: Uses Go’s generic
comparableconstraint for cache keys (K comparable), ensuring strict type safety and zero-reflection performance when matching cache entries. - Hooks:
UseQuery: Manages the async state machine (IsLoading,Data,Error) and dedupes concurrent requests for the same key.UseMutation: Executes side-effects (e.g., POST/DELETE) and injects aMutationContextinto itsOnSuccess/OnErrorcallbacks. This context provides direct access to theClientso developers can callClient.InvalidateQueries(exactKey)without requiring additional hook lookups.
3.15. Form Architecture & Validation (/extras/form)
Section titled “3.15. Form Architecture & Validation (/extras/form)”- Responsibility: Provide a unified pipeline from raw terminal input up to strongly-typed, validated Go structs.
- Low-Level DOM (
element.Form): The core engine implements a<form>primitive. Form controls (<input>,<checkbox>) implementdom.FormControlto exposeName()andValue(). Theelement.Formintercepts “Enter” keystrokes andtype="submit"button clicks to implicitly gather all control values and dispatch a singleevent.SubmitEventcarrying amap[string]anypayload. - Kitex Integration: Developers use
kitex.Form(kitex.FormProps{...})to wrap their controls declaratively. - High-Level Validation (
extras/form): Inspired by React Hook Form, this package provides theform.Use[T]API. It takes the rawmap[string]anyfrom thekitex.Form, securely maps it into the user’s defined generic structT, runs synchronous validation logic, and manages the meta-state (IsSubmitting,Errors,IsValid) during async submission.
3.16. Clipboard System
Section titled “3.16. Clipboard System”- Responsibility: Managing global text selection and synchronizing data with the system clipboard.
- Multi-MIME Data: The
event.ClipboardEventfollows aDataTransfer-like model, carrying a map of payloads keyed by MIME type (e.g.,text/plain,image/png). This allows components to negotiate their preferred data format during a paste. - Global Integration: The
dom.Documentacts as a central coordinator. If a focused element does not handle a copy/paste event, the Document falls back to the globaldom.Selectionto ensure seamless system-wide synchronization. - System Sync: Uses the OSC 52 escape sequence in supported backends to securely read from and write to the system clipboard across local and remote (SSH) sessions without external dependencies.
- Backend Architecture: The backend provides native support for terminal-specific protocols (like OSC 52 or Kitty) through a dedicated
Clipboard()interface.
3.17. Inline CLI Mode (/extras/trail)
Section titled “3.17. Inline CLI Mode (/extras/trail)”- Responsibility: Provide an Ink-inspired, component-driven inline CLI runtime for building interactive command-line tools without full-screen takeover.
- Application Lifecycle (
trail.New/trail.Run): Initializes an engine instance in inline mode (Inline: true), mounts the root component to the engine document, provides anAppHandlecontext, and executes the event loop. Automatic Ctrl+C termination is enabled by default viatrail.WithCtrlCExit(true). <Static>Scrollback Flushing: Ink-compatible<Static>component (trail.Static[T]) enables append-only items (e.g. completed task entries, log messages) to be permanently flushed to terminal scrollback. Internally, a component ref (emitted) tracks the index of already-flushed items. On layout effect (UseLayoutEffect), newly appended items are rendered into temporary DOM containers and flushed above viaapp.InsertAbove(node). BecauseStaticreturnsnilin the active VDOM, it occupies zero space in the live inline frame.- Layout Primitives: Convenient re-exports and constructors for inline terminal layouts:
Box(BoxProps, ...Node): Container element supporting flexbox layouts.Text(string): Text node constructor.Span(SpanProps, ...Node): Inline text styling and color spans.Newline(count ...int): Adds line breaks with controlled box heights.Spacer(): Flexible expanding box (flex: 1) for pushing elements apart.
- Hooks: Built-in hooks tailored for inline CLI interactions:
UseApp(): ReturnsAppHandleexposingExit(err error),InsertAbove(node Node), andPrintln(text string).UseInput(handler): Binds raw and semantic keyboard listeners (withevent.KeyEventsupport).- Seamless interoperability with core
kitexhooks (UseState,UseRef,UseEffect,UseLayoutEffect,UseInterval,UseTimeout,UseViewportSize,UseFocus).