MCPcopy Index your code
hub / github.com/Dicklesworthstone/frankentui

github.com/Dicklesworthstone/frankentui @v0.5.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.5.0 ↗ · + Follow
51,045 symbols 221,342 edges 958 files 5,884 documented · 12%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

FrankenTUI (ftui)

███████╗██████╗  █████╗ ███╗   ██╗██╗  ██╗███████╗███╗   ██╗████████╗██╗   ██╗██╗
██╔════╝██╔══██╗██╔══██╗████╗  ██║██║ ██╔╝██╔════╝████╗  ██║╚══██╔══╝██║   ██║██║
█████╗  ██████╔╝███████║██╔██╗ ██║█████╔╝ █████╗  ██╔██╗ ██║   ██║   ██║   ██║██║
██╔══╝  ██╔══██╗██╔══██║██║╚██╗██║██╔═██╗ ██╔══╝  ██║╚██╗██║   ██║   ██║   ██║██║
██║     ██║  ██║██║  ██║██║ ╚████║██║  ██╗███████╗██║ ╚████║   ██║   ╚██████╔╝██║
╚═╝     ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═══╝╚═╝  ╚═╝╚══════╝╚═╝  ╚═══╝   ╚═╝    ╚═════╝ ╚═╝

FrankenTUI - Minimal, high-performance terminal UI kernel

High‑performance terminal UI kernel -- 850K+ lines of Rust across 20 crates, 80+ widget/stateful-widget implementations, 46 interactive demo screens, a Bayesian intelligence layer, resizable pane workspaces, and in-tree web/WASM backends -- focused on correctness, determinism, and clean architecture.

status rust license crates widgets screens

Quick Run (from source)

The primary way to see what the system can do is the demo showcase: cargo run -p ftui-demo-showcase (not the harness).

# Download source with curl (no installer yet)
curl -fsSL https://codeload.github.com/Dicklesworthstone/frankentui/tar.gz/main | tar -xz
cd frankentui-main

# Run the demo showcase (primary way to see what FrankenTUI can do)
cargo run -p ftui-demo-showcase

Or clone with git:

git clone https://github.com/Dicklesworthstone/frankentui.git
cd frankentui
cargo run -p ftui-demo-showcase

TL;DR

The Problem: Most TUI stacks make it easy to draw widgets, but hard to build correct, flicker‑free, inline UIs with strict terminal cleanup and deterministic rendering.

The Solution: FrankenTUI is a kernel‑level TUI foundation with a disciplined runtime, diff‑based renderer, and inline‑mode support that preserves scrollback while keeping UI chrome stable.

Why Use FrankenTUI?

Feature What It Does Example
Inline mode Stable UI at top/bottom while logs scroll above ScreenMode::Inline { ui_height: 10 } in the runtime
Deterministic rendering Buffer → Diff → Presenter → ANSI, no hidden I/O BufferDiff::compute(&prev, &next)
One‑writer rule Serializes output for correctness TerminalWriter owns all stdout writes
RAII cleanup Terminal state restored even on panic TerminalSession in ftui-core
Composable crates Layout, text, style, runtime, widgets Add only what you need
80+ widgets Block, Paragraph, Table, Input, Tree, Modal, Command Palette, etc. Direct Widget / StatefulWidget implementations across ftui-widgets
Pane workspaces Drag‑to‑resize, docking, magnetic snap, inertial throw, undo/redo PaneTree + PaneDragResizeMachine in ftui-layout
Web/WASM backend Same Rust core renders in browser-oriented environments In-tree ftui-web + ftui-showcase-wasm
Bayesian intelligence Statistical diff strategy, resize coalescing, capability detection BOCPD, VOI, conformal prediction, e‑processes
Shadow‑run validation Prove rendering determinism across runtime migrations ShadowRun::compare() in ftui-harness
46 demo screens Dashboard, visual effects, widget gallery, layout lab, and more cargo run -p ftui-demo-showcase

Getting Started (Library Consumers)

If you want to embed FrankenTUI in your own Rust app (not just run the demo), start here: docs/getting-started.md.

