Skip to content

Devtools panel reference

View as Markdown

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">

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.

AttributeMeta tagValuesDefaultA change
data-endpointweft:endpointStudio’s base URL, http or https, a trailing / added; another scheme and the panel does not start; an empty value sets nothingthe 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-scopeweft:scopethe 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-idweft:public-ida public id: the older, deprecated spelling of data-scopenone; data-scope wins at the same runglive: rescopes
data-tokenweft:tokena bearer token: a panel token in pages you shipnone (setup A)live: a new connection
data-detectweft:detectheaders, markers, headers,markers (any order, any case), or off; off anywhere wins, another word makes it unsetunset: 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 tokenlive
data-positionweft:positionbottom-right, bottom-left, right-dock, left-dock, top-dock, bottom-dock; another value reads as the defaultbottom-rightlive: moves the dock, keeps its size. The user’s stored placement wins over it on load
data-openweft:open"true", or the attribute present and emptycollapsed (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-modeweft:modefloat, dock, pill, hiddenfrom position and openread 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-pushweft:push"true"offlive
data-z-indexweft:z-indexan integer, trimmed--weft-z on the element, else 2147483000live
data-themeweft:themelight, dark (any case, trimmed); anything else is autoauto: the stored ◐ choice, then the page’s <html> (data-theme, then class="dark" or "light", then its color-scheme), then prefers-color-scheme, else darklive
data-autoweft:autoany value but "false" is ononread 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-globalweft:globaloff or false (any case) turns it offon: window.weft.devtools while the panel is connectedlive

“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:

AttributeOnMeaning
data-weftthe panel’s <script> tagMarks 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-scopeany element of your pageA 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-untrustedany element of your pageMarkers 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:

InputValuesEffect
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 onceDetection 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 URLdebugMounts the dock even where data-auto is off (Install)

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.

OptionTypeDefaultField
endpointstringthe page’s directory, when nothing else names onedata-endpoint
scopeScope | stringnone; wins over publicIddata-scope
publicIdstringnone; "" is the dev listdata-public-id
detect"headers" | "markers" | "headers,markers" | "off"unsetdata-detect
tokenstringnonedata-token
positionPosition"bottom-right"data-position
openbooleanthe last open() or close(), else collapsed; replacing the self-mounted dock carries its open statedata-open
autobooleantruedata-auto; has no effect on the element mount() makes
theme"auto" | "light" | "dark""auto"data-theme
modeModeunsetwritten as data-mode
pushbooleanunsetwritten as data-push
zIndexnumber | stringunsetwritten as data-z-index
targetElementdocument.body; before <body> exists, appended on DOMContentLoadedwhere the element is appended
enabledbooleantruefalse: 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:

TypeDefinition
Position"bottom-right" | "bottom-left" | "right-dock" | "left-dock" | "top-dock" | "bottom-dock"
Mode"float" | "dock" | "pill" | "hidden"
PanelOptionsMountOptions 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.

<weft-devtools>’s public members. The npm package types them as WeftDevtoolsElement.

MemberSignatureWhat it does
openopen(): voidExpand the dock; from hidden it opens
closeclose(): voidCollapse the dock to the pill
toggletoggle(): voidFlip the dock; from hidden it opens
isOpenreadonly isOpen: booleanWhether the dock is expanded: a property, not a function
scopescope(s: Scope | string | null): voidSet 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
selectselect(runId: string, step?: number): voidSelect that turn, and the step by its ordinal, once a scope() just before has settled
onon(event: "run" | "parked" | "error", cb: (detail) => void): () => voidFollow this panel’s events; returns the unsubscribe
studioLinkstudioLink(runId: string, step?: number): stringThe Studio page of that run (and step), never with a token; "" before the endpoint is known
optionsPanelOptions | nullRung 1: what mount() passed
autoMountedbooleantrue 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
rescanrescan(): voidRe-read the configuration ladder and apply it
syncGlobalsyncGlobal(): voidPublish 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.

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.

@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).

