ratatui-zonekit
Extensible zone and plugin rendering system for ratatui.
Let plugins own UI zones in your TUI application. Plugins declare what they need (tabs, panels, overlays), and the host decides where and how to render them — safely.
The Problem
Building an extensible TUI means plugins need to render their own content. But giving plugins raw Frame access is unsafe — a misbehaving plugin can draw anywhere, crash the app, or ignore your theme.
The Solution
use ;
use Buffer;
use Rect;
;
The host renders plugins safely:
use ;
use Arc;
let mut registry = new;
let plugin = new;
registry.register;
// In the render loop, for each zone:
// SafeRenderer::render(&plugin, zone_id, &ctx, area, buf);
// If the plugin panics, the zone shows "[plugin crashed]" instead.
Features
Zone Types
| Zone | Description | Example |
|---|---|---|
| Tab | Replaces main content when active | Sprint board, file tree, logs |
| Sidebar | Panel in sidebar column | Plugin status, hooks, config |
| Control | Panel in control column (wide) | Agent controls, actions |
| Overlay | Floating popup on top | Search, picker, modal |
| StatusBar | Single line at bottom | Plugin status text |
Safe Rendering
Every plugin render is wrapped in catch_unwind. A crashing plugin shows an error message in its zone — the rest of the application continues normally.
Theme-Agnostic
Zonekit passes RenderContext.base_style (a plain ratatui::style::Style) to plugins. Works with:
- ratatui-themekit:
ctx.base_style = theme.style_base() - Raw styles:
ctx.base_style = Style::default().bg(Color::Rgb(...)) - Any theme system: just set the Style
Plugins that want richer theme access can depend on a theme crate directly — zonekit doesn't require or prevent this.
Event Routing
Plugins receive events for their zones:
Design Principles
- Request, don't mutate: plugins request zones, the host approves
- Safe delegation:
catch_unwindisolates plugin panics - Theme-agnostic: works with any styling system
- Model B: plugins declare intent, host renders
- Zero opinion on layout: zonekit manages zones, not the overall layout
License
MIT