For web embedding into frankentui_website (Next.js + bun), see the Embedding In frankentui_website section in docs/getting-started.md. It includes:

  • in-tree build/check guidance for ftui-web and ftui-showcase-wasm,
  • a clear note that FrankenTermWeb is currently adjacent/out-of-tree from this checkout,
  • runtime initialization guidance for FrankenTermWeb once that bundle is available,
  • and explicit no-xterm.js guidance.

Quick Example

# Demo showcase (primary)
cargo run -p ftui-demo-showcase

# Pick a specific demo view
FTUI_HARNESS_VIEW=dashboard cargo run -p ftui-demo-showcase
FTUI_HARNESS_VIEW=visual_effects cargo run -p ftui-demo-showcase

Demo Showcase Gallery (46 Screens)

The demo showcase (cargo run -p ftui-demo-showcase) ships 46 interactive screens, each demonstrating a different subsystem:

Category Screens What They Show
Overview dashboard, widget_gallery, advanced_features Full-system demos with animated panels, sparklines, markdown streaming
Layout layout_lab, layout_inspector, intrinsic_sizing, responsive_demo Flex/Grid solvers, pane workspaces, constraint visualization
Text shakespeare, markdown_rich_text, markdown_live_editor, advanced_text_editor Rope editor, syntax highlighting, streaming markdown
Data table_theme_gallery, data_viz, virtualized_search, log_search Themed tables, charts, Fenwick-backed virtualization
Input forms_input, form_validation, command_palette_lab, mouse_playground Bayesian fuzzy search, gesture recognition, focus management
Visual FX visual_effects, theme_studio, mermaid_showcase, mermaid_mega_showcase Gray-Scott reaction-diffusion, metaballs, Clifford attractors, fractal zooms
System terminal_capabilities, performance, performance_hud, determinism_lab Capability probing, frame budgets, conformal risk gating
Diagnostics explainability_cockpit, voi_overlay, snapshot_player, accessibility_panel Evidence ledgers, VOI sampling visualization, a11y tree
Workflow file_browser, kanban_board, async_tasks, notifications, drag_drop File picker, task boards, notification toasts, drag handles
Advanced inline_mode_story, hyperlink_playground, i18n_demo, macro_recorder, quake Inline scrollback, OSC 8 links, locale switching, event recording
3D / Code 3d_data, code_explorer, widget_builder, action_timeline 3D data views, AST browsing, widget composition, timeline aggregation

Each screen is also a snapshot test target. BLESS=1 cargo test -p ftui-demo-showcase updates baselines.


Use Cases

  • Inline UI for CLI tools where logs must keep scrolling.
  • Full-screen dashboards that must never flicker.
  • Deterministic rendering harnesses for terminal regressions.
  • Libraries that want a strict “kernel” but their own widget layer.

Non-Goals

  • Not a full batteries‑included app framework (by design).
  • Not a drop‑in replacement for existing widget libraries.
  • Not a “best effort” renderer; correctness beats convenience.

Minimal API Example

use ftui_core::event::Event;
use ftui_core::geometry::Rect;
use ftui_render::frame::Frame;
use ftui_runtime::{App, Cmd, Model, ScreenMode};
use ftui_widgets::paragraph::Paragraph;

struct TickApp {
    ticks: u64,
}

#[derive(Debug, Clone)]
enum Msg {
    Tick,
    Quit,
}

impl From<Event> for Msg {
    fn from(e: Event) -> Self {
        match e {
            Event::Key(k) if k.is_char('q') => Msg::Quit,
            _ => Msg::Tick,
        }
    }
}

impl Model for TickApp {
    type Message = Msg;

    fn update(&mut self, msg: Msg) -> Cmd<Msg> {
        match msg {
            Msg::Tick => {
                self.ticks += 1;
                Cmd::none()
            }
            Msg::Quit => Cmd::quit(),
        }
    }

    fn view(&self, frame: &mut Frame) {
        let text = format!("Ticks: {}  (press 'q' to quit)", self.ticks);
        let area = Rect::new(0, 0, frame.width(), 1);
        Paragraph::new(text).render(area, frame);
    }
}

fn main() -> std::io::Result<()> {
    App::new(TickApp { ticks: 0 })
        .screen_mode(ScreenMode::Inline { ui_height: 1 })
        .run()
}

