Skip to content

Lay out and theme the panel

View as Markdown

The panel floats in a corner, docks to an edge of the page, collapses to a pill, or hides. Set where it starts with data-position, data-open and data-mode on its script tag (or <weft-devtools>, a weft:* meta tag or mount()); after that the user’s own placement is remembered per origin. It is light or dark: data-theme decides, else the user’s ◐ choice, else your page’s theme. Every colour, radius and font is a --weft-* custom property your CSS can override.

Dock the panel on the right, open, and pad the page so nothing sits under it:

<script type="module" src="/studio/panel.js" data-weft
data-position="right-dock" data-open="true" data-push="true"></script>

Install the devtools panel lists every attribute, meta tag and mount() option, and the order they resolve in.

The weft devtools panel docked on the right of an app page, its Story tab showing a step's tool calls and their errorsThe weft devtools panel docked on the right of an app page, its Story tab showing a step's tool calls and their errors
data-position="right-dock" data-open="true": the panel docked on the right, open on its story tab.

The panel has four modes:

ModeWhat you seeHow it gets there
floatA 520×560 box in the bottom-right corner (or bottom-left), dragged by its header, resized from its corner between 360×280 and the viewport minus 16 pxthe default when open
dockFull height on the left or right edge, or full width on the top or bottom, 460 px across by default and resized along that edgedata-position="right-dock" and the other -dock values, or the header’s ⇆
pillThe collapsed button: the live dot and step count, and the current turn’s cost: · $0.0029 when Studio priced it, else its tokens once the run has finished, · 300 in · 58 out (an unpriced model, or a Studio without the pricing capability); — while it runscollapsed, the default; data-mode="pill"
hiddenNothing is drawn. The element, its host API and its events keep workingdata-mode="hidden"; Alt+W or open() brings it back

The attributes that set the starting layout:

AttributeValuesDefaultEffect
data-positionbottom-right, bottom-left, right-dock, left-dock, top-dock, bottom-dockbottom-rightWhere the dock starts: the float’s corner, or the docked edge. Changed later, it moves the dock
data-open"true" or an empty attributecollapsedStart expanded. Read once, when the element first connects: changing it later does nothing
data-modefloat, dock, pill, hiddenfrom the two aboveThe starting mode. float and dock start open; pill starts collapsed. Read once: changing it later does nothing
data-push"true"offWhile docked and open, pad <html> on the docked side (below)
data-z-indexan integer--weft-z on the element, else 2147483000The dock’s and the pill’s z-index

The header’s ⇆ button, labelled with the current layout (layout: float, layout: dock right), and Alt+Shift+W step through the layouts in one order: float, dock right, dock bottom, dock left, dock top. Under 640 px of panel width the turn list becomes a dropdown and the header’s buttons wrap. Each option says the turn’s status, steps and duration before its title or a replay’s lineage (● parked t3 · 1 step · 23 ms · Deploy…), so a cut title never cuts them. The default 520 px float and the 460 px left or right dock are both that narrow, so they show the dropdown until you widen them; a top or bottom dock is as wide as the viewport. Under a 480 px viewport the panel is a full-width bottom sheet, at most 70 vh tall. The resize handles work with a pointer or touch only.

data-push="true" is the one write the panel makes to your document, and it is opt-in. While the panel is docked and open, it sets --weft-devtools-inset on <html> to the dock’s size and pads that side by it. As the bottom sheet (under a 480 px viewport) it pads the bottom by 70vh. Docked at the bottom with the default size, <html> carries:

--weft-devtools-inset: 460px; padding-bottom: var(--weft-devtools-inset);

The inline padding it replaced, or one your page set meanwhile, is put back exactly when the dock closes, changes mode or disconnects. Padding does not move position: fixed or sticky elements, so keep a fixed composer clear with the same variable:

.composer { bottom: var(--weft-devtools-inset, 0); }

Use right, left or top for those docks.

The panel patches its DOM in place instead of rebuilding it. A turn row is matched by its run id and a step card by its step ordinal, so while a turn streams only its running step’s card changes. Focus, the caret, the panes’ scroll and the <details> you opened stay where they were, because their nodes stay.

The collapsed pill shows the conversation is busy without opening the panel. While the stream the panel already holds lists a run as running, the pill pulses and shows the run’s live step count, ● 3, with the aria-label weft devtools · running, step 3; its title adds — Alt+W. The button’s text always starts devtools. The count is the open tail’s steps when that run is the turn the panel follows, else its row’s; while that is unknown the pill reads ● alone, weft devtools · running. The pulse is a CSS animation, off under prefers-reduced-motion. When the run ends, the next draw is the plain pill again, with the turn’s cost or tokens.

The collapsed devtools pill while a run runs: devtools ● 4The collapsed devtools pill while a run runs: devtools ● 4
The collapsed pill while a run is at its fourth step: devtools ● 4.

