ConstCreate a code editor widget for multiline text editing. Supports selections, keyboard navigation, and undo/redo.
ui.codeEditor({
id: "editor",
lines: state.lines,
cursor: state.cursor,
selection: state.selection,
scrollTop: state.scrollTop,
scrollLeft: state.scrollLeft,
lineNumbers: true,
tabSize: 2,
onChange: (lines, cursor) => app.update({ lines, cursor }),
onSelectionChange: (sel) => app.update({ selection: sel }),
onScroll: (top, left) => app.update({ scrollTop: top, scrollLeft: left }),
})
Create a command palette widget for quick-access command execution. Supports search, keyboard navigation, and multiple command sources.
ui.commandPalette({
id: "cmd-palette",
open: state.paletteOpen,
query: state.query,
sources: [
{ id: "cmds", name: "Commands", prefix: ">", getItems: getCommands },
{ id: "files", name: "Files", getItems: searchFiles },
],
selectedIndex: state.selectedIndex,
onQueryChange: (q) => app.update({ query: q }),
onSelect: (item) => executeCommand(item),
onClose: () => app.update({ paletteOpen: false }),
})
Create a diff viewer widget for displaying file changes. Supports unified and side-by-side modes with hunk staging.
Create a dropdown menu positioned relative to an anchor. Automatically flips when near screen edge.
ui.dropdown({
id: "file-menu",
anchorId: "file-button",
position: "below-start",
items: [
{ id: "new", label: "New", shortcut: "Ctrl+N" },
{ id: "open", label: "Open", shortcut: "Ctrl+O" },
{ id: "divider", label: "", divider: true },
{ id: "exit", label: "Exit" },
],
onSelect: (item) => handleAction(item.id),
onClose: () => app.update({ menuOpen: false }),
})
Create a field wrapper for form inputs. Displays label, error message, and optional hint.
Create a file picker widget for browsing workspace files. Supports expand/collapse, multi-select, and git status indicators.
ui.filePicker({
id: "file-picker",
rootPath: "/workspace",
data: fileTree,
selectedPath: state.selectedFile,
expandedPaths: state.expanded,
modifiedPaths: state.gitModified,
onSelect: (path) => app.update({ selectedFile: path }),
onToggle: (path, exp) => toggleExpanded(path, exp),
onOpen: (path) => openFile(path),
})
Create a file tree explorer widget. Provides tree view with expand/collapse and custom node rendering.
Create a generic layer in the layer stack. Use for custom overlays that need z-order control.
Create a layers container for stacking overlays. Later children render on top (higher z-order).
Create a logs console widget for streaming output. Supports filtering, auto-scroll, and expandable entries.
Create a modal overlay. Renders centered with optional backdrop and focus trap.
Create a panel group container for resizable panels. Manages layout and resize state for child panels.
Create a radio group widget. Supports keyboard navigation with ArrowUp/Down for selection.
Create a resizable panel within a panel group. Specifies size constraints for the panel.
Create a select dropdown widget. Supports keyboard navigation with ArrowUp/Down and Enter.
Create a split pane widget with draggable dividers. Supports horizontal/vertical splits with resize constraints.
Create a table widget for displaying tabular data. Supports sorting, selection, and virtualization for large datasets.
ui.table({
id: "files",
columns: [
{ key: "name", header: "Name", flex: 1, sortable: true },
{ key: "size", header: "Size", width: 10, align: "right" },
{ key: "actions", header: "", width: 8, render: (_, row) =>
ui.button({ id: `del-${row.id}`, label: "Del" }) },
],
data: files,
getRowKey: (f) => f.id,
selection: state.selected,
selectionMode: "multi",
onSelectionChange: (keys) => app.update({ selected: keys }),
sortColumn: state.sortCol,
sortDirection: state.sortDir,
onSort: (col, dir) => app.update({ sortCol: col, sortDir: dir }),
})
Create a toast container for non-blocking notifications. Manages toast stack and auto-dismiss.
Create a tool approval dialog for reviewing tool execution. Shows tool details, risk level, and approval actions.
ui.toolApprovalDialog({
id: "approval",
open: state.pendingApproval !== null,
request: state.pendingApproval,
onAllow: () => executeTool(state.pendingApproval),
onDeny: () => app.update({ pendingApproval: null }),
onAllowForSession: () => allowForSession(state.pendingApproval),
onClose: () => app.update({ pendingApproval: null }),
})
Create a tree widget for displaying hierarchical data. Supports expand/collapse, selection, and lazy loading.
ui.tree<FileNode>({
id: "file-tree",
data: fileSystem,
getKey: (n) => n.path,
getChildren: (n) => n.children,
hasChildren: (n) => n.type === "directory",
expanded: state.expandedPaths,
selected: state.selectedPath,
onToggle: (node, exp) => app.update(s => ({
expandedPaths: exp
? [...s.expandedPaths, node.path]
: s.expandedPaths.filter(p => p !== node.path)
})),
onSelect: (n) => app.update({ selectedPath: n.path }),
onActivate: (n) => n.type === "file" && openFile(n.path),
renderNode: (node, depth, state) => ui.row({ gap: 1 }, [
ui.text(state.expanded ? "▼" : state.hasChildren ? "▶" : " "),
ui.text(node.type === "directory" ? "📁" : "📄"),
ui.text(node.name),
]),
showLines: true,
})
Widget factory functions for building VNode trees.