ExportSignatureDiffers from the element
mountmount(opts?: MountOptions): WeftDevtoolsElement | nullCreates the panel (MountOptions)
open, close(): voidAct on every panel; a panel mounted later starts that way
toggle(): voidFlips every panel there now
isOpenisOpen(): booleanA function: whether any panel is expanded; false with none
scopescope(s: Scope | string | null): voidEvery panel; a panel mounted later starts in it
selectselect(runId: string, step?: number): voidEvery panel
studioLinkstudioLink(runId: string, step?: number): stringThe first panel’s link; "" with none
onon(event, cb): () => voidListens on document: every panel, one mounted later included
serializeScope, parseScope(s: Scope): string, (str: string): ScopeThe scope’s string form
typesScope, 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.

SubpathExportsNotes
@weftgo/devtoolsthe table aboveImporting it loads panel.js, which defines the element and may self-mount the dock
@weftgo/devtools/reactuseWeftDevtools(opts): ref; types HelperOptions, ScopeA callback ref for React 18 and 19
@weftgo/devtools/vueuseWeftDevtools(opts or () => opts): ref; types HelperOptions, ScopeA function ref for Vue 3; pass a getter to follow reactive state
@weftgo/devtools/svelteweftDevtools(node, opts), useWeftDevtools; types HelperOptions, ScopeA Svelte action (3, 4 and 5)
@weftgo/devtools/scopeserializeScope, parseScope, ScopeNo DOM: safe in server code
@weftgo/devtools/panel.jsthe bundle itselfThe same bytes as /studio/panel.js
@weftgo/devtools/package.jsonthe 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.

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.

EventdetailWhen
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.

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.

TokenUsed forLightDarkStudio variable
--weft-bgpanes#fbfaf7#131211background
--weft-bg2header, steps, footer#fbfaf7#1c1a17card
--weft-bg3selected row, fields#f3f1ea#2a2722secondary (light), sidebar-accent (dark)
--weft-fgtext#191713#ece6d6foreground
--weft-dimsecondary text#6e6759#a39c8fmuted-foreground
--weft-faintthe faintest text#766f61#8d887bthe panel’s own (light), code-mut (dark)
--weft-linerules and borders#e7e3d9#2a2722border
--weft-accentthe accent#d13c10#ff7d52thread-ink
--weft-on-accenttext on the accent#fbfaf7#131211primary-foreground
--weft-warnerrors returned as data, interrupted, cancelled#875c04#e3b341status-int
--weft-errfailed runs and rows#b42318#f87171status-bad
--weft-infotool rows#2f5bd3#7aa2ffev-tool
--weft-oksucceeded, live, added diff lines#1f7a45#4ade80status-ok
--weft-resulta tool result’s tone#4d7a2a#8fbf6aev-result
--weft-parkedparked#8a3fb0#c678ddstatus-parked
--weft-status-runthe running dot, the pill’s pulse and border#ef4d21#ff5c2bstatus-run
--weft-status-run-inkthe running word#d13c10#ff5c2bstatus-run-ink
--weft-scrimthe ? overlay’s backdroprgba(251,250,247,.92)rgba(19,18,17,.92)the panel’s own
--weft-shadowthe float’s shadowrgba(25,23,19,.18)rgba(0,0,0,.45)the panel’s own
--weft-fontids, JSON, numbersui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospacesame
--weft-font-prosea step’s text, the prompt, notessystem-ui, sans-serifsame
--weft-radiuscorner radius8pxsame
--weft-radius-smsmall corner radius5pxsame
--weft-zthe dock’s and the pill’s z-index, below data-z-indexunset: 2147483000same

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.

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).

KeyDoes
Alt+WToggle 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+WNext layout: float, dock right, bottom, left, top
EscClose (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 / kNext / previous item of the list in focus (the turns)
[ / ]Previous / next step (⤢ carries it); K / J too
s / w / q / rThe story, waterfall, request or raw tab; again, back to the tab before it. Capitals work too
oOpen the turn, and the step picked, in Studio in a new tab
g sThe 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)
TabIn 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

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.

FieldTypeHolds
v1The format version
mode"float" or "dock"The layout mode
side"left", "right", "bottom" or "top"The docked edge
openbooleanExpanded
hiddenbooleanHidden: nothing drawn
x, y, w, hnumber, pxThe float’s box (default 520×560, at least 360×280)
dnumber, pxThe dock’s size across its edge (default 460)
runstringThe 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
rawbooleanMirrors tab being raw; a document without tab opens raw when it is true
debugbooleanThe 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.