# Custom sidebars: vibe-code your own cmux sidebar cmux lets you build your own sidebar UI by writing a small SwiftUI-style file. It is interpreted at runtime (no Xcode, no build step, no signing), renders as native SwiftUI in the real sidebar, hot-reloads on save, binds to live cmux state, and can run cmux commands on tap. This guide is the authoring contract for you or a coding agent. This guide covers interpreted custom sidebars, which cannot import frameworks or start child processes. For compiled Swift in an ExtensionKit sidebar, start with the [sample app](../Examples/SampleSidebarExtensionApp/README.md) and the [CmuxExtensionKit authoring guide](../Packages/macOS/CmuxExtensionKit/README.md). Compiled extensions run inside the macOS App Sandbox; if yours launches `git` or another external tool, read [Running external tools](../Packages/macOS/CmuxExtensionKit/README.md#running-external-tools) before choosing an executable or opening a repository. It is a beta, on by default. Turn it off in **Settings → Custom Sidebars** (`customSidebars.beta.enabled`). While off, custom sidebars do not appear. ## Start from a template Six curated custom sidebars are available as built-in templates while the Custom Sidebars beta is enabled: Workspaces, Agents Board, Panel Sessions, Panel Subagents, btop Agents, and Panel Todo. Right-click the sidebar toggle button, choose **Browse Sidebar Templates…**, and open the gallery. Each card shows a preview, placement, and description. **Try** temporarily selects the bundled source without writing to your sidebar folder; use **Keep** or **Revert** in the gallery bar. **Use** installs an editable file and offers **Edit** in your preferred editor. Right-panel templates open in the right sidebar when it is available. The same templates are available from the CLI: ```bash cmux sidebar templates cmux sidebar templates --json cmux sidebar try agents-board cmux sidebar new agents-board --from agents-board cmux sidebar open agents-board ``` `cmux sidebar try` creates a temporary preview file and prints the command to open and remove it. `cmux sidebar new` accepts kebab-case names and will not replace an existing file unless you add `--force`. The template list includes the intended placement for each file: left sidebar, right panel, or both. The six bundled source files and manifest are mirrored from `Examples/CustomSidebars/`. The remaining examples stay there as authoring references, so you can copy or adapt them into your dotfiles. Preview cards ship with the app bundle. ### Curated gallery | Template | Use it for | Placement | Preview | | --- | --- | --- | --- | | Workspaces | A straightforward live workspace list. | Left sidebar | ![Workspaces preview](../Packages/macOS/CmuxSettingsUI/Sources/CmuxSettingsUI/Resources/CustomSidebarTemplatePreviews/workspaces-light.png) / [dark](../Packages/macOS/CmuxSettingsUI/Sources/CmuxSettingsUI/Resources/CustomSidebarTemplatePreviews/workspaces-dark.png) | | Agents Board | A kanban-style board for agent workspaces. | Left sidebar | ![Agents Board preview](../Packages/macOS/CmuxSettingsUI/Sources/CmuxSettingsUI/Resources/CustomSidebarTemplatePreviews/agents-board-light.png) / [dark](../Packages/macOS/CmuxSettingsUI/Sources/CmuxSettingsUI/Resources/CustomSidebarTemplatePreviews/agents-board-dark.png) | | Panel Sessions | Searchable sessions for this workspace or all workspaces. | Right panel | ![Panel Sessions preview](../Packages/macOS/CmuxSettingsUI/Sources/CmuxSettingsUI/Resources/CustomSidebarTemplatePreviews/panel-sessions-light.png) / [dark](../Packages/macOS/CmuxSettingsUI/Sources/CmuxSettingsUI/Resources/CustomSidebarTemplatePreviews/panel-sessions-dark.png) | | Panel Subagents | Coding-agent sessions grouped by workspace with live status. | Right panel | ![Panel Subagents preview](../Packages/macOS/CmuxSettingsUI/Sources/CmuxSettingsUI/Resources/CustomSidebarTemplatePreviews/panel-subagents-light.png) / [dark](../Packages/macOS/CmuxSettingsUI/Sources/CmuxSettingsUI/Resources/CustomSidebarTemplatePreviews/panel-subagents-dark.png) | | btop Agents | A terminal-inspired monitor for agent activity. | Left sidebar | ![btop Agents preview](../Packages/macOS/CmuxSettingsUI/Sources/CmuxSettingsUI/Resources/CustomSidebarTemplatePreviews/btop-agents-light.png) / [dark](../Packages/macOS/CmuxSettingsUI/Sources/CmuxSettingsUI/Resources/CustomSidebarTemplatePreviews/btop-agents-dark.png) | | Panel Todo | An interactive scratch checklist for the current workspace. | Right panel | ![Panel Todo preview](../Packages/macOS/CmuxSettingsUI/Sources/CmuxSettingsUI/Resources/CustomSidebarTemplatePreviews/panel-todo-light.png) / [dark](../Packages/macOS/CmuxSettingsUI/Sources/CmuxSettingsUI/Resources/CustomSidebarTemplatePreviews/panel-todo-dark.png) | ## If you are an agent building this for someone Assume the person asking is not technical. They are describing a result ("a sidebar that shows my workspaces and lets me jump between them"), not an implementation. Your job is to turn that into a clean, native-looking, working sidebar and make the engineering decisions for them. Do not ask them about SwiftUI, files, or syntax. Concretely: - Default to real, live data. If they mention workspaces/tabs, bind to the `workspaces` context (not hard-coded text) so it stays correct on its own. - Make it interactive by default. Rows that represent something you can open should be tappable and run the matching `cmux(...)` action (e.g. selecting a workspace, focusing a tab). A list that just displays text is rarely what they wanted. - If the list is something a person would naturally reorder (workspaces, tasks, a queue), make it drag-and-drop reorderable with `Reorderable` (see below). When in doubt for a workspace list, prefer `Reorderable`. - Keep it native and uncluttered: a title, a divider, then the content. Use the status dot / pill / highlight patterns below so it is scannable at a glance. - Lazy-load / cap large lists (see Performance). Do not render hundreds of rows. - Iterate by saving the file and opening it as a pane with `cmux sidebar open `; it hot-reloads there while you edit. Verify it shows real data and that taps do the right thing before declaring it done. - Stay inside the supported subset below. If something is not supported, choose the closest supported approach rather than failing. ## Where to put a sidebar Write a named file (the name becomes the menu label; use short kebab-case): ~/.config/cmux/sidebars/.js # reactive JS scene runtime (fastest) ~/.config/cmux/sidebars/.swift # interpreted Swift ~/.config/cmux/sidebars/.json # declarative JSON (simpler, static) Each file shows up as an option in the **sidebar toggle button's right-click menu** and can also open as a normal Bonsplit pane tab. Pick it from the menu for the left sidebar, or run `cmux sidebar open ` to show it in a pane; edit the file and save and it hot-reloads. If several extensions share a base name, `.js` wins over `.swift`, which wins over `.json`. The same files also work as **right-sidebar panels** (extensions next to Files/Find/Vault): `cmux right-sidebar set custom ` selects one and adds a Custom button to the right sidebar's mode bar. The panel gets the same data keys and `cmux(...)` actions as the left sidebar and hot-reloads the same way. `panel-info` (selected-workspace overview with clickable ports and PRs), `panel-sessions` (every session with live search and a this-workspace/all scope toggle), `panel-todo` (an interactive scratch checklist), `panel-subagents` (every coding-agent session grouped by workspace with live status, elapsed time, and jump-to-terminal), five agent-roster variations (`agents-board` by status, `agents-cards`, `agents-timeline`, `agents-focus` hero+queue, `agents-dense` monospace), and `kitchen-sink` (every runtime feature on one panel) are right-panel-shaped examples. `TextField(value, opts)` opts: `placeholder`, `onSubmit(text)`, `onCancel()`, `onEdit(text)` (fires per keystroke - live search), `autofocus` (default true; pass `false` for persistent fields such as a search box). An autofocus field takes keyboard focus when it appears only if the user gave the sidebar focus: that sidebar's click handler created it (a button, tap, double-click or menu item, such as Rename) and keyboard focus hasn't moved since the click, or one of that sidebar's fields already has focus. A field that appears any other way, for example after a data update while you're typing in a terminal, stays unfocused until clicked, so sidebar code can't capture keystrokes meant for another pane. Each workspace's `tabs[i]` carries `surfaceId` for `surface.*` verbs (`tabs[i].id` is the stable panel identity, not interchangeable). For remote tmux tabs, `surfaceId` targets the window's active pane and can change when another pane becomes active. It is absent until the pane is ready. Pass the containing workspace's `id` as `workspace_id` to focus across workspaces. A sidebar file is a single SwiftUI-style view expression (no `struct`, no `var body` wrapper, just the view). ## Reactive JS sidebars (`.js`) A `.js` sidebar runs on a different engine than `.swift`: a JavaScriptCore program that executes ONCE, builds a retained scene graph, and binds to live data through signals. After the first run nothing re-executes per tick; a data change re-runs only the bindings that read it, and only those scene nodes re-render. Rows in `ForEach`/`Reorderable` keep stable identity by key, so animations, scroll position, and an in-flight drag survive live updates. Use `.js` when you want maximum performance or drag-to-reorder; use `.swift` when you want to paste SwiftUI. sidebar(() => VStack({ spacing: 6 }, [ Text("Workspaces").font("headline"), Divider(), Reorderable( { items: () => data.workspaces() ?? [], key: (w) => w.id, onMove: (id, index) => cmux("workspace.reorder", { workspace_id: id, index: index }), }, (w) => HStack({ spacing: 8 }, [ Circle({ size: 7 }).fill(() => (w().selected ? "accent" : "clear")), Text(() => w().title).lineLimit(1), Spacer(), ]) .padding(6) .onTap(() => cmux("workspace.select", { workspace_id: w().id })) ), ]) ) Rules of the runtime: - `sidebar(fn)` runs once and must return a view. There is no re-render; a prop whose value should track data must be a **function** (`Text(() => w().title)`, `.fill(() => ...)`), which becomes a live binding. - `data.()` reads a host data key as a signal (same keys as the Swift data context: `workspaces`, `groups`, `workspaceCount`, `selectedTitle`, `selectedId`, `unreadTotal`, `clock`). Reading inside a binding subscribes it. Each group is `{id, name, collapsed, pinned, anchorId, color?, icon?}` and a grouped workspace carries its group id as `group`. - Author state: `const [open, setOpen] = signal(false)` and `computed(fn)`. Reads inside any function-valued prop subscribe it; writes re-run exactly the bindings that read it. - Views: `VStack` `HStack` `ZStack` `LazyVStack` `Group` `Text` `Image` `Button` `Spacer` `Divider` `Circle` `Capsule` `Rectangle` `RoundedRectangle` `ProgressView` `ForEach` `Reorderable`. Containers take `(props, children)` or just `(children)`. - Chainable props: `.font(name|size)` `.weight` `.bold()` `.italic()` `.monospaced()` `.color` `.secondary()` `.lineLimit` `.truncation` `.padding` `.paddingHorizontal` `.paddingVertical` `.background` `.hoverBackground` (host-side hover wash, no JS round trip) `.cornerRadius` (continuous/squircle curvature) `.borderColor` `.borderWidth` `.opacity` `.frame({width,height,minWidth,maxWidth,...})` (or `.frame(() => ({...}))` to bind every key live; the keys come from the first evaluation, so return every key you need from the start) `.layoutPriority(n)` (who keeps width in an `HStack`; truncating text defaults to 1, so give a button or badge beside it 2) `.fixedSize()` (keep a view at its natural size; `.fixedSize("horizontal")` or `"vertical"` for one axis) `.fill` `.stroke` `.strokeWidth` `.size` `.rotation(degrees)` (spins the content in place inside its layout box, spring-animated - e.g. a group chevron that turns instead of swapping glyphs) `.fade(width)` (constant trailing fade: the last `width` points dissolve to transparent - use it instead of trailing padding where accessories float over the content) `.marquee(delaySeconds?)` (text only: after the hover holds `delay` seconds, default 0.5, an overflowing title scrolls out and back; layout never changes) `.cursor("pointer")` (show a pointing-hand cursor while the view is hovered) `.onTap(fn)`. Any of them (except handlers) accepts a function for a live binding. Colors are the same tokens as Swift sidebars (`accent`, `secondary`, `red`, `#RRGGBB[AA]`). - `ForEach({ items, key }, (item, key) => row)` reconciles by key: the row template runs once per key and `item()` is the row's live item signal. - `.fixed()` on a row inside a `Reorderable` makes it a non-grabbable slot (it still shifts to open gaps and keeps its own taps). Build a grouped sidebar as ONE flat Reorderable of headers (.fixed) + rows, and resolve the drop's container from the flat index; `Examples/CustomSidebars/workspaces.js` shows the full pattern including cross-group drag via `workspace.group.add`/`workspace.group.remove`. - `Reorderable({ items, key, onMove, onDragChange, spacing }, template)` is the drag-to-reorder list: the grabbed row lifts and follows the pointer, the other rows spring aside live, and the drop calls `onMove(id, index, extra)` (dispatch `workspace.reorder` there to persist). `index` is the zero-based flat row index after moving. `extra.side` is `"above"` or `"below"`: at a boundary between nesting levels, the pointer's horizontal position chooses which neighboring row's nesting to adopt. It is not a vertical drop direction. `extra.block` is true when moving a block header with its members. - Optional `onDragChange(state)` reports the projected drop during a drag: `{ id, index, side, block }`, using the same meanings as `onMove`. It fires on lift and when the projected intent changes, not on every pointer frame. `state` becomes `null` on drop (after `onMove`, if a move is needed), Escape, removal of the dragged row, or disappearance of the list. Keep this state in a signal to render an insertion line or nesting highlight; persist only from `onMove`. For example: ```js const [drag, setDrag] = signal(null); // Inside sidebar(() => ...): Reorderable({ items: () => data.workspaces() ?? [], key: w => w.id, onDragChange: setDrag, onMove: (id, index) => cmux("workspace.reorder", { workspace_id: id, index }), }, w => Text(() => w().title) .background(() => drag()?.id === w().id ? "accent" : "clear")) ``` - Right-click menus: `.contextMenu([Button("Pin", fn), Divider(), Menu("Move", [...]), Button("Close", fn).destructive()])` on any view. Menu items are ordinary Button/Menu/Divider nodes, so labels and actions can be live bindings (`Button(() => w().pinned ? "Unpin" : "Pin", ...)`). The menu opens only over the view it is attached to, so put it on the row's outer HStack when right-clicking anywhere on the row, including the empty space a Spacer fills, should open it. Useful verbs: `workspace.action` (pin/unpin, mark_read/mark_unread, move_up/move_down/move_top, close_others, set/clear color and description), `workspace.close`, `workspace.move_to_window`, `workspace.group.action` (pin/unpin/ungroup/delete), `workspace.group.collapse` / `.expand`. - Actions: `cmux(method, params)`, `openURL(url)`, `log(message)` anywhere in a handler. - Clipboard: `clipboard.write(text)` copies plain text, e.g. a Copy Workspace ID menu item: `Button("Copy Workspace ID", () => clipboard.write(w().id))`. It only works while cmux is handling a click, double-click, or menu item for the sidebar, and only synchronously inside that handler. Calls from load, data effects, drag/reorder callbacks, text-field submit or edit handlers, or a callback saved for later return `false` and log a `clipboard.write rejected: ...` message, so a sidebar can't swap the clipboard behind your back before you paste into a shell. Text is capped at 64 KB (UTF-8). It is write-only: there is no clipboard read. The remote renderer has no clipboard, so every call returns `false` there. - Containment: the context has no filesystem, network, or timers, and a runaway evaluation is terminated by a watchdog. Errors show in the sidebar with a line number. - Translucent "liquid glass" behind the sidebar comes from cmux's window chrome, not the sidebar file: pick a glass preset in Settings under sidebar appearance (e.g. Raycast Gray / HUD Glass). `sidebar(fn, { surface: "glass" })` additionally drops the pane host's opaque backdrop fill when the sidebar is opened as a Bonsplit pane. - There is no conditional view helper yet; model visibility with a binding that returns an empty string or a `null` background. A ready-to-copy example ships in `Examples/CustomSidebars/workspaces.js`. ## Choosing the renderer (in-process vs remote) Known limitation: the remote (out-of-process) renderer does not propagate a sidebar's `surface: "glass"` request to the host, so remotely rendered sidebars keep the opaque backdrop. Glass works in the default in-process renderer. By default a custom sidebar renders in-process: the interpreted view mounts as real SwiftUI inside the cmux window, so hover styling, focus, keyboard, and same-frame resize all work natively. The tradeoff is that the interpreter shares the host process. For sidebars from sources you do not fully trust you can switch to the remote renderer, an out-of-process worker. That is the containment lane: a crash or hang caused by the interpreted file cannot take down cmux, but input is limited to forwarded clicks (no hover, focus, or keyboard). Set it in **Settings → Custom Sidebars**, or in `~/.config/cmux/cmux.json`: { "customSidebars": { "renderer": "remote" } } Valid values are `"inProcess"` (default) and `"remote"`. The setting is read live; flipping it re-renders the selected sidebar without a restart. Both renderers protect the host against pathological sources with an evaluation budget (nesting depth and total produced nodes): a render that exceeds the budget is discarded and the last good render stays up. ## Downloadable examples The repo includes ready-to-copy sidebars in `Examples/CustomSidebars/`: - `status-board.swift` groups workspaces by live signals like urgent bugs, review, progress, research, and done. - `finder.swift` shows a macOS Finder-style workspace browser with a source list, selected workspace details, and tabs. - `btop-agents.js` is a btop-style agent activity list: a braille sparkline of recent agent activity per workspace, state glyphs, a small progress meter, and a header graph of busy workspaces. Install one from a cmux checkout: mkdir -p ~/.config/cmux/sidebars cp Examples/CustomSidebars/status-board.swift ~/.config/cmux/sidebars/status-board.swift cp Examples/CustomSidebars/finder.swift ~/.config/cmux/sidebars/finder.swift Then validate and open it as a Bonsplit pane: cmux sidebar validate status-board cmux sidebar open status-board `cmux sidebar select ` still previews a custom sidebar in the left sidebar picker. Use `cmux sidebar open ` when you want the sidebar as a normal pane tab that can live in a right-side split. ## Quick start cat > ~/.config/cmux/sidebars/mine.swift <<'SWIFT' VStack(alignment: .leading, spacing: 8) { Text("My sidebar").font(.title3).bold() Text(clock.time).font(.caption).foregroundColor(.secondary) Divider() ForEach(workspaces) { w in Button(action: { cmux("workspace.select", workspace_id: w.id) }) { HStack { Text(w.selected ? "●" : "○").foregroundColor(w.selected ? "#FF8800" : .secondary) Text(w.title) Spacer() } } } } SWIFT Then right-click the sidebar button and choose **mine**, or open it as a pane with: cmux sidebar open mine ## Live data you can bind to (read-only, refreshes ~1s) - `workspaces` — array, one per workspace. Always present: `id`, `title`, `selected` (Bool), `pinned` (Bool), `index` (Int), `directory`, `ports` (array of Int) + `portCount`, `unread` (Int notifications), `status`, `tabs` + `tabCount`. `status` is the workspace's task-status lane, one of `todo`, `working`, `needs-attention`, `review` or `done`. It is the resolved lane: a manual pin set through `cmux workspace status set` or the sidebar menu while that pin still holds, otherwise the lane cmux infers from live signals (an agent waiting on input, a running agent, an open pull request, a dirty working tree). An external tool that pins the lane through `cmux workspace status set` shows up here too. `status` is always reported, independently of whether the built-in status glyph is visible. That glyph needs two further conditions the context does not carry: the workspace-todo feature has to be on, which happens through the beta toggle or through the remote feature flag, and the workspace's own `statusHidden` has to be false. A workspace created in this session starts hidden; one restored from a session snapshot that predates the field starts visible. A custom sidebar therefore has to decide for itself whether to render the lane, and it cannot read `statusHidden` from the context. Note the two vocabularies differ: this lane uses `needs-attention`, while `agents[j].status` uses `needs_input`. They are separate values from separate sources and are not interchangeable. Present when the workspace has them (use `if let` / ternary): `emoji` (the leading emoji grapheme from the display title), `description`, `color` (hex), `branch` + `dirty` (Bool) from git, `pr` (`{ number, label, url, status: open|merged|closed, stale, branch }`, the workspace's first pull request in sidebar display order) + `prs` (array of the same shape with every pull request cmux knows for the workspace), `progress` (`{ value: 0..1, label }`), `latestMessage` (last agent message), `latestPrompt` (last submitted prompt), `latestAt` (epoch), `remote` (`{ target, state, connected }`), `agents` (coding-agent sessions hosted by the workspace's terminals, most recent first; omitted when none). Each `agents[j]` always has `id`, `kind` (`claude`/`codex`/raw source), `name` (display name), `status` (`idle`|`working`|`needs_input`|`ended`), and `lastActivityAt` (epoch); when available it adds `sinceEpoch` (when the current working/needs-input state began), `title` (first user prompt), `panelId` (the hosting terminal's `tabs[k].id`), `surfaceId` (the hosting tab's `tabs[k].surfaceId`, accepted by `surface.focus`), `directory`, `transcriptPath`, `pid`, and `children` (nested subagent runs under the session, oldest first; omitted when none). Each `children[k]` has `id` (stable for the child's lifetime), `running` (Bool), and `startedEpoch`; when available it adds `label` and `endedEpoch` (set when the child settles; settled children are pruned after a short retention). Headless OMP/Pi subagents run inside the parent's process, so they appear here via `cmux hooks omp|pi subagent-start|subagent-stop` with JSON `{"session_id": "", "agent_id": "", "description": ""}`: start opens the child on the parent record, stop closes the oldest running child (FIFO). The `agent_id` field is not read; only `_opencode_request_id` can correlate a stop event to a child. - `tabs` (per workspace) — array of surfaces. Always: `id`, `title`, `focused` (Bool), `pinned` (Bool), `hasUnread` (Bool, whether that surface has an unread notification). It is named differently from the workspace-level `unread`, which is a count, so that `w.unread > 0` and `t.hasUnread` cannot be confused for one another. When available: `directory`, `branch` + `dirty`, `ports` (array of Int), `latestPrompt` (the prompt last submitted in that surface, not a pending state) + `latestAt` (epoch). Pair `latestPrompt` with `hasUnread` to show which of a workspace's agents is waiting, instead of collapsing every surface into the workspace-level `latestPrompt`. - `workspaceCount` — Int. `selectedTitle` — active workspace's title. `selectedId` — its id. `unreadTotal` — total unread notifications. - `clock` — `{ time ("HH:mm:ss"), hour, minute, second, weekday, epoch }`. The sidebar re-renders about once a second, so clocks/countdowns and workspace changes are live. Optional fields are omitted when the workspace doesn't have them, so guard with `if let b = w.branch { ... }` or `w.pr != nil ? ... : ...` rather than assuming they exist. ## Views Containers: `VStack(alignment:spacing:)`, `HStack`, `ZStack`, `LazyVStack`, `LazyHStack`, `Group`, `EmptyView()`, `List { ... }`, `Section("Header") { ... }`, `Grid { GridRow { ... } }`, `LazyVGrid`, `LazyHGrid`, `ViewThatFits { ... }`, `ScrollView { ... }` (use `ScrollView(.horizontal) { HStack { ... } }` for a horizontal strip — vertical scrolling is automatic), and `HSplitView { columnA; columnB }` (two resizable, independently-scrolling columns with a persisted divider). Content: `Text("...")`, `Label("Title", systemImage: "folder")`, `Image(systemName: "folder.fill")` (SF Symbols), `Button("Title") { }` / `Button(action:){