ade
(alias: console)v1.10.1Web console for iii — bundles the React UI and proxies the engine WebSocket on a single port.
Install
iii trigger compose::add worker=ade@1.10.1Run in your project with the iii engine running. Exact versions are immutable and digest-pinned.
skill doc
Injectable console UI
A worker ships pages, function and observer-activity renderers, forms, and
stylesheets into every console tab at runtime — no console rebuild, no
iframe, hot reload. This skill is the delivery contract. Looks, tokens and
every number: ade/design-system (link to ade/design-system › Numbers,
never restate one). Behavior across widths and forms: ade/design-console-ui.
How it works
A worker observes ade::ui::asset once per asset, with args
{ kind: 'script' | 'style' | 'module', path } naming the asset (module for
code loaded on demand) and its content function as the target, which serves
{content} for {path}. The ADE worker calls the content function through the
observer, hashes and serves those bytes, then pushes changes to open tabs.
Tabs import() scripts and call their default setup(host); styles load as
scoped <link> assets; modules load only when a script calls
host.importModule(path). A new observer of a path hot-reloads it. Observing
is deployment; disconnect is teardown.
Project layout
mywork/
build.rs # ensure dist assets exist before include_str!
ui/
page.tsx # the script asset — default-exports setup(host)
styles.css # the style asset — every rule scoped
build.mjs # buildWorkerUi({ scope }) — the shared driver
package.json # workspace dependency on @iii-dev/console-ui
tsconfig.json # extends the shared worker tsconfig
src/ # page, renderers, config form, widgets
src/
ui.rs # embed and register dist/page.js + dist/styles.cssBoth sides of the contract are versioned in this repository; nothing is installed from a registry.
- Add
<worker>/uito the rootpnpm-workspace.yamlpackageslist. ui/package.json(copystate/ui/package.json): private,"type": "module", scriptsbuild: tsc --noEmit && node build.mjsandwatch: node build.mjs --watch,"dependencies": { "@iii-dev/console-ui": "workspace:*" }, and@types/react,@types/react-dom,esbuild,lucide-react,react,react-dom,typescriptas"catalog:"devDependencies — the workspacecatalog:inpnpm-workspace.yamlpins every toolchain version once.ui/tsconfig.jsonis{ "extends": "@iii-dev/console-ui/tsconfig.worker-ui.json", "include": ["page.tsx", "src"] }.ui/build.mjsis the whole driver call:import { buildWorkerUi } from '@iii-dev/console-ui/build-worker-ui', thenawait buildWorkerUi({ scope: 'mywork' }).- A Rust worker adds
iii-console-ui = { path = "../crates/console-ui" }to<worker>/Cargo.toml.
@iii-dev/console-ui's root is types-only at build time; the console serves
its runtime from the running SPA. iii-console-ui registers the content
function, observes the assets, and runs the development watcher; Node workers
implement the wire contract directly. Copy state/build.rs and
state/src/ui.rs; rename worker and asset paths and keep their tests.
Authoring workflow
- Read
packages/console-ui/index.d.ts,hooks.d.mtsandformat.d.mts; never guess a component, hook or prop. - Select only the needed slots; model the primary object, navigation, actions, async states, and what must survive navigation or reload.
- Choose one archetype (below); design wide and narrow flows separately.
- Build with shared primitives and minimal scoped CSS; build (the driver scopes, checks tokens, lints), register, inspect the manifest, exercise the real console.
Living references
| Need | Read | Reuse |
|---|---|---|
| Public API | packages/console-ui/index.d.ts, hooks.d.mts, format.d.mts |
Exact exports and props |
| Shared page chrome | ade/web/src/components/ui/PageChrome.tsx |
PageShell, PageHeader, surface roles |
| Migrated page, strict lint | browser/ui/page.tsx, browser/ui/src/page/, browser/ui/styles.css |
Shared hooks/format/icons, Toolbar, Eyebrow, overlays, lint: { strict: true } |
| Migrated list/detail editor | iii-directory/ui/page.tsx, iii-directory/ui/src/page/, iii-directory/ui/styles.css |
SearchField, MetaRow/ActionLine, Kbd/KeyCombo, dirty-draft guards, per-tab state |
| Migrated workbench | ide/ui/page.tsx, ide/ui/src/page/, ide/ui/build.mjs |
keyframePrefixes, allowUnscopedSelectors for vendor CSS, CodeEditor/FileDiff, terminal atoms |
| Minimal template | state/ui/page.tsx, state/ui/src/page/browser.tsx, state/ui/styles.css |
Smallest complete page + renderer + config form |
| Observer-activity renderer | cron/ui/src/observer-activity/, cron/src/ui.rs |
host.observerRenderers and the canonical small settings form |
| Rust delivery | state/src/ui.rs, state/build.rs |
Embedding, registration, asset tests, build freshness |
Copy delivery plumbing when it matches; never copy a reference's sidebar
count, thresholds, controls, or visual hierarchy without deriving them from
the new worker's content. The migration recipe and the order of the remaining
workers: docs/plans/2026-09-16-worker-ui-migration.md.
Archetypes
Choose one dominant archetype before writing JSX; mixing them produces a
generic dashboard. Shapes, wide/narrow flows and references are in
ade/design-console-ui › Archetypes.
- Console catalog — many searchable objects with rich detail.
- Database workbench — several tools on one selected resource.
- Directory editor — searchable documents with drafts or preview.
- State explorer — deep but compact hierarchy.
- Settings flow — one configuration entry, host-owned persistence.
- Terminal/instrument — one live surface with a toolbar and status bar.
1. The script asset (ui/page.tsx)
Ordinary React. react, @iii-dev/console-ui and lucide-react resolve at
runtime through the console's import map, so they stay external (the
driver does this). Default-export setup(host) and make every registration
through host: the loader attributes registrations to the script and
disposes them on reload. setup may return a disposer (SetupFn in
index.d.ts); the loader runs it and the registrations LIFO.
import { type Host, PageHeader, PageMain, type PageRenderProps, PageShell } from '@iii-dev/console-ui'
import { Boxes } from 'lucide-react'
function MyworkPage({ host, onRequestClose }: PageRenderProps & { host: Host }) {
return (
<PageShell className="mywork-ui-shell">
<PageHeader icon={<Boxes />} title="Mywork" description={host.path} onClose={onRequestClose} />
<PageMain className="mywork-ui-main">{/* the chosen archetype */}</PageMain>
</PageShell>
)
}
export default function setup(host: Host) {
host.pages.register({
id: 'mywork-manager', // alone at #/worker/mywork/mywork-manager
title: 'Mywork', // nav label
configurationId: 'mywork', // host adds the standard settings action
render: (props) => <MyworkPage host={host} {...props} />,
})
}Imports from the shared package and from lucide-react add zero bundle bytes.
Slots
Every register returns a remover and is disposed automatically on hot
reload and worker disconnect. Namespaces marked ? are absent on older
consoles: feature-detect them.
| Surface | What it is |
|---|---|
host.pages |
register({ id, title, configurationId?, render }) registers a page the workspace opens through host.panels.open or ade::workspace::open { screen: "ext:<id>" }, plus a nav entry. host.panels.openScreen({ screen, relativeTo?, direction?, sizes? }) places any workspace screen, built-in ones like traces included, in this browser's tab without a bus round trip (optional on older consoles: feature-detect, fall back to ade::workspace::open); #/worker/<scope>[/<id>] renders it alone (Testing below). render receives PageRenderProps (below). Set configurationId when the worker has a configuration entry; the host places the one settings action in PageHeader. Never mount WorkerConfigurationDialog yourself. |
host.functionCalls |
Chat/trace renderers. Match only the worker's function ids; return null to fall through. message.description is the harness's short activity label. metadata: { display: true } keeps a successful rich artifact visible while raw details stay collapsed. If raw data can contain secrets, implement a pure, total, cycle-safe redactRaw; the raw tab and copy action otherwise expose the original input/output. |
host.observerRenderers? |
Layered observer presentation; see below. |
host.configForms |
The deliberate form for one configuration entry in global Settings. There is no schema-generated fallback: every configurable worker registers one. The host owns dirty tracking, validation, save, reset and the SaveBar; honor focusField. { layout: 'full' } only for a workbench that owns its scrolling. Form anatomy and primitives: ade/design-console-ui › Configuration forms. |
host.providerConfigForms? |
Replace the form body for one exact llm-router provider id inside the model picker; provider-owned OAuth, device flow or companion login. Never solicit a plaintext API key. Props: ProviderConfigFormProps. |
host.chat? |
registerSessionChip, registerTurnSummary?, registerContextSection?, registerComposerAction?, registerComposerControl?, registerTranscriptRenderer?, compose?, openDraft?, selectConversation?, composerModel?, requestWorkingDirectoryChange?, requestThinkingLevelChange?. Feature-detect each method. registerComposerControl puts a compact per-session setting beside the model picker; it gets the session's metadata and a setMetadata(patch) the console persists through its own writer (never call session::set-meta yourself), and the value applies from the next turn like the model (the judge's provider picker). With placement: 'project' the control sits in the working-directory strip after the folder instead, only where that strip shows, for what belongs to the folder (the ide's worktree switcher); every control also gets the session's workingDir, and moves it with requestWorkingDirectoryChange. registerContextSection({ id, title, order?, render }) adds a section to the chat's Context side panel: the console draws the header (title, worker, count, fold, drag handle) and keeps the user's order; render gets { sessionId, workingDir?, active, isStreaming, setSummary }, reads only while active, and reports setSummary({ count, brief, tone, empty }), where empty: true leaves the section out. |
host.panels? |
open({ pageId, context }) places or reuses a registered page beside chat and delivers panelContext. Pass opaque ids; fetch bodies from the worker. |
host.mentions? |
registerRenderer({ provider, Preview }) draws the hover preview of the worker's own @<provider>(id="…") chat mentions from the mention view (view.data); Preview gets { provider, view, open }. The provider itself is declared by the worker's backend, not here (ade/mentions). A renderer that throws falls back to the generic card. |
host.overlays? |
register({ id, render }) — a floating layer over the workspace (the browser's live preview, the learn-iii tour). render receives { conversationId }, the active chat. A worker command registered with host.commands is listed whether or not its page exists, so an overlay-only worker keeps its palette row. Fall back to the page when absent. |
host.palette? |
registerSource({ id, title, kind, prefix?, minQuery?, search }) adds live rows to the command palette; open({ query? }). |
host.commands? |
register(pageId, commands) — palette rows for a page that may not be open yet (run usually calls panels.open). A mounted page contributes keys through PageRenderProps.commands. |
host.iii |
The tab's bus client: call(functionId, payload?, { timeoutMs? }), on(functionId, handler), observe(source, target, options?), addConnectionStateListener, browserId. Injected UI acts by calling its own worker's functions. observe takes a function id or { function_id, args?, filters?, deliver? } and the full id of a handler registered with on (<functionId>::<browserId>), delivers the event the observed function returned, and returns its disposer. A link to the worker's public pages takes its port from http::status at runtime, never a fixed 3111. |
host.importModule? |
importModule<T>(path) imports one of the worker's module assets on demand and resolves to its namespace (Lazy modules below); rejects when nothing is served at /ui/<path>. |
host.components, host.path, host.useTheme, host.uiClasses, host.workspace?, host.screen? |
Runtime component record, the current asset path, theme, class recipes, recent directories, visible-screen lease. |
PageRenderProps: panelSide ('left' | 'right', only to keep wide side
navigation on the outer edge); tabId and paneId? (key persisted UI state
and per-instance resources on paneId — the same page can be open in two
columns of one tab — falling back to tabId on older consoles);
onRequestClose? (wire to PageHeader.onClose); workingDir? (the active
conversation's live directory, for filesystem-shaped pages only);
panelContext? and conversationId?; setDirty? (report unsaved work) and
commands? (palette rows and pane-scoped keys, registered from an effect).
Live data: a page registers a handler over host.iii with an id like
iii::<worker>-ui::events and observes its worker's event functions with
<id>::<browserId> as the target (the iii:: prefix keeps it out of the
trace feed; the observers leave with the tab) — useWorkerLive from
@iii-dev/console-ui/hooks wraps fetch + observers + a re-read on tab focus. Every
injected render is error-bounded: import or setup failures drop the
extension's contribution and log to the browser console. Scripts run with full
console-origin privileges; the wrapper scopes styles, it is not a sandbox.
Observer renderers: layered ownership
interface ObserverActivityRenderer {
id: string
isMatch(functionId: string): boolean
tryRender(activity: ObserverActivityMessage): React.ReactNode | null
tryRenderDetails?(activity: ObserverActivityMessage): React.ReactNode | null
tryRenderDisplay?(activity: ObserverActivityMessage): React.ReactNode | null
redactRaw?(value: unknown): unknown
}ObserverActivityMessage.kind is registration, fired, or retirement;
the model carries the observed functionId, its opaque args and filters,
optional label and action, delivery, lifecycle and payload/outcome
fields. Match functionId (every agent observes through harness::observe),
parse args without throwing, return null per slot to fall through. tryRender is the
source-specific section inside the generic detail view; tryRenderDetails
replaces the whole expanded Terminal tab and must carry the lifecycle and
delivery facts the host no longer adds; tryRenderDisplay is the compact
timeline content inside the host's disclosure button — non-interactive, one
line, truncation-safe; redactRaw is pure, non-mutating, total, cycle-safe,
and a throw fails closed. The host owns the click target, expanded state,
motion, isolation, per-slot fallback and the Raw JSON tab; a once firing and
its automatic retirement are one activity.
For an agent's harness::observe, label names the observer and action
describes the future event:
{ "function_id": "session::on-message-added",
"filters": { "input.session_id": { "$eq": "explorer" } },
"label": "explorer-messages", "action": "new Explorer message received" }Observe receipts and active-observer surfaces show label; show action
only when activity.kind === 'fired'. Action affects presentation only.
Shared components, hooks, format, icons
packages/console-ui/index.d.ts is the only list of runtime exports: page
chrome, List/ListItem, cards, Panel, Chip/Badge, IconButton, the
Table family, line Tabs/SegmentedControl, Select/Selector, inputs,
Dialog/ConfirmDialog/DropdownMenu/Tooltip/BottomSheet, status and
empty states, Eyebrow, SearchField, Toolbar/StatusBar,
MetaRow/ActionLine, Kbd/KeyCombo, LiveRegion, Markdown/JSON/code
renderers, the terminal atoms (AnsiText, TerminalStream,
TerminalCommandLine), CodeEditor, FileDiff, ImageViewer,
ModelPicker, DirectoryPicker, and the settings primitives
(SettingsSection/SettingsList/SettingsRow/SettingsField,
RawValueInput, SettingsDeck). <Tooltip label="…"> is the one-line
tooltip. Confirmation is useConfirm() (render dialog, await confirm({ … }))
or ConfirmDialog — never window.confirm. uiClasses holds the stable
class recipes (list*, tree*, card*, panel*, chip, table*,
tabs*, field*, settings*, eyebrow, toolbar/toolbarEnd,
statusbar, spin, pulse) and tokens the CSS variable inventory. When
to use each: ade/design-system › Shared components.
Two subpaths bundle (React-free code the console itself uses):
@iii-dev/console-ui/hooks—useContainerNarrow({ below? })(attachrefto the pane root;narrowwhile the pane is below the shared default fromade/design-system› Numbers or yourbelow; synchronous first measure, resizes observed, zero widths ignored),usePaneState(key, initial)(localStorage-mirrored, best effort),useCopyFlash(text, ms?),useWorkerLive({ iii, sources, fetch, pollMs?, handlerId }).@iii-dev/console-ui/format—formatRelative,formatDuration,formatBytes,errorMessage,errorCode,copyText.
Literal shapes (@iii-dev/console-ui/index.d.ts, hooks.d.mts):
SelectOption<T extends string = string>: { value: T; label: string; title?: string; description?: string; disabled?: boolean }
SelectGroup<T extends string = string>: { label: string; options: SelectOption<T>[] }
SelectProps<T extends string = string>: { value: T | undefined; options?: SelectOption<T>[]; groups?: SelectGroup<T>[]; onChange: (next: T) => void; disabled?: boolean; className?: string; id?: string; name?: string; 'data-field'?: string; appearance?: 'default' | 'inline'; showChevron?: boolean; 'aria-label'?: string; 'aria-busy'?: boolean; 'aria-invalid'?: React.AriaAttributes['aria-invalid']; 'aria-describedby'?: string; placeholder?: string; sheetTitle?: React.ReactNode; sheetDescription?: React.ReactNode; allowEmpty?: boolean; emptyLabel?: string; onClear?: () => void; renderGroupHeader?: (group: SelectGroup<T>) => React.ReactNode }
Select: <T extends string = string>(props: SelectProps<T>) => React.ReactNode
CheckboxProps: Omit<React.InputHTMLAttributes<HTMLInputElement>, 'children' | 'className' | 'type'> & { className?: string; label?: React.ReactNode; indeterminate?: boolean }
Checkbox: React.ComponentType<CheckboxProps & React.RefAttributes<HTMLInputElement>>
WorkerLiveOptions<T>: { iii: ExtensionIii; sources: readonly (string | ObserveSource)[]; fetch: () => Promise<T>; pollMs?: number /* deprecated, ignored */; handlerId: string }
WorkerLive<T>: { data: T | null; loading: boolean; error: string | null; live: boolean; refresh: () => void }
useWorkerLive: <T>(options: WorkerLiveOptions<T>) => WorkerLive<T>Import these instead of keeping a local copy; the migration plan lists the copies still to be replaced.
Icons are lucide-react, an external shared with the console: import { X } from 'lucide-react'. Never hand-write SVG icons (the lint flags them) and
never add another icon dependency. Sizes: ade/design-system › Numbers.
Never bundle Monaco, CodeMirror, a diff renderer, or an ANSI parser; use
CodeEditor, FileDiff, and the terminal atoms.
Lazy modules
Heavy code only one view needs (the ide terminal's @xterm/xterm) ships as
a module asset: served at /ui/<path> like a script, never imported at
mount. The page imports it when the view opens:
if (!host.importModule) throw new Error('this console predates lazy modules')
const { Terminal } = await host.importModule<typeof import('./xterm')>('ide/xterm.js')- Add the entry (
ui/xterm.ts, exporting what the page uses) tobuildWorkerUi({ entryPoints: ['page.tsx', 'styles.css', 'xterm.ts'] }); it emits the fixed-namedist/xterm.js. - Embed it with
include_str!and register it with.module(path, …)(Registration below). - Page code imports the library only as types (
import type,typeof import('./xterm')): one value import bundles it back intopage.js.
importModule loads the hash-versioned URL when the tab knows the module, so
a hot reload applies at the next call, and the bare /ui/<path> otherwise,
so a call that beats the module's push to the tab still loads it. The ADE
worker serves a module only once its registration lands: register modules before
the scripts that import them (ConsoleUi does), and retry a rejected import
with backoff, since the registration may still be landing (the ide terminal
does).
2. The style asset (ui/styles.css)
Plain CSS, every top-level rule scoped under the worker's wrapper
attribute — the console mounts each render inside
<div data-iii-ui="<first path segment>" style="display:contents">:
[data-iii-ui="mywork"] .mywork-ui-main {
min-width: 0;
min-height: 0;
overflow: auto;
}
@keyframes mywork-flash { /* keyframe names are global: prefix them */ }- Colors, fonts, radius, shadows and motion are tokens:
var(--color-…),var(--font-sans|mono|code),var(--radius-…),var(--shadow-…),var(--motion-duration-…)/var(--motion-ease-…).checkTokensfails the build on a token the console does not define. Which token means what:ade/design-system› Tokens. - Keyframe names carry the worker prefix (
keyframePrefixes, default[scope, "<scope>-ui"]); spin/pulse areuiClasses.spin/uiClasses.pulse. - Responsive layout is
@containeron the pane (everyPageShellis a container), never a viewport@media; the viewport breakpoint is reserved for the console's phone chrome (ade/web/src/lib/viewport-breakpoint-conformance.test.ts). - No unscoped selectors (
:root,html,body,*, bare elements), no@font-face: injected CSS is unlayered and would beat the console's layered stylesheet document-wide.assertScopedrefuses the build; the ADE worker's fetch-time lint reports leftovers in the manifest'swarnings. - No Tailwind utility classes in injected markup — worker class names are not
in the console's compiled output. Shared components and
uiClassesfirst; scoped CSS only for domain layout and data visualization. - Scope
@media (prefers-reduced-motion: reduce)overrides too (shared recipes already honor it); streaming, rapidly updating and pointer-following values update without transitions. - Shared
Dialog,DropdownMenu,Select,Selector,Tooltip, andBottomSheetportals preserve the worker scope. A customdocument.bodyportal stampsdata-iii-ui="<worker>"on its root (and lists it inallowUnscopedSelectorsif its rules live outside the scope).
3. The build (ui/build.mjs)
buildWorkerUi (packages/console-ui/build-worker-ui.mjs, typed in
build-worker-ui.d.mts) is the one esbuild driver:
| Option | Default | Purpose |
|---|---|---|
scope |
required | The data-iii-ui value — first asset path segment, normally the worker name |
entryPoints |
['page.tsx', 'styles.css'] |
Extra scripts each need their own script asset observer and a default setup; a lazy module needs a module asset observer and no setup |
outdir, root |
'dist', process.cwd() |
Pass root: import.meta.dirname when invoked from elsewhere |
keyframePrefixes |
[scope, "<scope>-ui"] |
Allowed @keyframes name prefixes |
allowUnscopedSelectors |
[] |
Selector prefixes that are global on purpose (a portal root, vendor CSS such as .xterm) |
strictTokens |
true |
Unknown design token fails the build (false warns) |
lint |
{} |
false skips the design-rule lint; { strict, disable, allow } tunes it |
watch, minify |
--watch flag, !watch |
Watch rebuilds unminified for readable traces |
plugins, extraExternal, define |
Passed to esbuild |
After every build it checks each asset against the 8 MiB cap, runs
assertScoped on every sheet and checkTokens on everything; a non-watch
build then runs lintWorkerUi on the source. A failed check exits 1.
Six specifiers stay external because the console's import map serves them:
react, react-dom, react-dom/client, react/jsx-runtime,
@iii-dev/console-ui, lucide-react. The driver matches them exactly
(workerUiExternalsPlugin) because esbuild's external list would also
externalize @iii-dev/console-ui/format and /hooks, which must bundle.
Everything else bundles in. Only those six exist in the import map: a
dependency importing another bare react-family specifier (react-dom/server)
fails at import() time. A custom pipeline (canvas) imports
workerUiExternals, assertScoped, checkTokens and, from
@iii-dev/console-ui/lint-worker-ui, lintWorkerUi/formatLint, and runs
the same checks; dropping the react external there bundles a second React
("Invalid hook call"), dropping @iii-dev/console-ui throws at once with the fix.
Lint
lintWorkerUi({ root, scope, strict, disable, allow }) scans styles.css,
page.tsx and src/** (never dist/ or tests); errors fail the build,
warnings print. strict: true promotes warnings (browser, iii-directory,
ide; every migrated worker turns it on); disable: ['rule'] drops a rule;
allow: { rule: ['substring', /re/] } ignores matching excerpts; a
lint-allow <rule> comment on the finding's line or the one above does the
same in place — always with a reason.
| Rule | Level | Flags |
|---|---|---|
no-window-dialogs |
error | window.confirm/alert/prompt( — use useConfirm()/ConfirmDialog |
icon-size |
error | Lucide size, <svg width/height> or size-3/w-3 h-3 classes below the icon baseline |
accent-selection |
error | var(--color-accent…) in a selected/active/current rule (focus excepted) |
no-inline-svg |
warning | <svg in a .tsx outside icons.tsx/icons/ — import from lucide-react |
radius |
warning | border-radius other than 0, the system radius, full rounding, var(--radius-*), inherit |
font-family |
warning | anything but var(--font-…)/inherit |
font-size |
warning | below the UI text floor |
case-transform |
warning | text-transform/textTransform: — use Eyebrow/uiClasses.eyebrow |
focus-stroke |
warning | :focus/:focus-visible outline, box-shadow or border in accent — use --color-rule-focus |
shadow |
warning | box-shadow that is not var(--shadow-*), none or a token inset/hairline |
hex-color |
warning | #hex/rgb()/hsl() literals (custom properties on the scope root are fine) |
motion-literal |
warning | transition/animation with a literal ms/s duration |
keyframes-shared |
warning | @keyframes …spin/pulse/shimmer/fade — use uiClasses.spin/uiClasses.pulse |
viewport-media |
warning | `@media (max-width |
tailwind-in-worker |
warning | className strings with several Tailwind utilities |
The baseline, floor and radius the rules check are the values in
ade/design-system › Numbers. CLI: node packages/console-ui/lint-worker-ui.mjs <worker>/ui [--strict] [--json];
--all from the repo root prints one row per worker.
4. Registration (the worker side)
One content function serving all of the worker's assets (dispatch on
path), one ade::ui::asset observer per asset. Rust workers use the
iii-console-ui crate:
use iii_console_ui::ConsoleUi;
ConsoleUi::new("mywork")
.script("mywork/page.js", include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/ui/dist/page.js")))
.style("mywork/styles.css", include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/ui/dist/styles.css")))
.register(&iii);This registers <worker>::ui-content, one observer per asset, and the
III_<WORKER>_UI_WATCH watcher; it panics on a path the ADE worker would
reject; .module(path, content) adds a module asset the same way.
Export ui from the worker library and call ui::register(&iii) after its
normal functions; adapt state/build.rs so missing or stale UI sources build
before include_str!. Node workers register one function
mapping {path} to {content, content_type?}, then observe
ade::ui::asset once per asset:
iii.observe(
{ function_id: 'ade::ui::asset', args: { kind: 'script', path: 'mywork/page.js' } },
'mywork::ui-content',
)Observe modules first, in every SDK. The console commits assets in the order their observers reach it, and every SDK sends a worker's observers to the engine in the order the worker created them, on the first connection and on every reconnect, so the console serves the modules a script imports before the script reaches a tab.
Observe over the worker's own connection: its observers leave with the worker on disconnect (the console drops the assets) and are observed again on reconnect.
Runtime contract
| Function | ade::ui::asset; never observe the tab-only ade::ui::on-assets-changed |
| Args | { "kind": "script" | "module" | "style", "path": string }, nothing else: script is ESM JS imported at mount, module ESM JS imported only by host.importModule (kind module in the manifest and tab pushes), style CSS |
| Target | the worker's content function: once the observer is active it receives { path }, in a call of ade::ui::asset for that observer alone that the function's deliver hook hands to it |
| Path rules | lowercase [a-z0-9._-] segments, no leading slash, no ./.. segments, ≤ 512 chars; extension must match the kind (.js for scripts and modules, .css); convention: first segment = worker name — it becomes the data-iii-ui scope and the only human-readable attribution |
| Content function | input { "path": string } → output { "content": string, "content_type"?: string } |
| Size cap | 8 MiB per asset — a larger asset's observer is rejected (the driver fails first) |
| Reload | a new observer of the same path with a changed content hash replaces the asset (the old observer is rejected as UI_ASSET_SUPERSEDED); unchanged content is a no-op |
The dev loop (hot reload)
Rebuild-on-save stays in the build tool; re-observing stays in the worker
(observe the new asset first, then dispose the old observer). The Rust helper polls
once a second when III_<WORKER>_UI_WATCH=1 (ui/dist) or names a directory:
pnpm --dir mywork/ui watch # terminal 1, repo root
cd mywork && III_MYWORK_UI_WATCH=1 cargo run # terminal 2Every open tab hot-swaps the asset: scripts re-import() + re-setup() (slot
React state is lost), styles link-swap with no flash, a module's new bytes
load at the next host.importModule; unchanged content is hash-deduped end to
end.
Debugging
| Symptom | Cause |
|---|---|
| Build exits 1 naming a selector | an unscoped rule, unprefixed @keyframes or @font-face — assertScoped |
Build exits 1 on unknown token |
a var(--color-…) the console does not define — check token-names.mjs, or declare it on the scope root |
Build exits 1 on design-rule error(s) |
a lint error (or a warning under strict) — fix it or lint-allow it with a reason |
Observer rejected with a path error (INVALID_ARGS) |
path violates the rules table (wrong extension, uppercase, .., …) |
Observer rejected with UI_ASSET_FETCH_FAILED |
the content function threw, returned no string content, or timed out |
| "Invalid hook call" in the tab | a second React in the bundle — a custom build dropped an external |
import() fails on a bare specifier |
a dependency imports a react-family subpath outside the six shared specifiers |
host.importModule rejects |
nothing is served at /ui/<path>: a typo, the module is not registered, or its worker's UI is disabled |
| Styles apply on the page but not in a custom portal | a custom document.body portal must carry data-iii-ui="<worker>" on its root |
| Whole console restyled | unscoped rules reached the console — check warnings in the manifest |
| Registered but absent | inspect workers[].enabled and injectableUi.disabledWorkers in the manifest |
Inspect ade::ui-manifest (or GET <url>/ui, url from ade::status),
/ui/<path>, the worker's observers (engine::observers::list { worker }),
and [iii-ui] browser logs in that order.
The manifest is authoritative; its warnings must be empty.
Testing
Validate all four layers; a green build alone is not enough.
- Static:
pnpm --dir <worker>/ui build— type-check, scoped and token-checked assets, lint clean (strict where enabled), no bundled React, editor or ANSI parser. - Embedding: accepted assets, an ESM export, the built CSS scope (esbuild may omit selector quotes); targeted Rust tests.
- Delivery: boot engine + ADE + worker; manifest paths, hashes, no warnings, fetchable bytes, a changed hash after hot reload.
- Real rendering: the actual console at a phone-sized, a narrow split
and a wide pane (
ade/design-system› Numbers), both split positions, both themes, keyboard only, reduced motion, long content, every async and live-update state, dirty navigation, reconnect — the matrix inade/design-console-ui› Validate. Forhost.observerRenderersadd exact function-id match, malformed-args fallthrough, every slot and activity kind, non-interactive compact display, complete-detail lifecycle fidelity, action fallback, fail-closed redaction, and disable/disconnect fallback.
The page alone: <url>/#/worker/<scope>[/<page-id>][?context=<json>], with url from ade::status. The
console renders that one page over the full viewport — no tab strip, chat or
palette; the tab title is iii - <scope> — and never reads or writes the
shared workspace layout, so a Playwright or browser-worker session can open
a worker's page directly for screenshots and drive-through. scope is the
worker's asset namespace (browser/page.js → browser, the data-iii-ui
value); omit the page id for the worker's first page. context replays a
host.panels.open context on load. What still works there: the page's
settings action and the settings shortcut (the configuration overlay opens in
place), the page's keyed commands, hot reload and the worker's overlays.
host.panels.open delivers context in place for the page on screen and opens
any other page in a new browser tab. #/traces renders the traces explorer
the same way. Chat slots and the palette are out of its scope: validate those
in the full console, opened through ade::workspace::open.
Definition of done
PageShell+PageHeaderpresent, close action wired;- every configurable page declares
configurationId; every configuration entry has a purpose-builthost.configFormsform; - controls, hooks, formatters and icons come from
@iii-dev/console-ui, its/hooksand/formatsubpaths, andlucide-react— no local copies; - the narrow flow exposes every action without horizontal overflow; focus is
visible, controls have names, targets meet
ade/design-system› Numbers; - selection is neutral in both themes; styles are scoped and token-based;
- the build passes
strictTokensand a clean lint (strictonce migrated); - async responses cannot overwrite a newer selection or a dirty draft;
- reconnect and hot reload leave no duplicate registrations; the manifest has
no warnings and the browser console has no
[iii-ui]errors.