Design Philosophy

  1. Correctness over cleverness. Predictable terminal state is non-negotiable.
  2. Deterministic output. Buffer diffs and explicit presentation over ad-hoc writes.
  3. Inline first. Preserve scrollback while keeping chrome stable.
  4. Layered architecture. Core, render, runtime, widgets; no cyclic dependencies.
  5. Zero-surprise teardown. RAII cleanup, even when apps crash.

Workspace Overview (20 Crates)

Core Architecture

Crate Purpose Status
ftui Public facade + prelude Implemented
ftui-core Terminal lifecycle, events, capabilities, animation, input parsing, gestures Implemented
ftui-render Buffer, diff, ANSI presenter, frame, grapheme pool, budget system Implemented
ftui-style Style + theme system with CSS‑like cascading Implemented
ftui-text Spans, segments, rope editor, cursor, BiDi, shaping, normalization Implemented
ftui-layout Flex + Grid solvers, pane workspace system (9K+ lines), e‑graph optimizer Implemented
ftui-runtime Elm/Bubbletea runtime, effect system, subscriptions, rollout policy, telemetry schema (13K+ line program.rs) Implemented
ftui-widgets 80+ direct Widget / StatefulWidget implementations across the library Implemented
ftui-extras Feature‑gated add‑ons, VFX rasterizer (opt‑level=3) Implemented

Backend & Platform

Crate Purpose Status
ftui-backend Backend abstraction layer Implemented
ftui-tty TTY terminal backend Implemented
ftui-web Web/WASM adapter with pointer/touch parity Implemented
ftui-showcase-wasm WASM build of the demo showcase Implemented

Testing & Verification

Crate Purpose Status
ftui-harness Test harness, shadow‑run comparison, benchmark gate, rollout scorecard, determinism fixtures Implemented
ftui-pty PTY‑based test utilities Implemented
ftui-demo-showcase 46 interactive demo screens + snapshot tests Implemented
doctor_frankentui Integrated TUI capture, seeding, suite reporting, diagnostics, and coverage gating Implemented

Supporting

Crate Purpose Status
ftui-a11y Accessibility tree and node structures Implemented
ftui-i18n Internationalization support Implemented
ftui-simd SIMD acceleration Reserved

How FrankenTUI Compares

Feature FrankenTUI Ratatui tui-rs (legacy) Raw crossterm
Inline mode w/ scrollback ✅ First‑class ⚠️ App‑specific ⚠️ App‑specific ❌ Manual
Deterministic buffer diff ✅ Kernel‑level
One‑writer rule ✅ Enforced ⚠️ App‑specific ⚠️ App‑specific
RAII teardown ✅ TerminalSession ⚠️ App‑specific ⚠️ App‑specific
Pane workspaces (drag/resize/dock) ✅ Built‑in
Web/WASM backend ✅ Shared Rust core
Bayesian diff strategy ✅ Adaptive ❌ Fixed ❌ Fixed ❌ N/A
Shadow‑run validation harness ✅ Built‑in
Snapshot/time‑travel harness ✅ Built‑in
Widget count 80+ direct impls ~20 ~12 0
Demo screens 46 ~5 ~5 0

When to use FrankenTUI: - You want inline + scrollback without flicker. - You care about deterministic rendering and teardown guarantees. - You need resizable pane workspaces with drag, dock, and undo. - You want a single Rust codebase targeting both terminal and web. - You prefer a kernel you can build your own UI framework on top of.

When FrankenTUI might not be ideal: - You need a stable public API today (FrankenTUI is evolving fast). - You want a fully opinionated application framework rather than a kernel.


Installation

Quick Install (Source Tarball)

curl -fsSL https://codeload.github.com/Dicklesworthstone/frankentui/tar.gz/main | tar -xz
cd frankentui-main
cargo build --release

Git Clone

git clone https://github.com/Dicklesworthstone/frankentui.git
cd frankentui
cargo build --release

Use as a Workspace Dependency

# Cargo.toml
[dependencies]
ftui = { path = "../frankentui/crates/ftui" }

Crates.io (Published So Far)

Currently available on crates.io: - ftui-core - ftui-layout - ftui-i18n

