Nacho Live UI & Theming Guide
Nacho's GPUI renderer (nacho-gpui) is a pure, domain-agnostic primitive renderer. Every window frame, sidebar, header, chat stream, settings panel, theme, and widget is produced dynamically by plugins calling service.ui (nacho.ui-registry).
You can edit Nacho's UI live in two ways:
- Instant (zero compile): Call
ui_set_theme,ui_set_layout, orui_register_surfaceto tweak colors, layout, or inject declarative UI panels immediately. - Full Stateful WASM Plugin (~1–2s rebuilds): Scaffold a
wasm32-wasip2plugin that registers a dynamicUiProvider(render_ui), handles button/toggle clicks (ui_action), persists state inservice.storage, and hot-swaps live viaplugin_load_file/plugin_load_wasm.
1. Slots & Priority Composition#
nacho.ui-registry renders UiSlot::WindowRoot first, then recursively resolves every UiNode::SlotRef { slot } to all active surfaces/providers targeting UiSlot::Named { name }:
| Slot Name | Where it renders | Behavior |
|---|---|---|
WindowRoot ({"kind":"window_root"}) | Entire window frame (ui-shell, priority 0) | Highest priority wins (replaces whole shell). |
left_rail | Left sidebar (ui-sidebar, priority 10) | Stacked vertically if multiple surfaces target it. |
center_stage | Main workspace (ui-conversation, priority 10) | Stacked vertically if multiple surfaces target it. |
right_drawer | Slide-out workbench drawer (ui-workbench, priority 10) | Shown when drawer is open. |
sidebar_top | Inside expanded sidebar, right below top bar | Additive extension slot (zero-height when empty). |
sidebar_footer | Inside expanded sidebar, above profile dock | Additive extension slot (zero-height when empty). |
header_extra | Inside chat top header bar, before right controls | Additive extension slot (zero-height when empty). |
composer_top | Directly above the chat composer card | Additive extension slot (zero-height when empty). |
status_bar | Thin bottom bar below main workspace | Additive extension slot (zero-height when empty). |
Tip: To add a widget without touching existing panels, target one of the additive slots (header_extra, sidebar_top, sidebar_footer, composer_top, status_bar). To replace an existing UI plugin completely, either hot-swap its plugin ID (nacho.ui.sidebar, nacho.ui.conversation, nacho.ui.shell) or disable it and mount your own provider for left_rail / center_stage / WindowRoot.
2. ThemePatch & LayoutPatch#
ThemePatch (via ui_set_theme or service.ui → "set_theme_patch")#
Higher priority patches overlay lower-priority ones (ui-theme-obsidian uses priority 0; use priority 50+ for overrides). Colors use #RRGGBB or #RRGGBBAA hex strings:
| Field | Example | Meaning |
|---|---|---|
mode | "dark" / "light" | Base palette mode |
canvas | "#0E0F13" | Main window background |
surface | "#14161D" | Elevated surface / cards |
panel | "#12141A" | Sidebar / header panel fill |
hover | "#1E222D" | Interactive hover fill |
code_bg | "#0B0D11" | Code & diff block fill |
user_bubble | "#1D2230" | User message bubble fill |
border | "#262A36" | Subtle divider / border |
text | "#F2F4F8" | Primary foreground text |
muted | "#8E95A5" | Secondary / muted text |
accent | "#FF6B2C" | Primary accent color |
success | "#22C55E" | Success tone |
warning | "#F59E0B" | Warning tone |
danger | "#EF4444" | Danger / error tone |
radius | 10 | Base corner radius in px |
LayoutPatch (via ui_set_layout or service.ui → "set_layout_patch")#
Fields (all optional): show_sidebar (bool), show_inspector (bool), show_status_bar (bool), sidebar_width (u16 px), inspector_width (u16 px), use_system_titlebar (bool).
3. UiNode Primitive Reference#
Every UiNode uses #[serde(tag = "type", rename_all = "snake_case")]:
Layout & Containers#
box:{ "type": "box", "style": NodeStyle, "children": [UiNode] }row/column:{ "type": "row", "gap": 8, "children": [UiNode] }grid:{ "type": "grid", "columns": 2, "gap": 8, "children": [UiNode] }card:{ "type": "card", "title": "Title", "tone": "default", "children": [UiNode] }scroll:{ "type": "scroll", "id": "my-scroll", "style": NodeStyle, "children": [UiNode] }clickable:{ "type": "clickable", "id": "...", "style": NodeStyle, "active": false, "service": "...", "plugin_id": "...", "action_id": "...", "payload": {}, "children": [UiNode] }slot_ref:{ "type": "slot_ref", "slot": "header_extra" }spacer:{ "type": "spacer" }divider:{ "type": "divider" }window_controls:{ "type": "window_controls" }
Content#
text:{ "type": "text", "value": "Hello", "tone": "default", "bold": false }rich_text:{ "type": "rich_text", "value": "Title", "size": "sm", "tone": "default", "bold": true, "mono": false }(size:xs,sm,base,lg,xl)selectable_text:{ "type": "selectable_text", "id": "...", "value": "...", "size": "sm", "tone": "default" }markdown:{ "type": "markdown", "id": "...", "content": "**Bold** andcode" }icon:{ "type": "icon", "name": "sparkles", "size": 14, "tone": "accent" }— supports any Lucide icon name (sparkles,cpu,terminal,zap,flame,heart,clock,sliders-horizontal,palette,wrench,layers,check,x,plus,trash-2,refresh-cw,panel-left,folder,git-branch,bot,users,eye,search,globe,copy,link,settings,plug, etc.) or inline SVG ("svg:<svg ...>...</svg>").badge:{ "type": "badge", "label": "LIVE", "tone": "accent" }status_dot:{ "type": "status_dot", "tone": "success", "size": 8 }key_value:{ "type": "key_value", "key": "Tokens", "value": "12.4k" }progress:{ "type": "progress", "value": 42, "max": 100, "label": "Build" }code:{ "type": "code", "value": "fn main() {}", "language": "rust" }diff_view:{ "type": "diff_view", "path": "src/lib.rs", "additions": 3, "deletions": 1, "lines": [...] }spinner:{ "type": "spinner", "label": "Working...", "size": 18 }avatar:{ "type": "avatar", "asset": "nacho-logo", "size": 20, "rounded": 6 }image_gallery:{ "type": "image_gallery", "id": "...", "images": [...], "thumb_size": 72 }
Controls & Inputs#
action_button:{ "type": "action_button", "id": "my-btn", "label": "Run", "icon": "zap", "tooltip": "Click me", "variant": "secondary", "service": "service.my_plugin", "plugin_id": "community.my-plugin", "action_id": "click", "payload": {}, "field_ids": [] }variant:primary,secondary,ghost,icon,compact_icon,circle_send,circle_stop,danger
toggle_switch:{ "type": "toggle_switch", "id": "...", "label": "Enabled", "checked": true, "service": "...", "plugin_id": "...", "action_id": "...", "payload": {} }list_item:{ "type": "list_item", "id": "...", "icon": "sparkles", "title": "Row", "subtitle": "Sub", "badge": "New", "active": false, "service": "...", "plugin_id": "...", "action_id": "...", "payload": {} }collapsible:{ "type": "collapsible", "id": "...", "title": "Details", "subtitle": null, "trailing": "ok", "icon": "terminal", "tone": "default", "default_open": false, "children": [] }text_input:{ "type": "text_input", "field_id": "my_field", "placeholder": "Type...", "value": "", "masked": false, "service": "...", "plugin_id": "...", "submit_action": "submit" }dropdown:{ "type": "dropdown", "id": "...", "label": "Pick", "variant": "secondary", "placement": "bottom", "items": [...] }
NodeStyle & Enum Values#
axis:"vertical"(default) |"horizontal"bg:"transparent","canvas","panel","card","hover","code","accent","accent_soft","success_soft","warning_soft","danger_soft","user_bubble"border:"all","top","bottom","left","right"align:"start","center","end","stretch"justify:"start","center","end","between"tone:"default","accent","muted","success","warning","danger"animation:{ "kind": "fade_in"|"slide_up"|"slide_down"|"slide_left"|"slide_right"|"scale_in"|"spin"|"pulse", "duration_ms": 180, "easing": "ease_out"|"ease_in_out"|"linear", "repeat": false }- Dimensions:
gap,width,max_width,height,padding_x,padding_y,radius(px u16),flex_grow(u8),center_x(bool),full_height(bool).
4. Recipes#
Recipe A: Instant Live Theme Change (Zero Compile)#
Call ui_set_theme:
{
"mode": "dark",
"canvas": "#0B0E14",
"panel": "#10141D",
"surface": "#151B26",
"accent": "#FF7A18",
"radius": 10,
"priority": 60
}Recipe B: Instant Declarative Widget in Header (Zero Compile)#
Call ui_register_surface:
{
"surface_id": "live.header-pill",
"slot": "header_extra",
"priority": 10,
"root": {
"type": "box",
"style": {
"axis": "horizontal",
"align": "center",
"gap": 6,
"padding_x": 10,
"padding_y": 4,
"radius": 99,
"bg": "accent_soft"
},
"children": [
{ "type": "icon", "name": "flame", "size": 12, "tone": "accent" },
{ "type": "text", "value": "Focus Mode", "tone": "accent", "bold": true }
]
}
}Recipe C: Interactive Stateful WASM UI Widget Plugin#
- Call
plugin_scaffoldwithtemplate: "ui_widget",name: "focus-counter",slot: "sidebar_footer". - Edit the generated
src/lib.rs(implementsrender_uireturningUiSurfaceandui_actionupdatingservice.storageand emittingui.updated). - Compile with
CARGO_TARGET_DIR="$HOME/.local/share/nacho/plugin-target" cargo build --manifest-path ... --target wasm32-wasip2 --release. - Call
plugin_load_filewith the compiled.wasmpath — the live widget appears immediately in Nacho's sidebar and survives restarts!
Recipe D: Live-Editing a Built-In UI Panel#
- Edit e.g.
plugins/ui-sidebarorplugins/ui-conversationin the Nacho repo. - Build its WASM component:
cargo build --manifest-path plugins/ui-sidebar/Cargo.toml --target wasm32-wasip2 --release. - Call
plugin_load_filewithplugins/ui-sidebar/target/wasm32-wasip2/release/nacho_ui_sidebar.wasm. - The kernel hot-swaps
nacho.ui.sidebarlive without restarting Nacho! Callplugin_revertwithplugin_id: "nacho.ui.sidebar"anytime to revert to the bundled build.