OpenTail.TUI
1.1.0
Prefix Reserved
dotnet add package OpenTail.TUI --version 1.1.0
NuGet\Install-Package OpenTail.TUI -Version 1.1.0
<PackageReference Include="OpenTail.TUI" Version="1.1.0" />
<PackageVersion Include="OpenTail.TUI" Version="1.1.0" />
<PackageReference Include="OpenTail.TUI" />
paket add OpenTail.TUI --version 1.1.0
#r "nuget: OpenTail.TUI, 1.1.0"
#:package OpenTail.TUI@1.1.0
#addin nuget:?package=OpenTail.TUI&version=1.1.0
#tool nuget:?package=OpenTail.TUI&version=1.1.0
OpenTail.TUI
A modern, reactive, Elm-architecture terminal UI framework for .NET.
Building Terminal User Interfaces (TUIs) in C# has historically involved fighting with the console state, wrestling with partial screen redraws that cause flickering, or adopting heavy event-driven paradigms that feel out of place for modern, dynamic dashboards.
OpenTail.TUI takes a completely different approach. Heavily inspired by Elm and Rust's ratatui, it brings a strict, unidirectional data flow and a pristine double-buffered rendering engine to the .NET ecosystem. It is designed to let you build rich, 30fps animated terminal dashboards without ever worrying about cursor positions or thread locking.
Installation
dotnet add package OpenTail.TUI
Targets .NET 10 and .NET 11 (net10.0;net11.0) and is AOT-compatible. CI builds and tests on Linux, Windows and macOS, and publishes NativeAOT builds for Linux and Windows.
Features
♻️ Elm Architecture: Strict unidirectional flow. You define your
Init, yourUpdate(which handles messages and returns a new state), and yourView(which renders the state).🎞️ Zero-Flicker Animations: A highly optimized
CellBufferdiffs your UI against the terminal's current state and only writes the changes. It supports smooth 30fps periodic rendering so you can easily implement live timers, spinners, and glowing text.📦 Component-Driven Widgets: Includes a broad set of layout tools, state helpers, and widgets out of the box:
- Layout & Structure:
Box,Panel,Tabs,Collapsible,ModalHelper,Layout/Constraint,SplitPane,Placeholder - Data Visualization:
Table(with virtualized scrolling & dynamic borders),Tree,Sparkline,BarChart,Calendar,MetricGrid - Formatting & Text:
Paragraph(word-wrapping & truncation),MarkdownBlock,CodeBlock,DiffBlock(row tints, folding of unchanged lines, a height cap),ExceptionView,Rule - Inputs & Navigation:
TextInput,PasswordInput,NumberInput,TextArea,FormLayout,CheckboxList,DropdownButton/DropdownOverlay,ToggleSwitch,Slider,Scrollbar,Breadcrumbs,FilePicker,CommandMenu,CommandRegistry,KeyMap,FilterList - Feedback & Overlays:
ToastOverlay(Z-ordered notifications),Skeleton(animated loading placeholders),ProgressBar,Gauge,ActionRequiredPanel - Live/Scrolling Content:
Viewport,LogViewport,LiveLog(auto-following, bottom-anchored scrollback for streaming output),TranscriptView,FindingList,PastePreview,FoldedText(text with an expandable "… +N lines" footer) - Animations & Effects:
Marquee,RainbowText,GlowText,PulseRevealText,Spinner,CountdownLine - Time & Paging:
PaginatorState/PaginatorView,StopwatchState/StopwatchView,TimerState/TimerView(the model owns each state; the view draws it) - Terminal Graphics:
CanvasWidget(Braille rendering),ImageWidget(TrueColor half-block rendering)
See WIDGETS.md for the full catalog, organized by the problem each widget solves rather than alphabetically.
- Layout & Structure:
🎨 Rich Styling: First-class support for
Colorstructures andStylecomponents, gracefully degrading to standard console colors if modern virtual terminal sequences are unsupported.🧵 Thread Safe:
Published<T>gives a background task a lock-free way to hand live progress to the render loop, so a long-running operation never needs a hand-rolled lock around state the view also reads.⌨️ Terminal Input & Output: On Linux and macOS, keys are read as bytes, so a paste arrives as one
PasteMsgand Alt+letter keeps its modifier. Windows delivers a paste as key messages (see Platform notes).TuiMode.Inlinedraws in a block below the cursor,SuspendAsynchands the terminal to an editor and takes it back,FocusRingandFormInputshandle focus and text fields (with optional copy-on-select), andTuiTestHosttests a whole screen without a terminal.🧭 CLI App Primitives: Higher-level helpers cover command palettes, keyboard routing, filtered lists, approval prompts, transcript panes, diagnostic findings, diff blocks, form rows, and terminal capability fallbacks, so screens can share the boring-but-error-prone layout and state math.
Quick Start
using OpenTail.TUI.Runtime;
using OpenTail.TUI.Core;
using OpenTail.TUI.Widgets;
public sealed class MyCounterApp : IModel
{
private int _count;
private double _phase;
private DateTime? _lastTick;
// Kick off a 30fps animation loop as soon as the app starts.
public Cmd? Init() => Cmds.Tick(TimeSpan.FromMilliseconds(33), t => new TickMsg(t));
public (IModel Model, Cmd? Cmd) Update(IMsg msg)
{
switch (msg)
{
case KeyMsg { Key: ConsoleKey.Spacebar }:
_count++;
return (this, null);
case KeyMsg { Key: ConsoleKey.Escape }:
return (this, Cmds.Quit());
case TickMsg tick:
if (_lastTick is { } last)
_phase += (tick.Time - last).TotalSeconds;
_lastTick = tick.Time;
return (this, Cmds.Tick(TimeSpan.FromMilliseconds(33), t => new TickMsg(t)));
default:
return (this, null);
}
}
public void View(Rect area, CellBuffer buffer)
{
buffer.Clear();
var boxArea = new Rect(area.X + 2, area.Y + 2, 40, 10);
new Box("Hello TUI", Theme.Dark.Primary, Theme.Dark.Text).Render(boxArea, buffer);
var inner = Box.Inner(boxArea);
// A glowing text animation that pulses based on elapsed time (_phase).
new GlowText($"Count: {_count}", _phase, Theme.Dark.Muted.Foreground!.Value, Theme.Dark.Accent.Foreground!.Value, speed: 3.0)
.Render(new Rect(inner.X + 2, inner.Y + 2, inner.Width - 4, 1), buffer);
buffer.SetText(inner.X + 2, inner.Y + 4, "Press SPACE to increment, ESC to quit", Theme.Dark.Muted, inner.Width - 4);
}
}
Cmds.Tick delivers the library's TickMsg, so the app does not declare one.
Run it with TuiApp, which owns the terminal, the render loop, and input handling:
await new TuiApp(new MyCounterApp()).RunAsync();
Want to see more widgets in action first? Clone the repo and run the bundled demo:
dotnet run --project Demo
Architecture
IModel: The single source of truth for your screen's state.Update(IMsg msg): The only place state changes occur. When a key is pressed, a background task finishes, or a timer ticks, it yields anIMsg. The framework passes it here, you return the new state and optionally aCmdto execute a side-effect.View(Rect area, CellBuffer buffer): A pure function. It takes the bounds of the terminal and a blank canvas, and you instruct your widgets to draw themselves. The framework handles diffing this buffer against the real terminal window to apply changes instantly with zero tearing.
Widgets themselves are stateless renderers — construct one fresh per frame with whatever data/style it needs. Where a widget needs state across frames (a text cursor, a scroll offset), that state is a separate readonly record struct your model owns and mutates in Update (e.g. TextInputState, ViewportState, LiveLogState), which is what keeps Update itself unit-testable without a real terminal.
Building Real CLI Screens
The lower-level widgets are deliberately small, but common CLI application patterns have shared helpers too:
var keyMap = new KeyMap([
new KeyBinding("refresh", ConsoleKey.R, "R", "Refresh", 'r'),
new KeyBinding("quit", ConsoleKey.Escape, "Esc", "Quit")
]);
var matches = FilterList.Apply(files, filter.Query, file => file.Name, FilterMatchMode.Fuzzy);
var split = SplitPane.Compute(area, splitState, SplitPaneOrientation.Horizontal, minFirst: 24, minSecond: 40);
new ShortcutBar(keyMap.ToShortcuts(), Theme.Dark).Render(shortcutArea, buffer);
new ListView(matches.Select(x => x.Item.Name).ToArray(), filter.SelectedIndex, Theme.Dark.Text, Theme.Dark.Highlight)
.Render(split.First, buffer);
new TranscriptView(messages, transcriptScroll, Theme.Dark).Render(split.Second, buffer);
These helpers do not own your application policy. They centralize the terminal-specific bookkeeping: selection clamping, hit-testing, display-width truncation, pane geometry, command lookup, paste previewing, and safe fallback behavior.
Platform notes and known limits
Each item says how it was checked.
- Windows paste arrives as key messages, one per character. This is the current design. Virtual-terminal input would deliver a paste as one message (the paste markers were measured in Windows Terminal), but switching would also change how keys and the mouse are read. It has not been switched.
- Linux and macOS paste arrives as one
PasteMsg. Checked in a Linux pseudo-terminal, in Windows Terminal running WSL, and in a macOS pseudo-terminal in CI. - Mouse is read in full-screen mode on Windows only. Linux and macOS do not read it yet, and inline mode turns it off, because a mouse position is a screen position the inline block cannot map.
- Clipboard. On Windows,
TerminalClipboardreads and writes the system clipboard. Elsewhere it writes with OSC 52, which the terminal must allow, and it is off over SSH unless enabled withnew ClipboardPolicy(Osc52Mode.Enabled). Reading works on Windows only, soCmds.ReadClipboardAsPasteproduces no paste on Linux and macOS. OSC 52 has not been checked in a real terminal emulator yet. - Ctrl+C arrives as a key message on Windows, Linux and macOS. The library never quits by itself, so the app decides, for example copying when text is selected and quitting otherwise.
- Inline mode draws its block below the cursor and keeps earlier output above it. Checked in Windows Terminal and in WSL. Redraw on resize and the cursor position after exit are not checked yet.
- Text areas have no selection yet, so copy-on-select does not apply to
TextArea. - Known issue: on Windows, some box-drawing and symbol characters can show as
?in the console output. The cause is known and the fix is pending; see CHANGELOG.md.
License
Apache 2.0 — see the LICENSE file for details.
Inspiration
OpenTail.TUI has been informed by studying excellent open-source CLI and agent-terminal projects, including Codex, Aider, Goose, Open Code Review, Qwen Code, and Wave Terminal. Those projects were used as inspiration for interaction patterns, usability ideas, and problem framing; OpenTail.TUI's implementation, public API names, and code structure are independently expressed.
OpenTail.TUI was originally built to power FlightDeck, a real-time testing dashboard for agentic AI workflows, before being extracted as a standalone package.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. net11.0 is compatible. |
-
net10.0
- No dependencies.
-
net11.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.