The remaining crates are in the publish queue (render/runtime/widgets/etc.). Until those land, prefer workspace path dependencies for the full stack.


Quick Start

  1. Install Rust nightly (required by rust-toolchain.toml).
  2. Clone the repo and build: bash git clone https://github.com/Dicklesworthstone/frankentui.git cd frankentui cargo build
  3. Run the demo showcase (primary way to see the system): bash cargo run -p ftui-demo-showcase

Telemetry (Optional)

Telemetry is opt‑in. Enable the telemetry feature on ftui-runtime and set OTEL env vars (for example, OTEL_EXPORTER_OTLP_ENDPOINT) to export spans.

When the feature is off, telemetry code and dependencies are excluded. When the feature is on but env vars are unset, overhead is a single startup check.

See docs/telemetry.md for integration patterns and trace‑parent attachment.


Feature Flags

Crate Feature What It Enables
ftui-core tracing Structured spans for terminal lifecycle
ftui-core tracing-json JSON output via tracing-subscriber
`ft

Extension points exported contracts — how you extend this code

Model (Interface)
The Model trait defines application state and behavior. Implementations define how the application responds to events a [114 …
crates/ftui-runtime/src/program.rs
Accessible (Interface)
Trait for widgets that provide accessibility metadata. Implementing this trait is **opt-in**. Widgets that do not imple [11 …
crates/ftui-a11y/src/lib.rs
Diff (Interface)
Compute a structural diff between two values of the same type. The diff type `Self::Diff` captures what changed between [7 …
crates/ftui-core/src/generic_diff.rs
Tokenizer (Interface)
Core tokenizer abstraction. Implementors produce tokens for a single line given the state from the previous line. The d [6 …
crates/ftui-extras/src/syntax.rs
Screen (Interface)
Trait for demo screens. Each screen manages its own state, handles its own messages, and renders into the content area [44 …
crates/ftui-demo-showcase/src/screens/mod.rs
BackendEventSource (Interface)
Event source abstraction: terminal size queries, feature toggles, and event I/O. This is the input half of the backend [11 …
crates/ftui-backend/src/lib.rs
MeasurableWidget (Interface)
A widget that can report its intrinsic dimensions. Implement this trait for widgets whose size depends on their content [11 …
crates/ftui-widgets/src/measurable.rs
Decomposable (Interface)
Hierarchical Delta Debugging (HDD) for structured inputs. Recursively removes parts of structured input while a failure [4 …
crates/ftui-harness/src/hdd.rs

Core symbols most depended-on inside this repo

default
called by 6233
crates/ftui-style/src/theme.rs
clone
called by 3038
crates/ftui-style/src/stylesheet.rs
map
called by 2944
crates/ftui-core/src/keybinding.rs
iter
called by 2854
crates/ftui-text/src/text.rs
push
called by 2017
crates/ftui-text/src/segment.rs
join
called by 1443
crates/doctor_frankentui/src/abstract_interpretation.rs
fg
called by 1269
crates/ftui-style/src/style.rs
filter
called by 1110
crates/ftui-widgets/src/table.rs

Shape

Function 33,347
Method 12,431
Class 4,027
Enum 1,173
Interface 67

Languages

Rust100%
Python1%
C++1%
TypeScript1%

Modules by API surface

crates/ftui-runtime/src/program.rs718 symbols
crates/ftui-extras/src/mermaid.rs537 symbols
crates/ftui-extras/src/text_effects.rs496 symbols
crates/ftui-layout/src/pane.rs420 symbols
crates/ftui-extras/src/mermaid_render.rs387 symbols
crates/ftui-extras/src/mermaid_layout.rs357 symbols
crates/ftui-demo-showcase/src/screens/mermaid_mega_showcase.rs345 symbols
crates/ftui-demo-showcase/tests/screen_snapshots.rs302 symbols
crates/ftui-runtime/src/terminal_writer.rs284 symbols
crates/ftui-demo-showcase/src/app.rs277 symbols
crates/ftui-extras/src/syntax.rs273 symbols
crates/ftui-demo-showcase/src/screens/mermaid_showcase.rs265 symbols

Datastores touched

mydbDatabase · 1 repos

For agents

$ claude mcp add frankentui \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact