Skip to content

An open-source, faster Devin alternative

TypeScript

tour with offramps

Brian Reardon465c5284c6bb
diff --git a/web/src/components/code-off-ramp.tsx b/web/src/components/code-off-ramp.tsx
new file mode 100644
index 00000000..a9b0e4c4
--- /dev/null
+++ b/web/src/components/code-off-ramp.tsx
@@ -0,0 +1,105 @@
+import { useState } from 'react'
+import { Check, ChevronDown, Code2, Copy, ExternalLink } from 'lucide-react'
+import { Button } from '@/components/ui/button'
+import { useTransientFlag } from '@/lib/use-transient-flag'
+import { notifyError } from '@/lib/errors'
+import { cn } from '@/lib/utils'
+
+export type CodeTab = { label: string; code: string }
+
+/**
+ * A collapsible "dev off-ramp": a muted "</> Show code" toggle that expands to
+ * tabbed, copyable code (SDK / CLI / cURL) for whatever the adjacent one-click
+ * button does under the hood. Collapsed by default so it never touches the
+ * guided happy path — technical users pop it to see that the dashboard is just a
+ * thin client over the public API/SDK, and copy the exact call.
+ */
+export function CodeOffRamp({
+ tabs,
+ docs,
+ label = 'Show code',
+ className,
+}: {
+ tabs: CodeTab[]
+ docs?: string
+ label?: string
+ className?: string
+}) {
+ const [open, setOpen] = useState(false)
+ const [active, setActive] = useState(0)
+ const [copied, markCopied] = useTransientFlag(1500)
+
+ const current = tabs[active] ?? tabs[0]
+
+ const copy = () => {
+ void navigator.clipboard.writeText(current.code).then(
+ () => markCopied(),
+ (e: unknown) => notifyError("Couldn't copy to clipboard.", e),
+ )
+ }
+
+ return (
+ <div className={className}>
+ <button
+ type="button"
+ onClick={() => setOpen((o) => !o)}
+ className="text-muted-foreground hover:text-foreground inline-flex items-center gap-1.5 text-xs font-medium transition-colors"
+ aria-expanded={open}
+ >
+ <Code2 className="size-3.5" />
+ {label}
+ <ChevronDown
+ className={cn(
+ 'size-3.5 transition-transform',
+ open ? '' : '-rotate-90',
+ )}
+ />
+ </button>
+
+ {open ? (
+ <div className="mt-2 overflow-hidden rounded-md border">
+ <div className="bg-panel-2 flex items-center gap-1 border-b px-2 py-1.5">
+ {tabs.map((t, i) => (
+ <button
+ key={t.label}
+ type="button"
+ onClick={() => setActive(i)}
+ className={cn(
+ 'rounded px-2 py-1 text-xs font-medium transition-colors',
+ i === active
+ ? 'bg-background text-foreground'
+ : 'text-muted-foreground hover:text-foreground',
+ )}
+ >
+ {t.label}
+ </button>
+ ))}
+ <div className="flex-1" />
+ {docs ? (
+ <a
+ href={docs}
+ target="_blank"
+ rel="noreferrer"
+ className="text-muted-foreground hover:text-foreground inline-flex items-center gap-1 px-2 py-1 text-xs underline-offset-4 hover:underline"
+ >
+ Docs
+ <ExternalLink className="size-3" />
+ </a>
+ ) : null}
+ <Button variant="ghost" size="xs" onClick={copy}>
+ {copied ? (
+ <Check className="size-3.5" />
+ ) : (
+ <Copy className="size-3.5" />
+ )}
+ {copied ? 'Copied' : 'Copy'}
+ </Button>
+ </div>
+ <pre className="bg-panel-2 overflow-x-auto px-3 py-3 text-[12.5px] leading-relaxed">
+ <code className="text-foreground font-mono">{current.code}</code>
+ </pre>
+ </div>
+ ) : null}
+ </div>
+ )
+}
diff --git a/web/src/components/guided-tour.tsx b/web/src/components/guided-tour.tsx
new file mode 100644
index 00000000..b4176ed4
--- /dev/null
+++ b/web/src/components/guided-tour.tsx
@@ -0,0 +1,294 @@
+import { useEffect, useLayoutEffect, useRef, useState } from 'react'
+import { createPortal } from 'react-dom'
+import {
+ ArrowLeft,
+ ArrowRight,
+ Check,
+ Copy,
+ ExternalLink,
+ X,
+} from 'lucide-react'
+import { Button } from '@/components/ui/button'
+import { type CodeTab } from '@/components/code-off-ramp'
+import { useTransientFlag } from '@/lib/use-transient-flag'
+import { cn } from '@/lib/utils'
+
+export type GuideStep = {
+ /** The real UI element this step points at (spotlighted). */
+ target: React.RefObject<HTMLElement | null>
+ title: string
+ body: string
+ /** The API call that produced this region, e.g. "POST /v3/sessions". */
+ api?: string
+ /** Tabbed, copyable snippets of the real call (SDK / CLI / API). */
+ code?: CodeTab[]
+ docs?: string
+}
+
+const CALLOUT_W = 520
+const PAD = 8
+const M = 16 // viewport margin
+const GAP = 12 // gap between spotlight and callout
+
+const clamp = (v: number, lo: number, hi: number) =>
+ Math.max(lo, Math.min(v, hi))
+
+/**
+ * A first-run guided overlay: spotlights real UI regions on the destination view
+ * and, beside each, explains what it is + the exact public API call that
+ * produced it, with SDK / CLI / API tabs so people can jump to the path they
+ * care about. Non-blocking (the page behind stays usable); resize/scroll-safe.
+ */
+export function GuidedTour({
+ steps,
+ open,
+ onClose,
+}: {
+ steps: GuideStep[]
+ open: boolean
+ onClose: () => void
+}) {
+ const [i, setI] = useState(0)
+ const [tab, setTab] = useState(0)
+ const [rect, setRect] = useState<DOMRect | null>(null)
+ const [copied, markCopied] = useTransientFlag(1500)
+ const calloutRef = useRef<HTMLDivElement>(null)
+ const [calloutH, setCalloutH] = useState(360)
+
+ useEffect(() => {
+ if (open) {
+ setI(0)
+ setTab(0)
+ }
+ }, [open])
+
+ // Reset the code tab whenever the step changes.
+ useEffect(() => {
+ setTab(0)
+ }, [i])
+
+ // Measure the callout's real height so placement can avoid overlapping the
+ // spotlight (a fixed estimate misplaces short/tall callouts).
+ useLayoutEffect(() => {
+ if (calloutRef.current) setCalloutH(calloutRef.current.offsetHeight)
+ }, [open, i, tab, rect])
+
+ const step = steps[i]
+
+ // Measure the current target, scroll it into view, and keep the spotlight
+ // pinned to it through the smooth-scroll settle + any resize/scroll.
+ useLayoutEffect(() => {
+ if (!open || !step) return
+ const measure = () => {
+ const el = step.target.current
+ if (el) setRect(el.getBoundingClientRect())
+ }
+ step.target.current?.scrollIntoView({ behavior: 'smooth', block: 'center' })
+ measure()
+ const timers = [setTimeout(measure, 150), setTimeout(measure, 450)]
+ window.addEventListener('resize', measure)
+ window.addEventListener('scroll', measure, true)
+ return () => {
+ timers.forEach(clearTimeout)
+ window.removeEventListener('resize', measure)
+ window.removeEventListener('scroll', measure, true)
+ }
+ }, [open, i, step])
+
+ // Esc closes; arrows navigate.
+ useEffect(() => {
+ if (!open) return
+ const onKey = (e: KeyboardEvent) => {
+ if (e.key === 'Escape') onClose()
+ else if (e.key === 'ArrowRight' && i < steps.length - 1) setI((n) => n + 1)
+ else if (e.key === 'ArrowLeft' && i > 0) setI((n) => n - 1)
+ }
+ window.addEventListener('keydown', onKey)
+ return () => window.removeEventListener('keydown', onKey)
+ }, [open, i, steps.length, onClose])
+
+ if (!open || !step) return null
+
+ const spot = rect
+ ? {
+ top: rect.top - PAD,
+ left: rect.left - PAD,
+ width: rect.width + PAD * 2,
+ height: rect.height + PAD * 2,
+ }
+ : null
+
+ // Place the callout in whichever region around the spotlight has real room —
+ // below → above → right → left — so it never sits on top of the target. If the
+ // target is too big to clear (full-width, tall panels), dock it to the right
+ // edge (guaranteed on-screen).
+ const vw = window.innerWidth
+ const vh = window.innerHeight
+ let calloutTop = M
+ let calloutLeft = M
+ if (spot) {
+ const roomBelow = vh - (spot.top + spot.height)
+ const roomAbove = spot.top
+ const roomRight = vw - (spot.left + spot.width)
+ const roomLeft = spot.left
+ if (roomBelow >= calloutH + GAP + M) {
+ calloutTop = spot.top + spot.height + GAP
+ calloutLeft = clamp(spot.left, M, vw - CALLOUT_W - M)
+ } else if (roomAbove >= calloutH + GAP + M) {
+ calloutTop = spot.top - calloutH - GAP
+ calloutLeft = clamp(spot.left, M, vw - CALLOUT_W - M)
+ } else if (roomRight >= CALLOUT_W + GAP + M) {
+ calloutLeft = spot.left + spot.width + GAP
+ calloutTop = clamp(spot.top, M, vh - calloutH - M)
+ } else if (roomLeft >= CALLOUT_W + GAP + M) {
+ calloutLeft = spot.left - CALLOUT_W - GAP
+ calloutTop = clamp(spot.top, M, vh - calloutH - M)
+ } else {
+ calloutLeft = vw - CALLOUT_W - M
+ calloutTop = clamp(vh / 2 - calloutH / 2, M, vh - calloutH - M)
+ }
+ }
+
+ const tabs = step.code ?? []
+ const current = tabs[tab] ?? tabs[0]
+ const copy = () => {
+ if (current) void navigator.clipboard.writeText(current.code).then(markCopied)
+ }
+
+ return createPortal(
+ <div className="fixed inset-0 z-[100]" role="dialog" aria-modal="false">
+ {/* Spotlight: a ring around the target with a huge box-shadow scrim so
+ everything else dims. pointer-events-none → the page stays usable. */}
+ {spot ? (
+ <div
+ className="ring-primary pointer-events-none absolute rounded-lg ring-2 transition-all duration-200"
+ style={{
+ top: spot.top,
+ left: spot.left,
+ width: spot.width,
+ height: spot.height,
+ boxShadow: '0 0 0 9999px rgba(0,0,0,0.55)',
+ }}
+ />
+ ) : (
+ <div className="pointer-events-none absolute inset-0 bg-black/55" />
+ )}
+
+ {/* Callout */}
+ <div
+ ref={calloutRef}
+ className="bg-background absolute rounded-lg border p-4 shadow-xl"
+ style={{
+ top: calloutTop,
+ left: calloutLeft,
+ width: CALLOUT_W,
+ maxWidth: 'calc(100vw - 32px)',
+ }}
+ >
+ <div className="flex items-start justify-between gap-3">
+ <span className="text-muted-foreground text-xs">
+ Step {i + 1} of {steps.length}
+ </span>
+ <button
+ onClick={onClose}
+ aria-label="Close"
+ className="text-muted-foreground hover:text-foreground -mt-1 -mr-1"
+ >
+ <X className="size-4" />
+ </button>
+ </div>
+
+ <h3 className="text-foreground mt-1 text-sm font-semibold">
+ {step.title}
+ </h3>
+ <p className="text-muted-foreground mt-1 text-sm">{step.body}</p>
+
+ {step.api ? (
+ <div className="text-muted-foreground mt-2 font-mono text-xs">
+ {step.api}
+ </div>
+ ) : null}
+
+ {tabs.length > 0 ? (
+ <div className="bg-panel-2 mt-2 overflow-hidden rounded-md border">
+ <div className="flex items-center gap-1 border-b px-2 py-1.5">
+ {tabs.map((t, n) => (
+ <button
+ key={t.label}
+ type="button"
+ onClick={() => setTab(n)}
+ className={cn(
+ 'rounded px-2 py-1 text-xs font-medium transition-colors',
+ n === tab
+ ? 'bg-background text-foreground'
+ : 'text-muted-foreground hover:text-foreground',
+ )}
+ >
+ {t.label}
+ </button>
+ ))}
+ <div className="flex-1" />
+ <Button variant="ghost" size="xs" onClick={copy}>
+ {copied ? (
+ <Check className="size-3.5" />
+ ) : (
+ <Copy className="size-3.5" />
+ )}
+ {copied ? 'Copied' : 'Copy'}
+ </Button>
+ </div>
+ <pre className="max-h-[220px] overflow-auto px-3 py-3 text-[12.5px] leading-relaxed">
+ <code className="text-foreground font-mono whitespace-pre">
+ {current?.code}
+ </code>
+ </pre>
+ </div>
+ ) : null}
+
+ <div className="mt-3 flex items-center justify-between">
+ <div className="flex items-center gap-1.5">
+ {steps.map((_, n) => (
+ <span
+ key={n}
+ className={cn(
+ 'size-1.5 rounded-full',
+ n === i ? 'bg-primary' : 'bg-border',
+ )}
+ />
+ ))}
+ </div>
+ <div className="flex items-center gap-2">
+ {step.docs ? (
+ <a
+ href={step.docs}
+ target="_blank"
+ rel="noreferrer"
+ className="text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs underline-offset-4 hover:underline"
+ >
+ Docs
+ <ExternalLink className="size-3" />
+ </a>
+ ) : null}
+ {i > 0 ? (
+ <Button variant="ghost" size="sm" onClick={() => setI((n) => n - 1)}>
+ <ArrowLeft className="size-3.5" />
+ Back
+ </Button>
+ ) : null}
+ {i < steps.length - 1 ? (
+ <Button size="sm" onClick={() => setI((n) => n + 1)}>
+ Next
+ <ArrowRight className="size-3.5" />
+ </Button>
+ ) : (
+ <Button size="sm" onClick={onClose}>
+ Done
+ </Button>
+ )}
+ </div>
+ </div>
+ </div>
+ </div>,
+ document.body,
+ )
+}
diff --git a/web/src/pages/Dashboard.tsx b/web/src/pages/Dashboard.tsx
index 39234cb2..87cf53c5 100644
--- a/web/src/pages/Dashboard.tsx
+++ b/web/src/pages/Dashboard.tsx
@@ -31,6 +31,7 @@ import { PageHeader } from '@/components/page-header'
import { Panel, PanelHeader, PanelTitle } from '@/components/panel'
import { MetricCard } from '@/components/metric-card'
import { CopyRow } from '@/components/copy-row'
+import { CodeOffRamp, type CodeTab } from '@/components/code-off-ramp'
import { StatusBadge } from '@/components/status-badge'
import { EmptyState } from '@/components/empty-state'
import { ResourceTable, type Column } from '@/components/resource-table'
@@ -110,6 +111,80 @@ const SANDBOX_EXAMPLES: {
{ icon: Code2, label: 'Use from code', intent: { focus: 'connect' } },
]
+// Dev off-ramps: the exact public API/SDK/CLI calls each one-click card runs
+// under the hood. Surfaced (collapsed) so technical users see the dashboard is a
+// thin client over the API and can copy the real call. Kept in sync with the
+// launchMutation / createSandboxMutation bodies below.
+const AGENT_CODE: CodeTab[] = [
+ {
+ label: 'SDK',
+ code: `import { OpenComputer } from "@opencomputer/sdk";
+
+const oc = new OpenComputer({ apiKey: process.env.OPENCOMPUTER_API_KEY });
+
+// Create a managed agent — billed to your OpenComputer credits, no model key
+const agent = await oc.agents.create({
+ name: "my-agent",
+ runtime: "claude",
+ model: "anthropic/claude-opus-4-8",
+ prompt: "You are a helpful AI assistant working in a sandboxed computer.",
+ credential: "managed",
+});
+
+// Start a session — returns a browser-safe client token you can stream from
+const session = await oc.sessions.create({
+ agent: agent.id,
+ input: "Give me a quick tour of this sandbox.",
+});
+console.log(session.id, session.clientToken);`,
+ },
+ {
+ label: 'cURL',
+ code: `# 1. Create a managed agent
+curl -X POST https://api.opencomputer.dev/v3/agents \\
+ -H "Authorization: Bearer $OPENCOMPUTER_API_KEY" \\
+ -H "Content-Type: application/json" \\
+ -d '{"name":"my-agent","runtime":"claude","model":"anthropic/claude-opus-4-8","prompt":"You are a helpful AI assistant.","credential":"managed"}'
+
+# 2. Start a session on that agent
+curl -X POST https://api.opencomputer.dev/v3/sessions \\
+ -H "Authorization: Bearer $OPENCOMPUTER_API_KEY" \\
+ -H "Content-Type: application/json" \\
+ -d '{"agent":"agt_...","input":"Give me a quick tour of this sandbox."}'`,
+ },
+]
+
+const SANDBOX_CODE: CodeTab[] = [
+ {
+ label: 'SDK',
+ code: `import { Sandbox } from "@opencomputer/sdk";
+
+const sandbox = await Sandbox.create();
+
+const result = await sandbox.commands.run("python3 --version");
+console.log(result.stdout);
+
+// It stays alive until you kill it or it idles out
+await sandbox.kill();`,
+ },
+ {
+ label: 'CLI',
+ code: `# Create a sandbox
+oc create
+
+# Run a command in it — or drop into an interactive shell
+oc exec <sandbox-id> "python3 --version"
+oc shell <sandbox-id>`,
+ },
+ {
+ label: 'cURL',
+ code: `curl -X POST https://app.opencomputer.dev/api/sandboxes \\
+ -H "X-API-Key: $OPENCOMPUTER_API_KEY" \\
+ -H "Content-Type: application/json" \\
+ -d '{"memoryMB":1024,"cpuCount":1,"networkEnabled":true}'`,
+ },
+]
+
// Derive a friendly first name from an email local part (brian+test81@… → "Brian").
function firstNameFromEmail(email: string | undefined): string {
if (!email) return ''
@@ -424,7 +499,9 @@ function GettingStarted({ onBack }: { onBack?: () => void }) {
},
onSuccess: (session) => {
void queryClient.invalidateQueries({ queryKey: ['agents'] })
- void navigate(`/sessions/${session.id}`)
+ // Land on the session with the first-run guided overlay (maps this UI to
+ // the API calls that produced it). SessionDetail reads this nav state.
+ void navigate(`/sessions/${session.id}`, { state: { guide: 'agent' } })
},
})
const launching = launchMutation.isPending
@@ -437,14 +514,10 @@ function GettingStarted({ onBack }: { onBack?: () => void }) {
createSandbox({ memoryMB: 1024, cpuCount: 1, networkEnabled: true }),
onSuccess: (sb, intent) => {
void queryClient.invalidateQueries({ queryKey: ['sandboxes'] })
+ // Always land with the first-run guided overlay (SandboxDetail reads
+ // `guide`); the chip's intent fields order the tour to lead with its step.
void navigate(`/sandboxes/${sb.sandboxID}`, {
- state:
- intent.startupCommand ||
- intent.focus ||
- intent.exposePort ||
- intent.webApp
- ? intent
- : undefined,
+ state: { ...intent, guide: true },
})
},
})
@@ -540,6 +613,11 @@ function GettingStarted({ onBack }: { onBack?: () => void }) {
</button>
))}
</div>
+ <CodeOffRamp
+ className="mt-3"
+ tabs={AGENT_CODE}
+ docs="https://docs.opencomputer.dev/agent-sessions/quickstart"
+ />
</div>
{launchMutation.isError ? (
@@ -599,11 +677,16 @@ function GettingStarted({ onBack }: { onBack?: () => void }) {
</button>
))}
</div>
+ <CodeOffRamp
+ className="mt-3"
+ tabs={SANDBOX_CODE}
+ docs="https://docs.opencomputer.dev/quickstart"
+ />
</div>
<p className="text-muted-foreground mt-3 text-xs">
{creatingSandbox
- ? 'Booting a fresh cloud VM — this can take 10–20s…'
+ ? 'Booting a fresh cloud VM…'
: 'Ubuntu · Python and Node.js preinstalled · Interactive terminal'}
</p>
{createSandboxMutation.isError ? (
diff --git a/web/src/pages/SandboxDetail.tsx b/web/src/pages/SandboxDetail.tsx
index c467713c..fdb71e8a 100644
--- a/web/src/pages/SandboxDetail.tsx
+++ b/web/src/pages/SandboxDetail.tsx
@@ -1,4 +1,4 @@
-import { lazy, Suspense, useEffect, useRef, useState } from 'react'
+import { lazy, Suspense, useEffect, useMemo, useRef, useState } from 'react'
import { Link, useLocation, useNavigate, useParams } from 'react-router-dom'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { notifyError } from '@/lib/errors'
@@ -11,7 +11,9 @@ import {
Trash2,
ChevronRight,
Loader2,
+ Sparkles,
} from 'lucide-react'
+import { GuidedTour, type GuideStep } from '@/components/guided-tour'
import {
ApiError,
createPreviewUrl,
@@ -105,6 +107,109 @@ export default function SandboxDetail() {
const connectRef = useRef<HTMLDivElement>(null)
const scrolledRef = useRef(false)
+ // Guided first-run overlay: maps this sandbox's UI to the API/SDK/CLI that
+ // achieves each thing. Ordered so the chip you launched from leads (after the
+ // create step). Anchors: header, Terminal button, Preview panel, Connect panel.
+ const headerRef = useRef<HTMLDivElement>(null)
+ const terminalBtnRef = useRef<HTMLButtonElement>(null)
+ const previewRef = useRef<HTMLDivElement>(null)
+ const [guideOpen, setGuideOpen] = useState(
+ () => (location.state as { guide?: boolean } | null)?.guide === true,
+ )
+ const guideSteps: GuideStep[] = useMemo(() => {
+ const id = sandboxId || '<id>'
+ const stepCreate: GuideStep = {
+ target: headerRef,
+ title: 'You created a real cloud sandbox',
+ body: 'One call spun up a persistent Linux VM. It stays alive until you kill it or it idles out.',
+ api: 'POST /api/sandboxes',
+ code: [
+ {
+ label: 'SDK',
+ code: `import { Sandbox } from "@opencomputer/sdk";
+
+const sandbox = await Sandbox.create();`,
+ },
+ { label: 'CLI', code: `oc create` },
+ {
+ label: 'API',
+ code: `curl -X POST https://app.opencomputer.dev/api/sandboxes \\
+ -H "X-API-Key: $OPENCOMPUTER_API_KEY" \\
+ -H "Content-Type: application/json" \\
+ -d '{"memoryMB":1024,"cpuCount":1,"networkEnabled":true}'`,
+ },
+ ],
+ docs: 'https://docs.opencomputer.dev/quickstart',
+ }
+ const stepExec: GuideStep = {
+ target: terminalBtnRef,
+ title: 'Run commands in it',
+ body: 'This terminal runs against the live VM. In code it is exec — install packages, run scripts, anything.',
+ api: 'sandbox.exec.run(…)',
+ code: [
+ {
+ label: 'SDK',
+ code: `const { stdout } = await sandbox.exec.run("python3 --version");
+console.log(stdout);`,
+ },
+ { label: 'CLI', code: `oc exec ${id} -- python3 --version` },
+ {
+ label: 'API',
+ code: `curl -X POST https://app.opencomputer.dev/api/sandboxes/${id}/exec/run \\
+ -H "X-API-Key: $OPENCOMPUTER_API_KEY" \\
+ -H "Content-Type: application/json" \\
+ -d '{"cmd":"python3 --version"}'`,
+ },
+ ],
+ docs: 'https://docs.opencomputer.dev/sandboxes/overview',
+ }
+ const stepExpose: GuideStep = {
+ target: previewRef,
+ title: 'Expose a port → public URL',
+ body: 'Start a server in the box, then expose its port to get a public https URL — great for web apps and webhooks.',
+ api: 'sandbox.createPreviewURL({ port })',
+ code: [
+ {
+ label: 'SDK',
+ code: `await sandbox.exec.run("python3 -m http.server 8000 &");
+const preview = await sandbox.createPreviewURL({ port: 8000 });
+console.log(preview.url);`,
+ },
+ { label: 'CLI', code: `oc preview create ${id} 8000` },
+ {
+ label: 'API',
+ code: `curl -X POST https://app.opencomputer.dev/api/sandboxes/${id}/preview \\
+ -H "X-API-Key: $OPENCOMPUTER_API_KEY" \\
+ -H "Content-Type: application/json" \\
+ -d '{"port":8000}'`,
+ },
+ ],
+ docs: 'https://docs.opencomputer.dev/sandboxes/preview-urls',
+ }
+ const stepConnect: GuideStep = {
+ target: connectRef,
+ title: 'Drive it from your code',
+ body: 'Reconnect to this exact box by id from your own app and keep working — same VM, same state.',
+ api: `Sandbox.connect("${id}")`,
+ code: [
+ {
+ label: 'SDK',
+ code: `import { Sandbox } from "@opencomputer/sdk";
+
+const sandbox = await Sandbox.connect("${id}");
+const { stdout } = await sandbox.exec.run("echo hello from code");`,
+ },
+ { label: 'CLI', code: `oc shell ${id}` },
+ ],
+ docs: 'https://docs.opencomputer.dev/sandboxes/overview',
+ }
+ // Lead with the step matching the chip that launched this box.
+ if (webApp || exposePort) return [stepCreate, stepExpose, stepExec, stepConnect]
+ if (focusConnect) return [stepCreate, stepConnect, stepExec, stepExpose]
+ if (startupCommand) return [stepCreate, stepExec, stepExpose, stepConnect]
+ return [stepCreate, stepExec, stepExpose, stepConnect]
+ }, [sandboxId, webApp, exposePort, focusConnect, startupCommand])
+
// On arrival from an example chip: open the terminal (so the startup command
// has somewhere to run) and wipe history state so a refresh doesn't re-fire.
useEffect(() => {
@@ -273,7 +378,7 @@ export default function SandboxDetail() {
</p>
<p className="text-muted-foreground text-xs">
Booting a fresh cloud VM
- {sandboxId ? ` · ${sandboxId}` : ''}. This takes a few seconds.
+ {sandboxId ? ` · ${sandboxId}` : ''}…
</p>
</div>
</div>
@@ -318,8 +423,14 @@ export default function SandboxDetail() {
Back to Sandboxes
</Link>
+ <GuidedTour
+ steps={guideSteps}
+ open={guideOpen}
+ onClose={() => setGuideOpen(false)}
+ />
+
{/* Header */}
- <Panel className="mb-4 p-6">
+ <Panel ref={headerRef} className="mb-4 p-6">
<div className="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between">
<div className="min-w-0">
<div className="flex flex-wrap items-center gap-3">
@@ -335,6 +446,15 @@ export default function SandboxDetail() {
</div>
<div className="flex flex-wrap gap-2">
+ <Button
+ variant="ghost"
+ size="sm"
+ className="text-muted-foreground"
+ onClick={() => setGuideOpen(true)}
+ >
+ <Sparkles className="size-4" />
+ How it works
+ </Button>
<Button
variant={showLogs ? 'default' : 'outline'}
size="sm"
@@ -346,6 +466,7 @@ export default function SandboxDetail() {
{isRunning ? (
<>
<Button
+ ref={terminalBtnRef}
variant={showTerminal ? 'default' : 'outline'}
size="sm"
onClick={() => setShowTerminal((v) => !v)}
@@ -440,7 +561,7 @@ export default function SandboxDetail() {
{/* Preview URLs — expose a port to get a public https URL */}
{isRunning || (session.previewUrls?.length ?? 0) > 0 ? (
- <Panel className="mb-4 p-6">
+ <Panel ref={previewRef} className="mb-4 p-6">
<h2 className="mb-3 text-sm font-semibold">Preview URLs</h2>
{session.previewUrls && session.previewUrls.length > 0 ? (
<div className="space-y-2">
diff --git a/web/src/pages/SessionDetail.tsx b/web/src/pages/SessionDetail.tsx
index b6c0d3d7..8f3b806b 100644
--- a/web/src/pages/SessionDetail.tsx
+++ b/web/src/pages/SessionDetail.tsx
@@ -1,7 +1,8 @@
-import { useEffect, useMemo, useState } from 'react'
-import { Link, useParams } from 'react-router-dom'
+import { useEffect, useMemo, useRef, useState } from 'react'
+import { Link, useParams, useLocation } from 'react-router-dom'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
-import { ArrowLeft, Send, Wrench, CircleAlert } from 'lucide-react'
+import { ArrowLeft, Send, Wrench, CircleAlert, Sparkles } from 'lucide-react'
+import { GuidedTour, type GuideStep } from '@/components/guided-tour'
import { notifyError } from '@/lib/errors'
import { useHalted } from '@/hooks/useHalted'
import {
@@ -64,6 +65,103 @@ export default function SessionDetail() {
const [liveEvents, setLiveEvents] = useState<SessionEvent[]>([])
const [streamOk, setStreamOk] = useState(false)
+ // Guided first-run overlay: the chip launch passes { guide: 'agent' } via nav
+ // state; the "How it works" button reopens it any time. Anchors point at the
+ // real regions below (header / event stream / composer).
+ const location = useLocation()
+ const headerRef = useRef<HTMLDivElement>(null)
+ const eventsRef = useRef<HTMLDivElement>(null)
+ const composerRef = useRef<HTMLFormElement>(null)
+ const [guideOpen, setGuideOpen] = useState(
+ () => (location.state as { guide?: string } | null)?.guide === 'agent',
+ )
+ const guideSteps: GuideStep[] = useMemo(
+ () => [
+ {
+ target: headerRef,
+ title: 'This session came from two API calls',
+ body: 'Clicking the example created a managed agent, then started a session on it — the dashboard just called the public API on your behalf.',
+ api: 'POST /v3/agents · POST /v3/sessions',
+ code: [
+ {
+ label: 'SDK',
+ code: `import { OpenComputer } from "@opencomputer/sdk";
+const oc = new OpenComputer({ apiKey: process.env.OPENCOMPUTER_API_KEY });
+
+const agent = await oc.agents.create({
+ runtime: "claude",
+ model: "anthropic/claude-opus-4-8",
+ credential: "managed",
+});
+
+const session = await oc.sessions.create({
+ agent: agent.id,
+ input: "Give me a quick tour of this sandbox.",
+});`,
+ },
+ {
+ label: 'API',
+ code: `# 1. Create a managed agent
+curl -X POST https://api.opencomputer.dev/v3/agents \\
+ -H "Authorization: Bearer $OPENCOMPUTER_API_KEY" \\
+ -H "Content-Type: application/json" \\
+ -d '{"runtime":"claude","model":"anthropic/claude-opus-4-8","credential":"managed"}'
+
+# 2. Start a session on that agent
+curl -X POST https://api.opencomputer.dev/v3/sessions \\
+ -H "Authorization: Bearer $OPENCOMPUTER_API_KEY" \\
+ -H "Content-Type: application/json" \\
+ -d '{"agent":"agt_...","input":"Give me a quick tour of this sandbox."}'`,
+ },
+ ],
+ docs: 'https://docs.opencomputer.dev/agent-sessions/quickstart',
+ },
+ {
+ target: eventsRef,
+ title: "This is the session's live event log",
+ body: 'Every turn the agent takes streams here over SSE — the same feed you consume in code, no polling.',
+ api: 'GET /v3/sessions/:id/events',
+ code: [
+ {
+ label: 'SDK',
+ code: `// session is the handle returned by oc.sessions.create()
+for await (const event of session.events()) {
+ console.log(event.type, event.body);
+}`,
+ },
+ {
+ label: 'API',
+ code: `curl -N https://api.opencomputer.dev/v3/sessions/$SESSION_ID/events?stream=sse \\
+ -H "Authorization: Bearer $OPENCOMPUTER_API_KEY"
+# server-sent events stream: one event per line`,
+ },
+ ],
+ docs: 'https://docs.opencomputer.dev/agent-sessions/sessions',
+ },
+ {
+ target: composerRef,
+ title: 'Steer it from here',
+ body: 'Sending a message posts more input to the same session — the agent picks it up on its next turn.',
+ api: 'POST /v3/sessions/:id/messages',
+ code: [
+ {
+ label: 'SDK',
+ code: `await session.steer("Also add a dark mode toggle.");`,
+ },
+ {
+ label: 'API',
+ code: `curl -X POST https://api.opencomputer.dev/v3/sessions/$SESSION_ID/messages \\
+ -H "Authorization: Bearer $OPENCOMPUTER_API_KEY" \\
+ -H "Content-Type: application/json" \\
+ -d '{"text":"Also add a dark mode toggle."}'`,
+ },
+ ],
+ docs: 'https://docs.opencomputer.dev/agent-sessions/messaging',
+ },
+ ],
+ [],
+ )
+
const { data: session, isLoading } = useQuery({
queryKey: ['session', sessionId],
queryFn: () => getSession(sessionId),
@@ -190,6 +288,11 @@ export default function SessionDetail() {
return (
<div className="max-w-4xl">
+ <GuidedTour
+ steps={guideSteps}
+ open={guideOpen}
+ onClose={() => setGuideOpen(false)}
+ />
<Link
to="/sessions"
className="text-muted-foreground hover:text-foreground mb-4 inline-flex items-center gap-1.5 text-sm"
@@ -199,7 +302,7 @@ export default function SessionDetail() {
</Link>
{/* Header */}
- <Panel className="mb-4 p-5">
+ <Panel ref={headerRef} className="mb-4 p-5">
<div className="flex flex-wrap items-start justify-between gap-4">
<div className="min-w-0 space-y-1.5">
<div className="flex items-center gap-2.5">
@@ -246,6 +349,15 @@ export default function SessionDetail() {
/>
</div>
<div className="flex items-center gap-2">
+ <Button
+ variant="ghost"
+ size="sm"
+ className="text-muted-foreground"
+ onClick={() => setGuideOpen(true)}
+ >
+ <Sparkles className="size-3.5" />
+ How it works
+ </Button>
{canCancel ? (
<Button
variant="outline"
@@ -271,7 +383,7 @@ export default function SessionDetail() {
</Panel>
{/* Event stream */}
- <Panel className="overflow-hidden">
+ <Panel ref={eventsRef} className="overflow-hidden">
<div className="flex items-center justify-between border-b px-4 py-2.5">
<div className="flex items-center gap-2">
<h2 className="text-sm font-semibold">Events</h2>
@@ -331,6 +443,7 @@ export default function SessionDetail() {
</div>
)}
<form
+ ref={composerRef}
className="flex items-end gap-2"
onSubmit={(e) => {
e.preventDefault()