Devtools panel reference
The devtools panel is one custom element, <weft-devtools>, configured by data-* attributes, weft:* meta tags or mount() options, driven by its methods, observed through weft:* events and styled by --weft-* custom properties. This page lists each of them with its type, default and behaviour. How to install and use the panel is under Devtools; the panel’s script is served by Studio’s /panel.js route.
A script tag that sets five fields, and the same five as meta tags:
<script type="module" src="/studio/panel.js" data-weft data-position="right-dock" data-open="true" data-push="true" data-theme="dark" data-scope="pub_demo"></script>
<meta name="weft:position" content="right-dock"><meta name="weft:open" content="true"><meta name="weft:push" content="true"><meta name="weft:theme" content="dark"><meta name="weft:scope" content="pub_demo">Attributes and meta tags
Section titled “Attributes and meta tags”Thirteen fields configure the panel. Each resolves on its own, the first source that sets it winning: mount() options, then the element’s data-* attributes, then <meta name="weft:*"> tags, then the panel’s script tag, then (for the endpoint only) panel-config.json, then the script’s own directory. Install the panel explains the ladder.
| Attribute | Meta tag | Values | Default | A change |
|---|---|---|---|---|
data-endpoint | weft:endpoint | Studio’s base URL, http or https, a trailing / added; another scheme and the panel does not start; an empty value sets nothing | the script’s origin and directory; with no explicit endpoint, panel-config.json beside the script may move its path (same origin only) | live: a new connection |
data-scope | weft:scope | the scope’s string form, pub_…;session=…;flow=…;run=… | window.__WEFT__, then the page URL, markers and headers; since 0.20.0, with none of them, a panel token’s claims (scope) | live: rescopes |
data-public-id | weft:public-id | a public id: the older, deprecated spelling of data-scope | none; data-scope wins at the same rung | live: rescopes |
data-token | weft:token | a bearer token: a panel token in pages you ship | none (setup A) | live: a new connection |
data-detect | weft:detect | headers, markers, headers,markers (any order, any case), or off; off anywhere wins, another word makes it unset | unset: the header rung on only with page and endpoint on loopback and no panel token; the marker rung on except off loopback under a read-scoped panel token | live |
data-position | weft:position | bottom-right, bottom-left, right-dock, left-dock, top-dock, bottom-dock; another value reads as the default | bottom-right | live: moves the dock, keeps its size. The user’s stored placement wins over it on load |
data-open | weft:open | "true", or the attribute present and empty | collapsed (the pill) | read once, when the element first connects. A stored placement wins over it, data-mode float or dock opens the panel and pill collapses it |
data-mode | weft:mode | float, dock, pill, hidden | from position and open | read once; not an observed attribute. float and dock start expanded, pill collapsed, hidden draws nothing (the API and events still work); a stored placement wins |
data-push | weft:push | "true" | off | live |
data-z-index | weft:z-index | an integer, trimmed | --weft-z on the element, else 2147483000 | live |
data-theme | weft:theme | light, dark (any case, trimmed); anything else is auto | auto: the stored ◐ choice, then the page’s <html> (data-theme, then class="dark" or "light", then its color-scheme), then prefers-color-scheme, else dark | live |
data-auto | weft:auto | any value but "false" is on | on | read once, by the bundle’s self-mount decision, from a meta tag or the script tag only. On a <weft-devtools> element it is an observed attribute but does nothing |
data-global | weft:global | off or false (any case) turns it off | on: window.weft.devtools while the panel is connected | live |
“Live” means a change to the element’s attribute is applied at once. A meta tag or a script tag’s attribute is read whenever the element re-reads its configuration (an observed attribute change, rescan(), a new window.__WEFT__), but changes to them are not watched. mount()’s mode, push and zIndex are written onto the element as data-mode, data-push and data-z-index.
Other attributes the panel reads or writes:
| Attribute | On | Meaning |
|---|---|---|
data-weft | the panel’s <script> tag | Marks the tag whose data-* fields configure the panel, whatever its src (a renamed or proxied bundle). Without it the standalone bundle finds its tag as the running classic script or by its own URL; imported from npm, only data-weft counts |
data-weft-scope | any element of your page | A DOM marker naming the conversation it shows, in the scope’s string form; the framework helpers set it. The panel also writes it on its own element when scope() sets a scope |
data-weft-untrusted | any element of your page | Markers on or inside it are ignored: put it on rendered user or model HTML |
data-theme-resolved | <weft-devtools> | Written by the panel: light or dark, the theme it resolved, for your CSS or tests |
The page itself can carry three more inputs:
| Input | Values | Effect |
|---|---|---|
window.__WEFT__ | {scope} (a Scope or its string form) or {publicId} | The scope when no attribute, meta tag or option names one. Reassigning window.__WEFT__, or setting publicId or scope on the existing object, rescopes every panel |
?weft_scope= in the page URL, else #weft_scope= | the scope’s string form, URL-encoded once | Detection rung 4: below the explicit forms, above markers and headers; read, never written. A hash router’s #/chat?weft_scope=… is read too |
?weft=debug in the page URL | debug | Mounts the dock even where data-auto is off (Install) |
MountOptions
Section titled “MountOptions”mount(opts) from @weftgo/devtools is configuration rung 1: each option it sets wins over the attributes and meta tags. It returns the element, or null with enabled: false or on a server.
| Option | Type | Default | Field |
|---|---|---|---|
endpoint | string | the page’s directory, when nothing else names one | data-endpoint |
scope | Scope | string | none; wins over publicId | data-scope |
publicId | string | none; "" is the dev list | data-public-id |
detect | "headers" | "markers" | "headers,markers" | "off" | unset | data-detect |
token | string | none | data-token |
position | Position | "bottom-right" | data-position |
open | boolean | the last open() or close(), else collapsed; replacing the self-mounted dock carries its open state | data-open |
auto | boolean | true | data-auto; has no effect on the element mount() makes |
theme | "auto" | "light" | "dark" | "auto" | data-theme |
mode | Mode | unset | written as data-mode |
push | boolean | unset | written as data-push |
zIndex | number | string | unset | written as data-z-index |
target | Element | document.body; before <body> exists, appended on DOMContentLoaded | where the element is appended |
enabled | boolean | true | false: mount nothing and return null |
A second mount() returns the first element with the new options (moved to a new target), never a second panel. A scope set by scope() before it carries over unless opts names one.
The types it uses:
| Type | Definition |
|---|---|
Position | "bottom-right" | "bottom-left" | "right-dock" | "left-dock" | "top-dock" | "bottom-dock" |
Mode | "float" | "dock" | "pill" | "hidden" |
PanelOptions | MountOptions without target, enabled, mode, push and zIndex: what the element’s options holds |
Scope | { publicId: string; session?: string; flow?: string; run?: string } |
The framework helpers take HelperOptions: scope (a Scope, or a string read as a public id), endpoint, token and enabled (default true; false sets no marker and loads nothing). With endpoint or token and no panel of the page’s own, a helper mounts one with mount({endpoint, token}); without either it only scopes the panel the page has.
The element
Section titled “The element”<weft-devtools>’s public members. The npm package types them as WeftDevtoolsElement.
| Member | Signature | What it does |
|---|---|---|
open | open(): void | Expand the dock; from hidden it opens |
close | close(): void | Collapse the dock to the pill |
toggle | toggle(): void | Flip the dock; from hidden it opens |
isOpen | readonly isOpen: boolean | Whether the dock is expanded: a property, not a function |
scope | scope(s: Scope | string | null): void | Set the explicit scope (rung 1); sessionId and runId are read as session and run. null undoes it: back to mount()’s scope, else the ladder |
select | select(runId: string, step?: number): void | Select that turn, and the step by its ordinal, once a scope() just before has settled |
on | on(event: "run" | "parked" | "error", cb: (detail) => void): () => void | Follow this panel’s events; returns the unsubscribe |
studioLink | studioLink(runId: string, step?: number): string | The Studio page of that run (and step), never with a token; "" before the endpoint is known |
options | PanelOptions | null | Rung 1: what mount() passed |
autoMounted | boolean | true only on the dock the bundle mounted by itself, the one node the panel may remove. It does when Studio does not answer /api/meta, unless the endpoint was named and is on loopback. A 401 or 403 is said, never removed |
rescan | rescan(): void | Re-read the configuration ladder and apply it |
syncGlobal | syncGlobal(): void | Publish or remove window.weft.devtools as the configuration says |
None of the methods throws; a refusal is one line in the panel. Host API and events lists those lines.
window.weft.devtools
Section titled “window.weft.devtools”Under the script tag, while a panel is connected and data-global is on, window.weft.devtools is one frozen object with eight members: open(), close(), toggle(), isOpen (a getter, so a boolean), scope(s), select(runId, step?), on(event, cb) and studioLink(runId, step?), the element’s own. window.weft is created only when absent; a non-plain window.weft or an existing devtools is left alone and the footer says window.weft is the page's: no window.weft.devtools or window.weft.devtools is the page's: not replaced. The npm package never adds the global.
npm exports
Section titled “npm exports”@weftgo/devtools (its version is the weft version) ships the same panel.js as Studio’s route and calls the element’s methods on every panel on the page. It is built from weft’s repository, not installed from the registry (Install › npm).
| Export | Signature | Differs from the element |
|---|---|---|
mount | mount(opts?: MountOptions): WeftDevtoolsElement | null | Creates the panel (MountOptions) |
open, close | (): void | Act on every panel; a panel mounted later starts that way |
toggle | (): void | Flips every panel there now |
isOpen | isOpen(): boolean | A function: whether any panel is expanded; false with none |
scope | scope(s: Scope | string | null): void | Every panel; a panel mounted later starts in it |
select | select(runId: string, step?: number): void | Every panel |
studioLink | studioLink(runId: string, step?: number): string | The first panel’s link; "" with none |
on | on(event, cb): () => void | Listens on document: every panel, one mounted later included |
serializeScope, parseScope | (s: Scope): string, (str: string): Scope | The scope’s string form |
| types | Scope, MountOptions, PanelOptions, Position, Mode, WeftDevtoolsElement, DevtoolsEvents |
On a server every export is a no-op: mount() returns null, on() a no-op unsubscribe, isOpen() false, studioLink() "". Calls made while the page is still parsing take effect once the dock is mounted.
| Subpath | Exports | Notes |
|---|---|---|
@weftgo/devtools | the table above | Importing it loads panel.js, which defines the element and may self-mount the dock |
@weftgo/devtools/react | useWeftDevtools(opts): ref; types HelperOptions, Scope | A callback ref for React 18 and 19 |
@weftgo/devtools/vue | useWeftDevtools(opts or () => opts): ref; types HelperOptions, Scope | A function ref for Vue 3; pass a getter to follow reactive state |
@weftgo/devtools/svelte | weftDevtools(node, opts), useWeftDevtools; types HelperOptions, Scope | A Svelte action (3, 4 and 5) |
@weftgo/devtools/scope | serializeScope, parseScope, Scope | No DOM: safe in server code |
@weftgo/devtools/panel.js | the bundle itself | The same bytes as /studio/panel.js |
@weftgo/devtools/package.json | the manifest |
The helpers import the panel lazily, when an element is bound, so they are safe to import in server-rendered components. React, Vue and Svelte are optional peer dependencies the helpers never import.
Events
Section titled “Events”The panel dispatches each event from the element as a CustomEvent named weft:<event>, with bubbles and composed set, after its own work (a microtask). on() takes the name without the prefix.
| Event | detail | When |
|---|---|---|
weft:run | {runId: string, status: string, publicId?: string, sessionId?: string, step?: number} | A run starts (running) and on each status change, once per transition: succeeded, failed, parked, interrupted. step is the last step ordinal the panel knows |
weft:parked | {runId: string, callId: string, ackId: string, name: string} | Once per call a run parked on. ackId is the id the approval names, equal to callId |
weft:error | {message: string, runId: string} | A run of the conversation failed, once per run; the panel’s own failures are lines, not events |
Only runs of the conversation the panel follows are reported, and only transitions it sees: the first read of a conversation’s list is history, except a run reading running there and the run the scope pins.
CSS tokens
Section titled “CSS tokens”Every colour, radius and font is a custom property on the panel’s :host, dark by default and light under data-theme-resolved="light". A rule in your page’s CSS, such as weft-devtools { --weft-bg: #fff }, beats the shadow tree’s :host in either theme. The palette is Studio’s: a token with a Studio variable equals it in that theme.
| Token | Used for | Light | Dark | Studio variable |
|---|---|---|---|---|
--weft-bg | panes | #fbfaf7 | #131211 | background |
--weft-bg2 | header, steps, footer | #fbfaf7 | #1c1a17 | card |
--weft-bg3 | selected row, fields | #f3f1ea | #2a2722 | secondary (light), sidebar-accent (dark) |
--weft-fg | text | #191713 | #ece6d6 | foreground |
--weft-dim | secondary text | #6e6759 | #a39c8f | muted-foreground |
--weft-faint | the faintest text | #766f61 | #8d887b | the panel’s own (light), code-mut (dark) |
--weft-line | rules and borders | #e7e3d9 | #2a2722 | border |
--weft-accent | the accent | #d13c10 | #ff7d52 | thread-ink |
--weft-on-accent | text on the accent | #fbfaf7 | #131211 | primary-foreground |
--weft-warn | errors returned as data, interrupted, cancelled | #875c04 | #e3b341 | status-int |
--weft-err | failed runs and rows | #b42318 | #f87171 | status-bad |
--weft-info | tool rows | #2f5bd3 | #7aa2ff | ev-tool |
--weft-ok | succeeded, live, added diff lines | #1f7a45 | #4ade80 | status-ok |
--weft-result | a tool result’s tone | #4d7a2a | #8fbf6a | ev-result |
--weft-parked | parked | #8a3fb0 | #c678dd | status-parked |
--weft-status-run | the running dot, the pill’s pulse and border | #ef4d21 | #ff5c2b | status-run |
--weft-status-run-ink | the running word | #d13c10 | #ff5c2b | status-run-ink |
--weft-scrim | the ? overlay’s backdrop | rgba(251,250,247,.92) | rgba(19,18,17,.92) | the panel’s own |
--weft-shadow | the float’s shadow | rgba(25,23,19,.18) | rgba(0,0,0,.45) | the panel’s own |
--weft-font | ids, JSON, numbers | ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace | same | |
--weft-font-prose | a step’s text, the prompt, notes | system-ui, sans-serif | same | |
--weft-radius | corner radius | 8px | same | |
--weft-radius-sm | small corner radius | 5px | same | |
--weft-z | the dock’s and the pill’s z-index, below data-z-index | unset: 2147483000 | same |
One more property is written to your page, not the panel: with data-push="true", while the panel is docked and open, <html> gets --weft-devtools-inset set to the dock’s size (70vh as the bottom sheet) and padding-<side>: var(--weft-devtools-inset), both put back exactly when it closes. Use the variable to keep a fixed element clear: bottom: var(--weft-devtools-inset, 0). Lay out and theme the panel shows overrides.
Keyboard
Section titled “Keyboard”Alt+W is the one key the panel hears on window. Every other key is heard on its shadow root, so it fires only while focus is inside the panel, and, except Tab, never while a text field has focus. ? in the panel shows the list. Since 0.20.0 the keys the panel shares with Studio mean the same on both (lib/keys.ts).
| Key | Does |
|---|---|
Alt+W | Toggle the dock from anywhere on the page, except a text field; Ctrl+Shift+W too where the browser delivers it. Opening puts focus in the panel |
Alt+Shift+W | Next layout: float, dock right, bottom, left, top |
Esc | Close (the ? list first); your page’s own Esc handlers still run. On a control of the experiment drawer it closes the drawer instead, focus back to its verb |
j / k | Next / previous item of the list in focus (the turns) |
[ / ] | Previous / next step (⤢ carries it); K / J too |
s / w / q / r | The story, waterfall, request or raw tab; again, back to the tab before it. Capitals work too |
o | Open the turn, and the step picked, in Studio in a new tab |
g s | The same as o; s must follow g within 1.5 s |
/ | Focus a filter: on the raw tab the raw tree’s; on the request tab an open tree’s, else the turn list’s; on other tabs the turn list’s |
← / → | On the tabs: previous / next tab (Home / End: first / last) |
? | The key list |
↓ / ↑ | On a turn row, or a waterfall step row: move the list’s one tab stop (Enter or a click selects a turn; Enter or Space selects a waterfall row) |
Tab | In an open, focused float: wraps from the last control to the first (Shift+Tab back), from a text field too; the panel’s only focus trap |
localStorage
Section titled “localStorage”The panel keeps one JSON object per origin in localStorage["weft.devtools"]. A document whose v is not 1 is ignored; every read and write is guarded, so a private window just forgets. localStorage.removeItem("weft.devtools") resets it.
| Field | Type | Holds |
|---|---|---|
v | 1 | The format version |
mode | "float" or "dock" | The layout mode |
side | "left", "right", "bottom" or "top" | The docked edge |
open | boolean | Expanded |
hidden | boolean | Hidden: nothing drawn |
x, y, w, h | number, px | The float’s box (default 520×560, at least 360×280) |
d | number, px | The dock’s size across its edge (default 460) |
run | string | The last selected turn, by run id |
theme | "light", "dark" or "" | The ◐ choice; "" is auto |
tab | "story", "request", "waterfall" or "raw" | The turn view’s open tab. Another value (a "timeline" stored before 0.20.0) opens story, or raw when raw is true |
raw | boolean | Mirrors tab being raw; a document without tab opens raw when it is true |
debug | boolean | The force-on switch |
The placement fields, mode through d, are written only once the user places the panel (a toggle, drag, resize or re-dock); until then the data-* attributes decide on every load. An old localStorage.weft_debug=1 is migrated into debug and removed.