The panel resolves light or dark in this order:

  1. Explicit: data-theme="light" or "dark" on the tag or element, <meta name="weft:theme">, or mount({ theme }). The header’s ◐ button then reads theme: dark, set by the page and does nothing.
  2. Stored: the user’s ◐ choice. Each click steps auto → light → dark → auto; the choice is kept as theme in localStorage["weft.devtools"], and auto clears it.
  3. Auto: your page’s <html data-theme="dark|light">, else <html class="dark|light">, else <html>’s computed color-scheme when it is exactly dark or light, then the system’s prefers-color-scheme, else dark.
The devtools panel as a float in the bottom-right corner, forced light over a page in the docs' theme: the turn's Story with step 0's lookup_order call and its resultThe devtools panel as a float in the bottom-right corner, forced light over a page in the docs' theme: the turn's Story with step 0's lookup_order call and its result
data-mode="float" data-theme="light": the float in the bottom-right corner stays light whatever the page's theme.

data-theme="auto" is the default and means “use steps 2 and 3”. A theme toggle on your page is followed live: one attributes-only MutationObserver on <html>’s class and data-theme, and one media-query listener, both removed on disconnect. The panel only reads <html>. The resolved theme is written to the element as data-theme-resolved, for your own CSS or tests.

The palette is Studio’s (studio/web/src/lib/palette.ts), and both themes meet WCAG AA contrast (4.5:1 for text, 3:1 for UI). Every colour, radius and font is a custom property on the panel’s :host. A rule in your page’s CSS beats the shadow tree’s :host, in either theme:

weft-devtools {
--weft-accent: #0b6bcb;
--weft-font-prose: Georgia, serif;
}
TokenUsed for
--weft-bg, --weft-bg2, --weft-bg3panes; header, steps and footer; the selected row and fields
--weft-fg, --weft-dim, --weft-faint, --weft-linetext, secondary text, the faintest text, rules
--weft-accent, --weft-on-accentthe accent, and text on it
--weft-warn, --weft-err, --weft-info, --weft-ok, --weft-parkedstatus colours
--weft-scrim, --weft-shadowthe ? overlay’s backdrop, the float’s shadow
--weft-font, --weft-font-proseids, JSON and numbers; a step’s text, the prompt and notes (system-ui, sans-serif, no webfont)
--weft-radius, --weft-radius-smcorner radii
--weft-resulta tool result’s tone
--weft-status-run, --weft-status-run-inkthe running dot, the pill’s pulse and border; the running word
--weft-zthe default z-index, below data-z-index

--weft-faint (light), --weft-scrim and --weft-shadow are the panel’s own; the rest equal a Studio variable (--weft-parked is Studio’s status-parked). In light, --weft-bg2 equals --weft-bg, so the header and steps differ from the panes by their rule line only. Devtools panel reference lists them with the panel’s other attributes.

The “Studio not reachable” line sits in your page’s flow: on a mount you made, and since 0.20.0 on the panel’s own dock at a loopback endpoint you named. It takes your page’s text colour, not a theme’s.

The panel keeps one JSON object per origin in localStorage["weft.devtools"]:

{"v":1,"mode":"float","side":"right","open":true,"hidden":false,"x":864,"y":324,"w":520,"h":560,"d":460,"run":"s_01…-t3","theme":"","raw":false,"tab":"story","debug":false}
FieldWhat it holds
mode, side, open, hiddenfloat or dock, the docked edge, expanded, hidden
x, y, w, hthe float’s box, in px
dthe dock’s size across its edge, in px
runthe last selected turn, by run id
themethe ◐ choice: light, dark, or "" for auto
tab, rawthe turn’s open tab: story, request, waterfall or raw (a timeline stored before 0.20.0 opens story, or raw when raw is true); raw mirrors it
debugthe ?weft=debug force-on switch (Install)

The placement fields (mode through d) are written only once the user places the panel: a toggle, a drag, a resize or a re-dock. Until then your data-* attributes decide on every load; after it, the stored placement wins over them. A document with another v is ignored. Every read and write is guarded, so a private window forgets and the panel still works. To reset everything, including debug:

localStorage.removeItem("weft.devtools")

Alt+W is the only key the panel listens for on window. Every other key is heard on its shadow root, so it fires only while focus is inside the panel. A key typed into your page never reaches it, and keys typed into the panel’s own fields are typing. Alt+W that opens the dock puts focus in it, so the other keys work at once. ? inside the panel shows the list. Since 0.20.0 a key Studio also binds means the same there: j / k, [ / ], s / w / q / r, o and ? (Studio’s keyboard). / differs: here it filters the turn list or the raw tree, in Studio the runs list only.

