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:

  1. Instant (zero compile): Call ui_set_theme, ui_set_layout, or ui_register_surface to tweak colors, layout, or inject declarative UI panels immediately.
  2. Full Stateful WASM Plugin (~1–2s rebuilds): Scaffold a wasm32-wasip2 plugin that registers a dynamic UiProvider (render_ui), handles button/toggle clicks (ui_action), persists state in service.storage, and hot-swaps live via plugin_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 NameWhere it rendersBehavior
WindowRoot ({"kind":"window_root"})Entire window frame (ui-shell, priority 0)Highest priority wins (replaces whole shell).
left_railLeft sidebar (ui-sidebar, priority 10)Stacked vertically if multiple surfaces target it.
center_stageMain workspace (ui-conversation, priority 10)Stacked vertically if multiple surfaces target it.
right_drawerSlide-out workbench drawer (ui-workbench, priority 10)Shown when drawer is open.
sidebar_topInside expanded sidebar, right below top barAdditive extension slot (zero-height when empty).
sidebar_footerInside expanded sidebar, above profile dockAdditive extension slot (zero-height when empty).
header_extraInside chat top header bar, before right controlsAdditive extension slot (zero-height when empty).
composer_topDirectly above the chat composer cardAdditive extension slot (zero-height when empty).
status_barThin bottom bar below main workspaceAdditive 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:

FieldExampleMeaning
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
radius10Base 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, "mode": "standard"|"virtualized_top"|"virtualized_tail", "on_near_start": UiActionTarget?, "on_near_end": UiActionTarget?, "children": [UiNode] }
    • Use virtualized_top for large top-down feeds/queues (infinite scroll via on_near_end) and virtualized_tail for chat/log streams that follow the bottom.
  • overlay: { "type": "overlay", "id": "my-modal", "dim_backdrop": true, "dismiss": UiActionTarget?, "children": [UiNode] } — renders in a top-level deferred modal layer with backdrop occlusion and click-outside dismiss.
  • split_pane: { "type": "split_pane", "id": "main-split", "axis": "horizontal"|"vertical", "initial_ratio_pct": 35, "min_first_px": 220, "min_second_px": 320, "first": UiNode, "second": UiNode } — smooth 60fps draggable split panes with per-ID client state.
  • 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, "color": "#1d9bf0", "size_px": 15, "weight": "semibold" } (size: xs, sm, base, lg, xl; optional weight: normal, medium, semibold, bold)
  • selectable_text: { "type": "selectable_text", "id": "...", "value": "...", "size": "sm", "tone": "default" }
  • markdown: { "type": "markdown", "id": "...", "content": "**Bold** and code" }
  • icon: { "type": "icon", "name": "sparkles", "size": 14, "tone": "accent", "color": "#f91880" } — 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>").
  • image: { "type": "image", "id": "hero", "source": { "kind": "url", "url": "https://..." } | { "kind": "asset", "name": "nacho-logo" } | { "kind": "base64", "mime_type": "image/png", "data_base64": "..." }, "width": 48, "height": 48, "radius": 24, "fit": "cover"|"contain"|"fill"|"scale_down", "alt": "Avatar", "lightbox": false } — remote http/https images load asynchronously through a bounded LRU cache (256 entries / 64 MiB).
  • 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).
  • Per-node colors (colors): { "bg": "#15202b", "border": "#38444d", "hover_bg": "#1c2732", "hover_border": "#1d9bf0", "text": "#ffffff", "hover_text": "#1d9bf0" } — optional #RGB/#RRGGBB/#RRGGBBAA overrides on any box or clickable.
  • Positioning & layering:
    • position: { "kind": "relative" } or { "kind": "absolute", "top": -24, "left": 16 } (top/right/bottom/left are optional signed i16 px offsets).
    • overflow: "auto" (default) | "visible" | "hidden" | "scroll_x" | "scroll_y".
    • z_index: optional u16 (renders through GPUI deferred().with_priority(z)).
    • opacity: optional u8 (0..=100).
    • shadow: "none" | "sm" | "md" | "lg".
  • Generic drag-and-drop (on any box or clickable):
    • drag: { "channel": "ticket", "payload": { "id": "INC-42" }, "preview_label": "INC-42" }
    • drop: { "channel": "ticket", "service": "service.my_app", "plugin_id": "community.my-app", "action_id": "move_ticket", "payload": { "lane": "resolved" } } — on drop, dispatches ui_action with { "target": <drop.payload>, "dragged": <drag.payload> }.

Declarative Keyboard Shortcuts (service.ui → register_keybindings)#

Plugins register shortcuts dynamically without touching nacho-gpui:

json
{
  "plugin_id": "community.triage",
  "bindings": [
    {
      "id": "next-ticket",
      "plugin_id": "community.triage",
      "chord": "j",
      "scope": "outside_inputs",
      "service": "service.triage",
      "action_id": "select_next",
      "payload": {},
      "priority": 10
    },
    {
      "id": "command-palette",
      "plugin_id": "community.triage",
      "chord": "cmd+k",
      "scope": "global",
      "service": "service.triage",
      "action_id": "toggle_palette",
      "payload": {},
      "priority": 50
    }
  ]
}
  • scope: "global" fires even when a TextInput/Composer is focused; "outside_inputs" only fires when no text field is focused.
  • cmd normalizes to Command on macOS and Ctrl on Linux/Windows. Higher priority wins; disabling or unloading a plugin automatically removes its bindings.

4. Recipes#

Recipe A: Instant Live Theme Change (Zero Compile)#

Call ui_set_theme:

json
{
  "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:

json
{
  "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#

  1. Call plugin_scaffold with template: "ui_widget", name: "focus-counter", slot: "sidebar_footer".
  2. Edit the generated src/lib.rs (implements render_ui returning UiSurface and ui_action updating service.storage and emitting ui.updated).
  3. Compile with CARGO_TARGET_DIR="$HOME/.local/share/nacho/plugin-target" cargo build --manifest-path ... --target wasm32-wasip2 --release.
  4. Call plugin_load_file with the compiled .wasm path — the live widget appears immediately in Nacho's sidebar and survives restarts!

Recipe D: Live-Editing a Built-In UI Panel#

  1. Edit e.g. plugins/ui-sidebar or plugins/ui-conversation in the Nacho repo.
  2. Build its WASM component: cargo build --manifest-path plugins/ui-sidebar/Cargo.toml --target wasm32-wasip2 --release.
  3. Call plugin_load_file with plugins/ui-sidebar/target/wasm32-wasip2/release/nacho_ui_sidebar.wasm.
  4. The kernel hot-swaps nacho.ui.sidebar live without restarting Nacho! Call plugin_revert with plugin_id: "nacho.ui.sidebar" anytime to revert to the bundled build.

Recipe E: Blank-Canvas Full Application Takeover (Zero Core Edits)#

  1. Disable all 4 default UI plugins (nacho.ui.shell, nacho.ui.sidebar, nacho.ui.conversation, nacho.ui.workbench) via plugin_disable or service.kernel_control.
  2. Mount a standalone WASM plugin that registers a UiSlot::WindowRoot provider (priority: 100), registers its own UiKeybindings, schedules background polls via service.timer, and renders a full custom desktop UI using split_pane, scroll (virtualized_top), image, overlay, colors, position, and drag/drop.
  3. Every default sidebar, header, chat panel, and shortcut vanishes cleanly — Nacho becomes your bespoke native GPUI application.