Build a panel#
A panel is a page of your own HTML in the sidebar, with a workflow as its API. At the end you will have a panel of your open GitHub pull requests, and the shape most panels settle into: one workflow that answers like a small JSON API, a script that calls it, and a refresh loop.
What you will build#
A "Pull requests" page in your sidebar: one row per open pull request in a repository, with its author and how long ago it changed. Selecting a row opens it on GitHub, a button copies the branch name, and the sidebar entry shows how many are waiting for review. It refreshes itself while you look at it.
Prerequisites#
- A GitHub connection in Settings → Connections. GitHub Apps in Verdalia covers the App kind; an ordinary GitHub sign-in works for this guide too.
- Workflow basics, for the workflow editor and Set Workflow Output.
How a panel is put together#
A panel is HTML in a sandboxed frame, and its API is a workflow: the workflow is the panel's
endpoint and reaches your workspace's connections and systems, such as GitHub, safely on the
panel's behalf. The panel talks to it through window.verdalia:
verdalia.api.executeWorkflowruns a workflow the panel lists, as the person viewing it, and returns that workflow's output. Everything the panel does to the world goes through here.verdalia.api.queryTablereads rows from a table the panel lists, with no workflow involved.verdalia.api.onEventreceives the events workflows send with a Send User Event step, so the panel can read again when something it shows has changed.verdalia.appreaches the page around the panel: open a link, put state in the address, copy text, set the count on the sidebar entry.verdalia.storagekeeps a small value in the viewer's browser between visits; see the Panels docs.verdalia.contextsays who is looking, in which workspace, and in which timezone.
The panel's HTML is the view. The workflows are its backend, and they are ordinary workflows: you can run them from the editor, read their runs, and call them from agents.
The HTML is one of the panel's files. The others are scripts, stylesheets and SVG images that
belong to the same version, plus the built-in vendor libraries the version lists; the HTML loads
each by name as asset:NAME. Each Save makes a new version, and the version marked Current
is what everyone sees. Switching to an older version is how you roll back.
An Input node receives the input the panel sends. A JavaScript node connected to it reads
that value as inputs.input, and what the script returns is the node's output.
One workflow per panel, shaped like an API#
A panel that grows ends up calling several operations: list, get one, do something. Give each panel (or each subject, if several panels share one) a single workflow with one entry per operation, and make every entry answer the same shape:
{ "ok": true, "result": { "...": "..." } }
{ "ok": false, "error": { "code": "not_found", "message": "No such pull request" } }
There are two ways to have several entries in one workflow.
Several Input nodes. Each operation is its own island: an Input node, the work, a Set
Workflow Output. The panel names the island with startNode, the Input node's id. Use this by
default; each operation reads on its own in the editor and in run history.
One Input node and a Branch. The input is { method, params }, and a Branch node in key
mode routes on inputs.input.method. A method nobody listed goes to the Branch's default output,
so wire default to a node that answers
{ ok: false, error: { code: 'unknown_method', message: 'Unknown method' } }. Use this when the
operations share their first steps.
With several Input nodes, each island has its own Set Workflow Output. With a Branch, wire every
path into the value socket of one Set Workflow Output: only one path runs, so the output is
set once, and a second set would fail the run.
Declining and failing are different answers#
The ok: false shape is for a run that worked and declined: the pull request is already merged,
or has conflicts. The workflow decides that and says so in its output.
A node that fails is not a decline, and the workflow does not turn it into one. Leave every node's
Failure mode at Stop branch (default). When GitHub refuses a call, the GitHub node fails with
GitHub's explanation, nothing that depends on it runs, the run is marked failed, and the panel's
call throws workflow_failed with a message saying why. The other codes a call can throw are under
"When a call fails" in Panels.
To answer a failed read with a decline instead, set the GitHub node to Route to error output
and wire its error output into a JavaScript step that returns { ok: false, error: { code, message } }, then wire that step into the same input of Set Workflow Output as the success path.
Fail workflow stops every branch of the run at once, and is for rare emergencies; Stop
branch already fails the run.
So the output a panel receives is always the shape its workflow set, and one small helper turns a decline into a thrown error, beside the failures that already throw:
const API = 'pull-requests-a1b2c3-d4e5f6' // your workflow's slug or id, from its address
const ENTRIES = { list: 'input', merge: 'input-2' } // the Input nodes' ids
async function api(method, params = {}, onProgress) {
const { output } = await verdalia.api.executeWorkflow({
workflow: API, startNode: ENTRIES[method], input: params, onProgress,
})
if (!output.ok) throw new Error(output.error.message)
return output.result
}
workflow is the workflow's slug or its id. The slug is the last part of the address while the
workflow is open, and carries a suffix of its own, so copy it rather than writing the name: a name
such as 'pull-requests' resolves to no workflow, and the call fails. The panel may call only the
workflows under its Workflows it may run, and any other call is refused with not_allowed.
startNode is an Input node's id; Get workflow lists every node's id.
When the data is already in a table#
If a workflow already writes the data into a table (a webhook that records orders, a nightly sync),
the panel can read that table with queryTable and skip the workflow for reads. Add the table
under Tables it may read on the panel. The panel can then read every row and column of it, so
keep anything it should not show in another table. A panel changes a table through a workflow.
A read through a workflow is a run each time, and shows in the workflow's run history. A table read is not, which matters for a panel that refreshes every thirty seconds.
Build the pull-request panel#
1. Create the workflow. Name it "Pull requests". Add an Input node, and connect it to a
GitHub node with your connection and the List Pull Requests operation. Set Repo to the
repository's name, and Owner to its account; left empty, Owner is the connection's own
account. Leave State at open, and set Limit to 100, the most one call returns: it starts
at 20.
2. Shape the answer. Add a JavaScript node after the GitHub node. Its input is the GitHub
node's output: the pull requests under pull_requests, beside limit, offset, count,
has_more and next_offset. Each item is GitHub's pull-request object as GitHub lists it, passed
through unchanged, and it is large; send the panel only what it draws:
const { pull_requests, has_more } = inputs.input
const prs = pull_requests.map((pr) => ({
number: pr.number,
title: pr.title,
url: pr.html_url,
branch: pr.head.ref,
author: pr.user.login,
draft: pr.draft,
waiting: !pr.draft && pr.requested_reviewers.length + pr.requested_teams.length > 0,
updated: pr.updated_at,
}))
return { ok: true, result: { prs, more: has_more, now: new Date().toISOString() } }
The item fields used here were read off a real List Pull Requests run on 13 November 2026; the
GitHub node's documentation lists the envelope (pull_requests, has_more and the rest) but not
the fields of an item. A listed item is GitHub's list shape, which is not the whole of what Get
Pull Request returns: in that run, items had no mergeable, merged, additions, commits or
review_comments. Read those with Get Pull Request for one pull request when a panel needs
them. waiting counts a pull request with anyone in requested_reviewers or requested_teams,
both lists in that run; when GitHub takes a reviewer off those lists was not part of what it showed.
more is true when the repository has more than 100 open pull requests; the panel says so rather
than presenting the first 100 as all of them. now is the server's clock. The panel computes
"2 hours ago" against it, so a viewer whose computer clock is off still sees the right age.
3. Return it. Wire the JavaScript node into a Set Workflow Output. Run the workflow from the editor, check the output, and copy the workflow's slug from the address.
4. Create the panel. In Settings → Panels, select New panel, name it "Pull requests",
and add the workflow under Workflows it may run. Then add verdalia-kit-1.css and
verdalia-kit-1.js under Vendor libraries, the panel kit the HTML below uses.
5. Write the HTML. Put your workflow's slug, or its id, in API.
<link rel="stylesheet" href="asset:verdalia-kit-1.css">
<script src="asset:verdalia-kit-1.js"></script>
<style>
body { margin: 0; padding: 16px; font: 14px system-ui;
background: var(--verdalia-color-surface-primary, #16171a);
color: var(--verdalia-color-text-primary, #bcbdc1); }
.row { display: flex; gap: 12px; padding: 8px 0;
border-bottom: 1px solid var(--verdalia-color-border-subtle, rgb(255 255 255 / 0.06)); }
.title { flex: 1; padding: 0; border: 0; background: none; font: inherit; color: inherit;
text-align: left; cursor: pointer; }
.meta { color: var(--verdalia-color-text-secondary, #7d7e81); }
</style>
<h2>Pull requests</h2>
<p id="status" class="meta"></p>
<div id="list"></div>
<p id="more" class="meta"></p>
<script>
const API = 'pull-requests-a1b2c3-d4e5f6' // your workflow's slug or id, from its address
async function api(params = {}) {
const { output } = await verdalia.api.executeWorkflow({ workflow: API, input: params })
if (!output.ok) throw new Error(output.error.message)
return output.result
}
function render({ prs, more, now }) {
const list = document.getElementById('list')
list.replaceChildren(...prs.map((pr) => {
const row = document.createElement('div')
row.className = 'row'
const title = document.createElement('button')
title.className = 'title'
title.textContent = `#${pr.number} ${pr.title}`
title.onclick = () => verdalia.app.open(pr.url)
const meta = document.createElement('span')
meta.className = 'meta'
meta.textContent = `${pr.author} · ${VerdaliaKit.relativeTime(pr.updated, now)}`
const copy = document.createElement('button')
copy.textContent = 'Copy branch'
copy.onclick = async () => {
await verdalia.app.copy(pr.branch)
VerdaliaKit.toast(`Copied ${pr.branch}`)
}
row.append(title, meta, copy)
return row
}))
document.getElementById('more').textContent = more ? 'Showing the first 100.' : ''
verdalia.app.badge(prs.filter((pr) => pr.waiting).length)
}
async function refresh() {
try {
render(await api())
document.getElementById('status').textContent = ''
} catch (error) {
document.getElementById('status').textContent = error.message
}
}
verdalia.ready.then(refresh)
</script>
Titles and authors go in with textContent, never innerHTML: they are text someone else wrote.
6. Save and add to the sidebar. Select Save, then Add to navigation.
Note: A reference to a file the version does not hold shows in the editor as "No file named
verdalia-kit-1.js", and the panel loads without it: VerdaliaKit is then undefined and the script
stops at the first call. Add the vendor library, and the message goes.
Note: Open links with verdalia.app.open(url). A web address (http or https) opens in a
new tab, and a path in your workspace opens that page. A plain <a href> replaces the panel with
"This panel tried to load another page, so it was stopped."
Keep it fresh#
A dashboard you leave open needs a loop that reads often enough, never piles calls up, and keeps something on screen when a read fails.
let reading = null
const setStatus = (text) => { document.getElementById('status').textContent = text }
function read() {
reading ??= api()
.then((data) => { render(data); setStatus('') })
.catch((error) => setStatus(error.message))
.finally(() => { reading = null })
return reading
}
setInterval(() => { if (document.visibilityState === 'visible') read() }, 30_000)
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'visible') read()
})
- Read one at a time: a second
read()while one is running gets the same promise. A panel can have four calls running at once, and the fifth fails withbusy. - Poll only while the panel is visible; a hidden browser tab costs runs and shows nothing.
- Keep the last good data. A failed read leaves the rows from the last one on screen; show the
message beside a Retry button that calls
read(). - After a write, put what it returned into the rows at once. Then
await readingand callread()again, so the list is read after the write, not before it.
When the data lives in a table, queryTable makes the poll free of runs; the loop is the same.
A panel that refreshes when a workflow says so#
A poll reads on a timer whether anything changed or not. When the change is made by one of your workflows, that workflow can announce it instead, and the panel reads only when there is something new to read.
Three pieces do this:
- Send User Event is a workflow step that sends a small event: a key such as
notes.saved, and a JSON payload. With Send to listening clients on, the event goes to every client connected to the workspace (the web, desktop and mobile apps of every member), and to every panel open in them that listens on that key. verdalia.api.onEvent(key, listener)in the panel callslistenerwith{ key, payload, sentAt }for each event on that exact key, and returns a function that stops listening. One call per key.- On User Event is a trigger that starts a workflow on the same events, so one event can update panels and start workflows at once.
An event says that something changed, not what it changed to. Its payload names the record, such
as { "document_id": "01M7BX3ZEQPHGZRWDXGXE2GF7Q" }, and the panel reads the record through its
own workflow, as it does when it loads. The payload is capped at 1,024 characters, which is plenty
for an id and nothing like enough for a document.
A panel receives only the events sent while it is open. After a reload, a new version, or a dropped connection, nothing missed is sent again, so the panel always reads once when it loads and treats every event as "read again".
The example: a panel that shows one note from your Library, and refreshes whenever a "Save note" workflow changes it.
1. Give the panel a read workflow. Name it "Note". An Input node feeds a Library node
with the Get Document operation, which reads the document named by document_id in its input.
A JavaScript node shapes the answer, and a Set Workflow Output returns it:
const { id, name, content } = inputs.input
return { ok: true, result: { id, name, content } }
2. Announce the save. In the "Save note" workflow, after the Library node with the
Update Document operation, add a Send User Event step. Set its key to notes.saved, its
payload to { "document_id": "{{ input.id }}" }, and turn on Send to listening clients. The
Library node's output carries the document's id, which the payload template reads.
3. Write the panel. Grant it the "Note" workflow under Workflows it may run. "Save note" needs no grant: the panel never runs it.
<h2 id="title"></h2>
<div id="body"></div>
<p id="status" class="meta"></p>
<script>
const NOTE = 'note-a1b2c3-d4e5f6' // the Note workflow's slug or id
const DOCUMENT = '01M7BX3ZEQPHGZRWDXGXE2GF7Q' // the id of the document this panel shows
let reading = null
function read() {
reading ??= verdalia.api.executeWorkflow({ workflow: NOTE, input: { document_id: DOCUMENT } })
.then(({ output }) => {
if (!output.ok) throw new Error(output.error.message)
document.getElementById('title').textContent = output.result.name
document.getElementById('body').textContent = output.result.content
document.getElementById('status').textContent = ''
})
.catch((error) => { document.getElementById('status').textContent = error.message })
.finally(() => { reading = null })
return reading
}
verdalia.api.onEvent('notes.saved', (event) => {
if (event.payload.document_id === DOCUMENT) read()
})
verdalia.ready.then(read)
</script>
onEvent may be called before verdalia.ready; the panel starts listening once it connects.
Note: The payload carries the document's id, so the panel compares ids. A panel that keeps the
document's slug instead, such as weekly-briefing-a1b2c3, never matches, and never refreshes.
4. Publish it and try it. Select Save, Publish and Add to navigation, open the panel, and run "Save note" from the editor in another tab: the panel reads the note again as soon as the run reaches the Send User Event step.
Note: An event key is 1 to 64 characters: lowercase letters a–z, digits, ., _ and -,
starting with a letter or digit. verdalia.api.onEvent('Notes.Saved', …) throws invalid_input,
and a Send User Event step with that key shows a finding when saved and fails its run.
The same event starts every workflow whose On User Event trigger filters on notes.saved, or
has no filter. A workflow that sends a key its own trigger listens on starts itself again, so check
the run's key before sending. Any panel in the workspace can listen on any key; there is no
grant to add.
Act from a panel#
An action is another entry in the same workflow: "merge", "request review", "close".
- Ask first with
VerdaliaKit.confirm({ title, message, reasonLabel }). It resolves with{ confirmed, reason }, and the reason can travel to the workflow as a comment. - Show what will happen. Give risky actions a
previewentry that computes the effect without doing it ("merges 3 commits into main, deletes the branch"), and show that in the confirm. Theactentry then does it for real. - Report progress on long runs by passing
onProgress. It hears{ type: 'started', jobId }once the run starts,{ type: 'node', nodeId, state }as each step's state becomesstarted,completed,failedorskipped(nodeIdis the node's id in the workflow), and{ type: 'waiting', elapsedMs }while the run is still going. - Keep the logic in one place. If the real work already lives in another workflow, the panel's
entry calls it with a Subworkflow node, which starts that workflow at the Input node you
choose. The panel's workflow stays a thin layer of
{ ok, result }answers.
Note: Read failures and write failures deserve different treatment. Keep a failed read quiet and retry it; show a failed write where the person clicked, with its message.
What else a panel can do#
- Link into itself.
verdalia.app.setParams({ resourceId: '42' }, { history: 'push' })puts the open pull request in the address: a copied link opens the panel on it, and Back closes it. Read it back fromverdalia.app.paramsandonParamsChange. - Link out to the rest of Verdalia. Build paths with
verdalia.context.workspace.slugand open them withverdalia.app.open, so the same HTML works in any workspace. - Show times in the viewer's timezone, from
verdalia.context.viewer.timezone. - Load independent parts of a dashboard with separate calls and
Promise.allSettled, so a slow or broken source blanks one section, not the page. - Share a stylesheet or helper. A panel's files belong to its version, so give each panel that
needs one its own copy; changing one panel's file never changes another. Verdalia's built-in
vendor libraries (Preact, htm, uPlot and the UI kit) are shared without copying, and always the
current build. A stylesheet cannot load another file with
url(), so its images and fonts aredata:URLs. "Match Verdalia's look" in Panels says how to make a panel look like the rest of the app. - Remember a choice in a variable for the page load, or have a workflow store it if it should
last. Browser storage is not available to a panel, so
localStoragethrows. - Change it without breaking it. Save puts your edits live at once; if a version breaks the panel, Switch to this version on the one before puts it back, and an agent asked to restore that version writes it again as the newest. A version made without switching, by a push or an agent asked to stage it, waits under Versions until you switch to it.
- Find out why it is blank. Open your browser's developer console while the panel is open: what the panel logged, an error its script threw and did not catch, and a failed call are written there, each line marked with the panel.
The same panel with Preact#
Building elements by hand gets long once a panel has more than one list. The built-in UI kit,
@verdalia/ui, is Preact with components in Verdalia's look and hooks that keep a read's state.
Add verdalia-ui.js, verdalia-ui.css, verdalia-preact.js, verdalia-preact-hooks.js and
verdalia-htm.js under Vendor libraries: the UI kit imports the other three, and a save that
leaves one out is refused with the name of the missing library. The pull-request list becomes:
<link rel="stylesheet" href="asset:verdalia-ui.css">
<div id="app"></div>
<script type="module">
import {
html, render, useEffect, usePoll,
Section, List, ListItem, Button, ErrorNotice, relativeTime, toast,
} from '@verdalia/ui'
const API = 'pull-requests-a1b2c3-d4e5f6' // your workflow's slug or id, from its address
async function api(params = {}) {
await verdalia.ready
const { output } = await verdalia.api.executeWorkflow({ workflow: API, input: params })
if (!output.ok) throw new Error(output.error.message)
return output.result
}
function App() {
const { data, error, refresh } = usePoll(() => api(), 30_000)
useEffect(() => {
if (data) verdalia.app.badge(data.prs.filter((pr) => pr.waiting).length)
}, [data])
async function copy(event, branch) {
event.stopPropagation()
await verdalia.app.copy(branch)
toast(`Copied ${branch}`)
}
return html`
<${Section} title="Pull requests">
<${ErrorNotice} error=${error} onRetry=${refresh} />
<${List}>
${(data?.prs ?? []).map((pr) => html`
<${ListItem}
key=${pr.number}
meta=${`${pr.author} · ${relativeTime(pr.updated, data.now)}`}
actions=${html`<${Button} onClick=${(event) => copy(event, pr.branch)}>Copy branch</${Button}>`}
onClick=${() => verdalia.app.open(pr.url)}
>#${pr.number} ${pr.title}</${ListItem}>`)}
</${List}>
${data?.more ? html`<p>Showing the first 100.</p>` : null}
</${Section}>`
}
render(html`<${App} />`, document.getElementById('app'))
</script>
usePoll runs the loader now and every 30 seconds, and keeps the last rows on screen while it runs
again or after it fails, which is most of "Keep it fresh". Preact puts pr.title in as text, so
the innerHTML problem does not arise. useWorkflow does the same for an action, with running
for a busy button.
The same panel scales up to a project on your computer: JSX bundled with Vite into a folder a Relay can read, then pushed into the panel by an agent: "Push lights/dist in my projects mount to my Lights panel." "Build with Vite" and "Push a build" in Panels give the configuration, the kit's types and what a push takes.
Ask an agent to build one#
Agents have the same tools: they create panels, write their workflows and files, and choose vendor libraries. Their changes go live at once, and an agent can switch back to the version before; ask it to stage a change to keep it as a version you switch to yourself. What makes the result good is what you tell it:
- what the panel shows and what each button does, in your words;
- where the data comes from: a connection, a table, or an existing workflow to call;
- which actions need a confirmation, and which need a preview first;
- how often it should refresh;
- whether it should look like the rest of Verdalia, or follow a style you describe.
"Build a panel of my open pull requests in acme/web, one workflow with a list entry, refresh
every minute, copy the branch name, and show how many wait for review in the sidebar" is enough to
get the panel in this guide.
Next steps#
Panels lists every call, code and limit used here.