KeyDoes
Alt+WToggle the dock from anywhere on the page, except while a text field has focus. Ctrl+Shift+W too, where the browser delivers it
Alt+Shift+WNext layout: float, dock right, bottom, left, top
EscClose (the ? list first). It is not stopped, so your page’s own Esc handlers still run
j / kNext / previous item of the list in focus (the turns)
[ / ]Previous / next step (⤢ carries it); J / K too
s / w / q / rThe story, waterfall, request or raw tab; again, back to the tab before it
oOpen the turn and step in Studio, in a new tab; g s too
/Focus the filter: the raw tree’s on the raw tab, else the turn list’s
← / →On the tabs: previous / next tab (Home / End: first / last)
?The key list
↓ / ↑On a turn row: move the list’s one tab stop (Enter or a click selects)
TabIn an open, focused float: wraps from the last control to the first (Shift+Tab back)

The float is non-modal: it has no backdrop and the page stays live. Its Tab wrap is the panel’s only focus trap, and Esc collapses the dock to leave it. Docked, as a pill or as the bottom sheet, the panel never traps focus.

Every control has an ARIA role or label, the turn list has a roving tabindex, and weft’s tests hold the panel to zero axe violations:

ElementARIA
The dockrole="complementary", aria-label="weft devtools"
The turn listrole="list" (aria-label="turns") of role="listitem" rows with a roving tabindex. The selected row has aria-current="true", and each row’s aria-label says it in words: turn 3, parked, Refund order 4411, 1 step, 120 in 30 out, just now
The running step’s textaria-live="polite" with aria-busy="true" while it streams: a screen reader waits rather than re-reading each draw
The step-end statusa visually hidden role="status" line, written once when the running step ends: step N finished · n words
The turn’s tabsrole="tablist" (aria-label="turn views") of role="tab" buttons with aria-selected and one tabindex="0"; the drawn panel is a role="tabpanel"
Expandersaria-expanded on “how to scope”, a subagent’s summary and each raw tree node
Filtersaria-label="filter turns", "status", "filter keys and values"
Icon buttonsan aria-label on each: ⤢, ⇆, ◐, –, ↺ and the pill. From 480 px of dock width, ⤢, ⇆ and ◐ also show the words Studio, layout and theme
The switcher, the turn dropdownaria-label="conversation", aria-label="turn"
The experiment drawerevery field inside its <label>; selects labelled model, thinking, side effects, engine, thread

weft’s own test studio/web/src/panel/a11y.test.ts runs axe-core over the panel’s shadow root in its modes, including (float open, docked right, the bottom sheet at 400 px, the pill, the raw tab with its tree open and filtered, the waterfall tab, the experiment drawer, the ? overlay), in both themes, and fails on any violation. jsdom has no layout, so colour contrast is held by theme.test.ts instead. Contrast over your page, focus-ring visibility and real screen-reader announcements are checked by hand in a browser. axe-core is a dev dependency only; panel.js does not contain it.

A page that docks the panel at the bottom, pushes its own layout up, keeps a fixed composer clear, and recolours the accent. With the devtools example running, this is its page with the tag changed:

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Order help</title>
<style>
.composer { position: fixed; left: 0; right: 0; bottom: var(--weft-devtools-inset, 0); }
weft-devtools { --weft-accent: #0b6bcb; }
</style>
</head>
<body>
<h1>Order help</h1>
<form class="composer"><input name="text" size="40"> <button>Ask</button></form>
<script type="module" src="/studio/panel.js" data-weft
data-position="bottom-dock" data-open="true" data-push="true"
data-z-index="50" data-theme="dark"></script>
</body>
</html>

The dock opens across the bottom, dark, under any of your elements with a z-index above 50. The form stays above it. Once you drag, resize or re-dock it, your placement wins over these attributes on the next load, until localStorage.removeItem("weft.devtools").

The layout page's complete example: an Order help page with its composer kept above a dark panel docked along the bottom, the panel's accent recoloured blue, showing a turn's StoryThe layout page's complete example: an Order help page with its composer kept above a dark panel docked along the bottom, the panel's accent recoloured blue, showing a turn's Story
This example's page: the dark dock across the bottom with the blue accent, the composer kept above it by --weft-devtools-inset.
  • Set the starting layout, then let the user own it. After the first placement the stored layout wins over data-position, data-open and data-mode on every load; to see your attributes again, clear localStorage["weft.devtools"]. (Source: studio/README.md:1191-1197; panel/layout.ts:79-97)
  • data-mode and data-open are read once. The element does not observe data-mode, and reads data-open only on its first connect; a framework that changes either after mount changes nothing. (Source: panel/element.ts:412-425, 904-914)
  • Keep fixed elements clear with the variable, not the padding. data-push pads <html>, which never moves position: fixed or sticky content; use var(--weft-devtools-inset, 0). (Source: studio/README.md:1135)
  • Override tokens on the weft-devtools selector. Your page’s CSS cannot reach inside the shadow tree, but a rule on the host element sets its custom properties in both themes. (Source: studio/README.md:1153-1160)
  • Keyboard shortcuts need focus in the panel. Only Alt+W works from the page; the rest fire inside the panel, so they never clash with your app’s keys. (Source: studio/README.md:1199-1207; panel/element.ts:496-499)