---
/**
* The "how it works" stage of the landing page: an architecture diagram
* (host, sandboxes with your agents, the shared service, the dashboard, you,
* VS Code) next to the mini dashboard (`MiniTui.astro`), plus a lighter
* stacked diagram for tablet/mobile. The markup is the no-JS state (`STATIC`
* in `lib/mini-tui.ts`); `scripts/how-it-works.ts` mounts the dashboard and
* mirrors its state (selection, tab, VS Code, agent statuses) on the diagram.
*/
import {
Bot,
Code,
Container,
Database,
Files,
FolderGit2,
GitBranch,
LayoutDashboard,
Search,
UserRound,
} from '@lucide/astro';
import MiniTui from './MiniTui.astro';
type AgentStatus = 'editing' | 'testing' | 'idle' | 'waiting';
interface Instance {
name: string;
/** Where the instance's files live, relative to the config dir. */
folder: string;
/** Git branch of a worktree instance; the first instance uses your checkout. */
branch?: string;
status: AgentStatus;
statusLabel: string;
/** Diagram card x, in the 640 × 560 canvas units. */
x: number;
}
// Repeat instances of one sandbox get `.worktrees/<instance>` on
// `sandbox/<instance>` (the default branch pattern); the first uses `../web`.
const instances: Instance[] = [
{ name: 'web', folder: '../web', status: 'editing', statusLabel: 'editing', x: 16 },
{
name: 'web-2',
folder: '.worktrees/web-2',
branch: 'sandbox/web-2',
status: 'testing',
statusLabel: 'running tests',
x: 228,
},
{
name: 'web-3',
folder: '.worktrees/web-3',
branch: 'sandbox/web-3',
status: 'idle',
statusLabel: 'idle',
x: 440,
},
];
/** Initially selected instance (the first row, like the real dashboard). */
const selected = 'web';
const service = 'postgres';
// Canvas geometry (units of the 640 × 560 viewBox); the HTML nodes use the
// same numbers through `--x/--y/--w/--h`, so connectors meet the node edges.
const CARD_W = 184;
const CARD_TOP = 228;
const CARD_BOTTOM = 400;
const center = (i: Instance) => i.x + CARD_W / 2;
const dashboardLinks = instances.map((i) => {
const cx = center(i);
const sx = 320 + Math.sign(cx - 320) * 20;
return {
sandbox: i.name,
d: sx === cx ? `M${cx} 148 V${CARD_TOP}` : `M${sx} 148 C${sx} 196 ${cx} 184 ${cx} ${CARD_TOP}`,
};
});
const serviceLinks = instances.map((i) => {
const cx = center(i);
const ex = 320 + Math.sign(cx - 320) * 34;
return {
sandbox: i.name,
d: ex === cx ? `M${cx} ${CARD_BOTTOM} V452` : `M${cx} ${CARD_BOTTOM} C${cx} 436 ${ex} 420 ${ex} 452`,
};
});
// VS Code sits top-right (bottom edge at y 176); its link lands right of centre.
const vscodeLinks = instances.map((i) => {
const tx = center(i) + 28;
return {
sandbox: i.name,
d: tx === 560 ? `M560 176 V${CARD_TOP}` : `M560 176 C560 206 ${tx} 198 ${tx} ${CARD_TOP}`,
};
});
const title = (i: Instance) => `${i.name} · ${i.branch ?? i.folder} — Dev Container`;
---
<div class="hiw" data-pagefind-ignore>
<p class="visually-hidden">
Diagram: on your machine, the devsandbox dashboard is connected to three sandboxes, web, web-2 and web-3. Each is
its own container with an agent you run inside it: web uses your checkout in ../web, web-2 and web-3 their own git
worktrees on branches sandbox/web-2 and sandbox/web-3. All three share one postgres service. From the dashboard you
open any sandbox in VS Code, attached to its container.
</p>
<div class="hiw-stage" data-hiw data-selected={selected} data-tab="instances">
<div class="hiw-diagram" aria-hidden="true">
<div class="hiw-canvas">
<svg class="hiw-links" viewBox="0 0 640 560" fill="none">
<path class="hiw-link hiw-link--you" data-connector="you" d="M320 54 V88" pathLength="1" />
{
dashboardLinks.map((l) => (
<path
class="hiw-link hiw-link--dashboard"
data-connector="dashboard"
data-sandbox={l.sandbox}
data-active={l.sandbox === selected ? '' : undefined}
d={l.d}
pathLength="1"
/>
))
}
{
serviceLinks.map((l) => (
<path class="hiw-link hiw-link--service" data-connector="service" data-sandbox={l.sandbox} d={l.d} pathLength="1" />
))
}
{
vscodeLinks.map((l) => (
<path class="hiw-link hiw-link--vscode" data-connector="vscode" data-sandbox={l.sandbox} d={l.d} pathLength="1" />
))
}
{/* Ambient "traffic": one short dash travelling along each link. */}
{
dashboardLinks.map((l, i) => (
<path class="hiw-pulse hiw-pulse--dashboard" style={`--p: ${i}`} d={l.d} pathLength="1" />
))
}
{
serviceLinks.map((l, i) => (
<path class="hiw-pulse hiw-pulse--service" style={`--p: ${i}`} d={l.d} pathLength="1" />
))
}
</svg>
<div class="hiw-host" style="--x: 0; --y: 36; --w: 640; --h: 524">
<div class="hiw-host-label"><span>HOST</span> your machine</div>
<div class="hiw-host-runtime">
<span class="hiw-runtime-label">RUNTIME</span>
<span>docker</span><span>podman</span><span>Apple container</span>
</div>
</div>
<div class="hiw-node hiw-you" data-node="you" style="--x: 272; --y: 18; --w: 96; --h: 36">
<UserRound aria-hidden="true" /> you
</div>
<div class="hiw-node hiw-dashboard" data-node="dashboard" style="--x: 235; --y: 88; --w: 170; --h: 60">
<span class="hiw-node-icon"><LayoutDashboard aria-hidden="true" /></span>
<span class="hiw-node-copy">
<strong>dashboard</strong>
<span>devsandbox · TUI</span>
</span>
</div>
{
instances.map((i) => (
<div
class="hiw-sandbox"
data-sandbox-node={i.name}
data-selected={i.name === selected ? '' : undefined}
style={`--x: ${i.x}; --y: ${CARD_TOP}; --w: ${CARD_W}; --h: ${CARD_BOTTOM - CARD_TOP}`}
>
<div class="sb-head">
<span class="sb-icon">
<Container aria-hidden="true" />
</span>
<span class="sb-name">{i.name}</span>
<span class="sb-state" data-sb-state={i.name}>
<i />
<span data-sb-state-label>running</span>
</span>
</div>
<div class={`sb-tree${i.branch ? ' is-worktree' : ''}`}>
{i.branch ? <GitBranch aria-hidden="true" /> : <FolderGit2 aria-hidden="true" />}
{i.branch ?? i.folder}
</div>
<div class="sb-path">{i.branch ? i.folder : 'your checkout'}</div>
<div class="sb-agent" data-agent={i.name} data-status={i.status}>
<span class="agent-icon">
<Bot aria-hidden="true" />
</span>
<span class="agent-copy">
<span class="agent-label">your agent</span>
<span class="agent-status">
<i />
<span data-agent-status>{i.statusLabel}</span>
</span>
</span>
</div>
</div>
))
}
<div class="hiw-node hiw-service" data-node="service" style="--x: 236; --y: 452; --w: 168; --h: 46">
<span class="hiw-node-icon"><Database aria-hidden="true" /></span>
<span class="hiw-node-copy">
<strong>{service}</strong>
<span>shared service</span>
</span>
</div>
<div class="hiw-vscode" data-vscode data-open="false" data-target="web-2" style="--x: 416; --y: 40; --w: 224; --h: 136">
<div class="vsc-bar">
<Code aria-hidden="true" />
{
instances.map((i) => (
<span class="vsc-title" data-vscode-for={i.name} hidden={i.name !== 'web-2'}>
{title(i)}
</span>
))
}
</div>
<div class="vsc-body">
<div class="vsc-activity">
<Files aria-hidden="true" />
<Search aria-hidden="true" />
<GitBranch aria-hidden="true" />
</div>
<div class="vsc-editor">
<i style="--w: 46%; --c: #85dce0"></i>
<i style="--w: 70%; --c: #b7ea89; --in: 1"></i>
<i style="--w: 58%; --c: #c9e0d7; --in: 1"></i>
<i style="--w: 34%; --c: #668086; --in: 2"></i>
<i style="--w: 62%; --c: #b7ea89; --in: 1"></i>
<i style="--w: 20%; --c: #dae8d7"></i>
</div>
</div>
<div class="vsc-status">
{
instances.map((i) => (
<span class="vsc-remote" data-vscode-for={i.name} hidden={i.name !== 'web-2'}>
<span aria-hidden="true">><</span> Container devsandbox-{i.name}
</span>
))
}
</div>
</div>
</div>
</div>
<MiniTui id="hiw-tui" autoplay />
</div>
{/* Tablet / mobile: a stacked, CSS-only version of the same picture. */}
<div class="hiw-flow" aria-hidden="true">
<div class="flow-you"><UserRound /> you</div>
<div class="flow-host">
<div class="flow-host-label"><span>HOST</span> docker · podman · Apple container</div>
<div class="flow-node flow-dashboard">
<span class="hiw-node-icon"><LayoutDashboard /></span>
<span class="hiw-node-copy"><strong>dashboard</strong><span>devsandbox · TUI</span></span>
</div>
<ul class="flow-sandboxes">
{
instances.map((i) => (
<li class={i.name === 'web-2' ? 'is-attached' : undefined}>
<span class="sb-icon">
<Container />
</span>
<span class="flow-sb-copy">
<span class="sb-name">{i.name}</span>
<span class={`sb-tree${i.branch ? ' is-worktree' : ''}`}>
{i.branch ? <GitBranch /> : <FolderGit2 />}
{i.branch ?? i.folder}
</span>
</span>
<span class="sb-agent" data-status={i.status}>
<Bot />
<span class="agent-status">
<i />
{i.statusLabel}
</span>
</span>
</li>
))
}
</ul>
<div class="flow-bottom">
<div class="flow-node flow-service">
<span class="hiw-node-icon"><Database /></span>
<span class="hiw-node-copy"><strong>{service}</strong><span>shared by all three</span></span>
</div>
<div class="flow-node flow-vscode">
<span class="hiw-node-icon"><Code /></span>
<span class="hiw-node-copy"><strong>VS Code</strong><span>attached to web-2</span></span>
</div>
</div>
</div>
</div>
</div>
<ol class="hiw-steps">
<li>
<span class="hiw-step-no">01</span>
<h3>Define sandboxes once</h3>
<p>A <code>devsandboxes.toml</code> names the image, your repo folder and the services, like postgres.</p>
</li>
<li>
<span class="hiw-step-no">02</span>
<h3>One sandbox per agent</h3>
<p>Each <code>devsandbox run</code> starts a container on its own worktree and branch. Start your agent inside it.</p>
</li>
<li>
<span class="hiw-step-no">03</span>
<h3>Watch and jump in</h3>
<p>The dashboard shows every sandbox and the notifications sent from inside. Press <code>o</code> to open one in VS Code.</p>
</li>
</ol>
<script>
import '../scripts/how-it-works';
</script>
<style>
/* A card whose container the dashboard stopped (`s`, `:stop`): red like its STATUS cell. */
[data-sb-state][data-exited] {
color: #f08080;
}
</style>