An open-source, faster Devin alternative
TypeScript
web: once onboarded, the Computer page shows the work that is live
Slack U06GFN8DJ7Pe19b3663a4b8
diff --git a/web/src/managed-agents/Computer.test.tsx b/web/src/managed-agents/Computer.test.tsxindex 1d6e5440..694f90f3 100644--- a/web/src/managed-agents/Computer.test.tsx+++ b/web/src/managed-agents/Computer.test.tsx@@ -48,6 +48,40 @@ const provisioning = {},}+const onboarded = {+ ...provisioning,+ computer: {+ ...provisioning.computer,+ state: 'ready' as const,+ connected: true,+ },+ slack: { installed: true, teamId: 'T1', teamName: 'Acme' },+ github: {+ connected: true,+ installations: [{ id: '42', accountLogin: 'acme' }],+ },+}+const minutesAgo = (minutes: number) =>+ new Date(Date.now() - minutes * 60_000).toISOString()+const liveSession = {+ key: 'C1:1.1',+ title: 'Fix the flaky checkout test',+ channelId: 'C1',+ threadTs: '1.1',+ ownerSlackUserId: 'U1',+ status: 'busy' as const,+ updatedAt: minutesAgo(2),+ slackUrl: 'https://acme.slack.com/archives/C1/p11',+}+const doneSession = {+ ...liveSession,+ key: 'C1:1.0',+ title: 'Explain the billing flow',+ threadTs: '1.0',+ status: 'idle' as const,+ updatedAt: minutesAgo(90),+}+async function settle(until: () => boolean, label: string) {for (let attempt = 0; attempt < 50; attempt += 1) {if (until()) return@@ -174,4 +208,87 @@ describe('Computer page', () => {render('/')await settle(() => location() === '/computer', 'redirect to /computer')})++ it('shows live work instead of setup once onboarded', async () => {+ computerApi.getComputer.mockResolvedValue(onboarded)+ computerApi.getComputerSessions.mockResolvedValue([+ doneSession,+ liveSession,+ ])++ render('/computer')+ await settle(+ () => container.textContent?.includes('Fix the flaky') === true,+ 'live session card',+ )++ const live = container.querySelector('section[aria-labelledby="live-now"]')+ expect(live?.textContent).toContain('Live now')+ expect(live?.textContent).toContain('Fix the flaky checkout test')+ expect(live?.textContent).toContain('Working…')+ expect(live?.textContent).toContain('2 min ago')+ expect(live?.textContent).not.toContain('Explain the billing flow')+ expect(+ live?.querySelector('a[href="https://acme.slack.com/archives/C1/p11"]')+ ?.textContent,+ ).toContain('Open in Slack')+ expect(container.textContent).toContain('Recent')+ expect(container.textContent).toContain('Explain the billing flow')+ expect(container.textContent).toContain('1 hr ago')+ expect(container.textContent).toContain('One thing in flight')+ expect(container.textContent).toContain('Acme')+ expect(container.textContent).toContain('acme')++ // Setup and selling are gone; specs never appear.+ expect(container.textContent).not.toContain('Three steps')+ expect(container.textContent).not.toContain('Install Slack app')+ expect(container.textContent).not.toContain('Lives in Slack')+ expect(container.textContent).not.toContain('never logs off')+ expect(container.textContent).not.toMatch(/vCPU|GiB/)+ })++ it('invites a hand-off when nothing is live', async () => {+ computerApi.getComputer.mockResolvedValue(onboarded)+ computerApi.getComputerSessions.mockResolvedValue([doneSession])++ render('/computer')+ await settle(+ () => container.textContent?.includes('Quiet right now.') === true,+ 'quiet live state',+ )+ expect(container.textContent).toContain('Ready when you are.')+ expect(container.textContent).toContain('@OpenComputer why is the')+ })++ it('keeps a resting computer and the upgrade visible once onboarded', async () => {+ computerApi.getComputer.mockResolvedValue({+ ...onboarded,+ computer: { ...onboarded.computer, state: 'parked', connected: false },+ })++ render('/computer')+ await settle(+ () => container.textContent?.includes('Resting') === true,+ 'resting header',+ )+ expect(container.textContent).toContain('Sleeping')+ expect(container.textContent).toContain('Upgrade and it never sleeps.')+ })++ it('keeps the setup page until GitHub is connected too', async () => {+ computerApi.getComputer.mockResolvedValue({+ ...onboarded,+ github: { connected: false, installations: [] },+ })+ computerApi.getComputerSessions.mockResolvedValue([liveSession])++ render('/computer')+ await settle(+ () => container.textContent?.includes('Three steps') === true,+ 'setup checklist',+ )+ expect(container.textContent).toContain('never logs off')+ expect(container.textContent).toContain('Connect GitHub')+ expect(container.textContent).not.toContain('Live now')+ })})diff --git a/web/src/managed-agents/Computer.tsx b/web/src/managed-agents/Computer.tsxindex 33c6c6e0..a6797e17 100644--- a/web/src/managed-agents/Computer.tsx+++ b/web/src/managed-agents/Computer.tsx@@ -1,4 +1,4 @@-import { useEffect, useRef, useState, type ReactNode } from 'react'+import { useEffect, useMemo, useRef, useState, type ReactNode } from 'react'import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'import { Link, useSearchParams } from 'react-router-dom'import {@@ -6,11 +6,14 @@ import {Computer as ComputerIcon,ExternalLink,GitPullRequest,+ Hash,+ Lightbulb,Loader2,MessagesSquare,Moon,RotateCcw,Send,+ Sparkles,Terminal,Unplug,} from 'lucide-react'@@ -28,6 +31,7 @@ import {import { ResourceTable, type Column } from '@/components/resource-table'import { StatusBadge } from '@/components/status-badge'import { Button } from '@/components/ui/button'+import { Skeleton } from '@/components/ui/skeleton'import { notifyError, notifySuccess } from '@/lib/errors'import { cn } from '@/lib/utils'import { addManagedGitHubConnection } from './api'@@ -47,16 +51,19 @@ import {EXAMPLE_ASKS,SESSION_STATUS,START_SESSION_COPY,+ compactStatusLine,computerChecklist,+ computerIsOnboarded,computerPollInterval,computerPresentation,heroCopy,+ relativeTime,+ sessionPollInterval,slackReturnFromSearch,+ splitSessions,type ChecklistStep,} from './computer-state'-const SESSION_POLL_MS = 15_000-export default function ComputerPage() {const queryClient = useQueryClient()const [searchParams, setSearchParams] = useSearchParams()@@ -71,7 +78,7 @@ export default function ComputerPage() {queryFn: getComputerSessions,// Sessions run on the computer; there are none to ask for before it exists.enabled: hasComputer,- refetchInterval: SESSION_POLL_MS,+ refetchInterval: (query) => sessionPollInterval(query.state.data),})// The first visit creates the organization's computer. The call is@@ -133,11 +140,49 @@ export default function ComputerPage() {)}+ const { live, recent } = splitSessions(sessions.data ?? [])+ const sessionsLoading = hasComputer && sessions.isLoading+ const createError = create.isError ? create.error : null++ // Once it is in Slack and knows the code, the page is about the work.+ if (computerIsOnboarded(status.data)) {+ return (+ <div className="mx-auto max-w-5xl space-y-8">+ <CompactHeader+ status={status.data}+ liveCount={live.length}+ createError={createError}+ creating={create.isPending}+ onRetry={() => create.mutate()}+ />+ <LiveNow+ sessions={live}+ readAt={sessions.dataUpdatedAt}+ loading={sessionsLoading}+ failed={sessions.isError}+ />+ <SessionsPanel+ title="Recent"+ description="Finished and waiting threads, newest first."+ emptyTitle="Nothing here yet"+ emptyDescription="Finished work lands here."+ hasComputer={hasComputer}+ sessions={recent}+ readAt={sessions.dataUpdatedAt}+ loading={sessionsLoading}+ failed={sessions.isError}+ />+ <IdeasToTry />+ <CliFooter />+ </div>+ )+ }+return (<div className="mx-auto max-w-5xl space-y-6"><Herostatus={status.data}- createError={create.isError ? create.error : null}+ createError={createError}creating={create.isPending}onRetry={() => create.mutate()}/>@@ -145,28 +190,353 @@ export default function ComputerPage() {<Checklist status={status.data} sessions={sessions.data} /><TryAsking /><SessionsPanel+ title="Sessions"+ description="Work your computer is doing for your team, newest first."+ emptyTitle="No sessions yet"+ emptyDescription={START_SESSION_COPY}hasComputer={hasComputer}- sessions={newestFirst(sessions.data ?? [])}- loading={hasComputer && sessions.isLoading}+ sessions={[...live, ...recent]}+ readAt={sessions.dataUpdatedAt}+ loading={sessionsLoading}failed={sessions.isError}/>- <Panel>- <PanelContent className="flex flex-wrap items-center justify-between gap-4">- <div className="flex items-center gap-3">- <Terminal className="text-muted-foreground size-4" aria-hidden />- <p className="text-muted-foreground text-sm">- Build and deploy agents of your own with the OpenComputer CLI.+ <CliFooter />+ </div>+ )+}++function CliFooter() {+ return (+ <Panel>+ <PanelContent className="flex flex-wrap items-center justify-between gap-4">+ <div className="flex items-center gap-3">+ <Terminal className="text-muted-foreground size-4" aria-hidden />+ <p className="text-muted-foreground text-sm">+ Build and deploy agents of your own with the OpenComputer CLI.+ </p>+ </div>+ <Button variant="outline" asChild>+ <Link to="/new">Create an agent</Link>+ </Button>+ </PanelContent>+ </Panel>+ )+}++/** Re-renders on an interval so relative times stay true between polls. */+function useNow(intervalMs: number) {+ const [now, setNow] = useState(() => Date.now())+ useEffect(() => {+ const timer = setInterval(() => setNow(Date.now()), intervalMs)+ return () => clearInterval(timer)+ }, [intervalMs])+ return now+}++type DotTone = 'alive' | 'busy' | 'failed' | 'quiet'++function PulseDot({ tone, className }: { tone: DotTone; className?: string }) {+ const pulsing = tone === 'alive' || tone === 'busy'+ return (+ <span className={cn('relative flex size-2', className)} aria-hidden>+ {pulsing ? (+ <span+ className={cn(+ 'absolute inline-flex size-full animate-ping rounded-full opacity-75',+ tone === 'alive' ? 'bg-emerald-500' : 'bg-amber-500',+ )}+ />+ ) : null}+ <span+ className={cn(+ 'relative inline-flex size-full rounded-full',+ tone === 'alive'+ ? 'bg-emerald-500'+ : tone === 'busy'+ ? 'bg-amber-500'+ : tone === 'failed'+ ? 'bg-red-500'+ : 'bg-muted-foreground',+ )}+ />+ </span>+ )+}++/** The computer's state as a dot tone, shared by the hero and the header. */+function computerDot(status: ComputerStatus, failedToCreate: boolean): DotTone {+ const { computer } = status+ if (failedToCreate || computer?.state === 'failed') return 'failed'+ if (computer?.state === 'ready' && computer.connected) return 'alive'+ if (+ !computer ||+ computer.state === 'provisioning' ||+ computer.state === 'waking' ||+ computer.state === 'ready'+ ) {+ return 'busy'+ }+ return 'quiet'+}++function StatusPill({+ status,+ failedToCreate,+}: {+ status: ComputerStatus+ failedToCreate: boolean+}) {+ return (+ <div className="bg-background/70 inline-flex items-center gap-2 rounded-full border px-3 py-1 text-xs font-medium backdrop-blur">+ <PulseDot tone={computerDot(status, failedToCreate)} />+ {failedToCreate+ ? 'Failed'+ : computerPresentation(status.computer, status.plan).label}+ </div>+ )+}++function RetryButton({+ creating,+ onRetry,+ className,+}: {+ creating: boolean+ onRetry: () => void+ className?: string+}) {+ return (+ <Button className={className} disabled={creating} onClick={onRetry}>+ {creating ? (+ <Loader2 className="size-4 animate-spin" aria-hidden />+ ) : (+ <RotateCcw className="size-4" aria-hidden />+ )}+ Try again+ </Button>+ )+}++function CompactHeader({+ status,+ liveCount,+ createError,+ creating,+ onRetry,+}: {+ status: ComputerStatus+ liveCount: number+ createError: Error | null+ creating: boolean+ onRetry: () => void+}) {+ const { computer } = status+ const failedToCreate = !computer && createError !== null+ const line = failedToCreate+ ? { headline: 'Something went wrong.', detail: createError.message }+ : compactStatusLine(computer, status.plan, liveCount)+ const offerUpgrade = computer?.state === 'parked' && status.plan === 'free'+ const canRetry = failedToCreate || computer?.state === 'failed'+ const accounts = status.github.installations.map(+ (installation) => installation.accountLogin,+ )+ return (+ <section className="from-primary/10 via-panel to-panel relative overflow-hidden rounded-2xl border bg-linear-to-br px-6 py-6 sm:px-8">+ <div+ className="bg-primary/15 pointer-events-none absolute -top-20 -right-16 size-56 rounded-full blur-3xl"+ aria-hidden+ />+ <div className="relative flex flex-wrap items-end justify-between gap-x-8 gap-y-5">+ <div className="min-w-0">+ <StatusPill status={status} failedToCreate={failedToCreate} />+ <h1 className="mt-3 text-2xl font-semibold tracking-tight text-balance sm:text-3xl">+ {line.headline}+ </h1>+ {line.detail ? (+ <p className="text-muted-foreground mt-1.5 text-sm">+ {offerUpgrade ? (+ <Link+ to="/billing"+ className="text-foreground decoration-foreground/30 hover:decoration-foreground underline underline-offset-4 transition-colors"+ >+ {line.detail}+ </Link>+ ) : (+ line.detail+ )}</p>- </div>+ ) : null}+ {canRetry ? (+ <RetryButton+ className="mt-4"+ creating={creating}+ onRetry={onRetry}+ />+ ) : null}+ </div>+ <div className="flex flex-wrap items-center gap-2 text-sm">+ <span className="bg-background/70 text-muted-foreground inline-flex items-center gap-1.5 rounded-full border px-3 py-1 backdrop-blur">+ <Hash className="size-3.5" aria-hidden />+ <span className="sr-only">Slack: </span>+ {status.slack.teamName ?? 'Slack'}+ </span>+ <span+ className="bg-background/70 text-muted-foreground inline-flex max-w-64 items-center gap-1.5 rounded-full border px-3 py-1 backdrop-blur"+ title={accounts.join(', ')}+ >+ <GithubMark className="size-3.5 shrink-0" />+ <span className="sr-only">GitHub: </span>+ <span className="truncate">+ {accounts.length ? accounts.join(', ') : 'GitHub'}+ </span>+ </span>+ <Button variant="ghost" size="sm" asChild>+ <Link to="/managed-agents/connections">Manage</Link>+ </Button>+ <SlackAction status={status} compact />+ </div>+ </div>+ </section>+ )+}++function LiveNow({+ sessions,+ readAt,+ loading,+ failed,+}: {+ sessions: ComputerSession[]+ /** When the sessions were read; relative times never predate it. */+ readAt: number+ loading: boolean+ failed: boolean+}) {+ const now = Math.max(useNow(30_000), readAt)+ return (+ <section aria-labelledby="live-now">+ <div className="mb-3 flex items-baseline justify-between gap-4">+ <h2 id="live-now" className="text-lg font-semibold tracking-tight">+ Live now+ </h2>+ {sessions.length > 0 ? (+ <span className="text-muted-foreground text-sm">+ {sessions.length === 1+ ? '1 session in flight'+ : `${sessions.length} sessions in flight`}+ </span>+ ) : null}+ </div>+ {loading ? (+ <Skeleton className="h-36 rounded-xl" />+ ) : sessions.length > 0 ? (+ <div+ className={cn('grid gap-4', sessions.length > 1 && 'sm:grid-cols-2')}+ >+ {sessions.map((session) => (+ <LiveCard key={session.key} session={session} now={now} />+ ))}+ </div>+ ) : failed ? (+ <div className="bg-panel text-muted-foreground rounded-xl border px-6 py-8 text-center text-sm">+ Sessions are temporarily unavailable. They reload by themselves.+ </div>+ ) : (+ <QuietNow />+ )}+ </section>+ )+}++function LiveCard({ session, now }: { session: ComputerSession; now: number }) {+ const busy = session.status === 'busy'+ return (+ <article+ className={cn(+ 'bg-panel relative overflow-hidden rounded-xl border bg-linear-to-br to-transparent p-6 shadow-sm',+ busy ? 'from-emerald-500/[0.06]' : 'from-amber-500/[0.06]',+ )}+ >+ <div+ className={cn(+ 'absolute inset-x-0 top-0 h-0.5 bg-linear-to-r from-transparent to-transparent',+ busy ? 'via-emerald-500' : 'via-amber-500',+ )}+ aria-hidden+ />+ <div className="flex items-center gap-2.5 text-sm">+ <PulseDot tone={busy ? 'alive' : 'busy'} className="size-2.5" />+ <span+ className={cn(+ 'font-medium',+ busy+ ? 'text-emerald-600 dark:text-emerald-400'+ : 'text-amber-600 dark:text-amber-400',+ )}+ >+ {busy ? 'Working…' : 'Starting…'}+ </span>+ <span className="text-muted-foreground">·</span>+ <time+ className="text-muted-foreground"+ dateTime={session.updatedAt}+ title={new Date(session.updatedAt).toLocaleString()}+ >+ {relativeTime(session.updatedAt, now)}+ </time>+ </div>+ <div className="mt-4 flex flex-wrap items-end justify-between gap-4">+ <h3 className="min-w-0 flex-1 text-xl font-semibold tracking-tight text-balance">+ {session.title || 'Untitled session'}+ </h3>+ {session.slackUrl ? (<Button variant="outline" asChild>- <Link to="/new">Create an agent</Link>+ <a href={session.slackUrl} target="_blank" rel="noreferrer">+ Open in Slack+ <ExternalLink className="size-3.5" aria-hidden />+ </a></Button>- </PanelContent>- </Panel>+ ) : null}+ </div>+ </article>+ )+}++function QuietNow() {+ return (+ <div className="bg-panel rounded-xl border border-dashed px-6 py-10 text-center">+ <Sparkles className="text-primary mx-auto size-5" aria-hidden />+ <p className="mt-3 font-medium">Quiet right now.</p>+ <p className="text-muted-foreground mt-1 text-sm">+ Mention @OpenComputer in Slack to hand it something.+ </p>+ <CopyRow+ value={`@OpenComputer ${EXAMPLE_ASKS[0]}`}+ className="mx-auto mt-5 max-w-2xl text-left"+ /></div>)}+function IdeasToTry() {+ return (+ <details className="group bg-panel rounded-xl border">+ <summary className="text-muted-foreground hover:text-foreground flex cursor-pointer list-none items-center gap-2 px-5 py-3 text-sm font-medium [&::-webkit-details-marker]:hidden">+ <Lightbulb className="size-4" aria-hidden />+ Ideas to try+ <span className="ml-auto text-xs transition-transform group-open:rotate-90">+ ›+ </span>+ </summary>+ <div className="grid gap-2 px-5 pb-5">+ {EXAMPLE_ASKS.map((ask) => (+ <CopyRow key={ask} value={`@OpenComputer ${ask}`} />+ ))}+ </div>+ </details>+ )+}+function Hero({status,createError,@@ -179,17 +549,10 @@ function Hero({onRetry: () => void}) {const { computer } = status- const presentation = computerPresentation(computer, status.plan)const failedToCreate = !computer && createError !== nullconst copy = failedToCreate? { headline: 'Something went wrong.', subline: createError.message }: heroCopy(computer, status.plan)- const alive = computer?.state === 'ready' && computer.connected- const busy =- !computer ||- computer.state === 'provisioning' ||- computer.state === 'waking' ||- (computer.state === 'ready' && !computer.connected)const canRetry = failedToCreate || computer?.state === 'failed'return (<section className="from-primary/10 via-panel to-panel relative overflow-hidden rounded-2xl border bg-linear-to-br px-8 py-12 sm:px-12 sm:py-16">@@ -198,31 +561,7 @@ function Hero({aria-hidden/><div className="relative max-w-3xl">- <div className="bg-background/70 inline-flex items-center gap-2 rounded-full border px-3 py-1 text-xs font-medium backdrop-blur">- <span className="relative flex size-2" aria-hidden>- {alive || busy ? (- <span- className={cn(- 'absolute inline-flex size-full animate-ping rounded-full opacity-75',- alive ? 'bg-emerald-500' : 'bg-amber-500',- )}- />- ) : null}- <span- className={cn(- 'relative inline-flex size-2 rounded-full',- alive- ? 'bg-emerald-500'- : busy- ? 'bg-amber-500'- : failedToCreate || computer?.state === 'failed'- ? 'bg-red-500'- : 'bg-muted-foreground',- )}- />- </span>- {failedToCreate ? 'Failed' : presentation.label}- </div>+ <StatusPill status={status} failedToCreate={failedToCreate} /><h1 className="mt-6 text-4xl font-semibold tracking-tight text-balance sm:text-5xl">{copy.headline}</h1>@@ -230,14 +569,7 @@ function Hero({{copy.subline}</p>{canRetry ? (- <Button className="mt-8" disabled={creating} onClick={onRetry}>- {creating ? (- <Loader2 className="size-4 animate-spin" aria-hidden />- ) : (- <RotateCcw className="size-4" aria-hidden />- )}- Try again- </Button>+ <RetryButton className="mt-8" creating={creating} onRetry={onRetry} />) : null}</div></section>@@ -401,7 +733,13 @@ function Step({)}-function SlackAction({ status }: { status: ComputerStatus }) {+function SlackAction({+ status,+ compact = false,+}: {+ status: ComputerStatus+ compact?: boolean+}) {const queryClient = useQueryClient()const [confirmUnlink, setConfirmUnlink] = useState(false)const install = useMutation({@@ -441,9 +779,14 @@ function SlackAction({ status }: { status: ComputerStatus }) {const teamName = status.slack.teamName ?? 'this Slack workspace'return (<>- <Button variant="outline" onClick={() => setConfirmUnlink(true)}>- <Unplug className="size-4" aria-hidden />- Unlink+ <Button+ variant={compact ? 'ghost' : 'outline'}+ size={compact ? 'sm' : 'default'}+ className={cn(compact && 'text-muted-foreground')}+ onClick={() => setConfirmUnlink(true)}+ >+ <Unplug className={compact ? 'size-3.5' : 'size-4'} aria-hidden />+ {compact ? 'Unlink Slack' : 'Unlink'}</Button><ConfirmDialogopen={confirmUnlink}@@ -494,80 +837,90 @@ function GitHubAction({ connected }: { connected: boolean }) {)}-function newestFirst(sessions: ComputerSession[]) {- return [...sessions].sort((left, right) =>- right.updatedAt.localeCompare(left.updatedAt),- )+function sessionColumns(now: number): Column<ComputerSession>[] {+ return [+ {+ key: 'title',+ header: 'Session',+ cell: (session) => (+ <span className="block max-w-md truncate font-medium">+ {session.title || 'Untitled session'}+ </span>+ ),+ },+ {+ key: 'status',+ header: 'Status',+ cell: (session) => (+ <StatusBadge+ status={SESSION_STATUS[session.status].badge}+ label={SESSION_STATUS[session.status].label}+ />+ ),+ },+ {+ key: 'updated',+ header: 'Updated',+ cell: (session) => (+ <time+ className="text-muted-foreground whitespace-nowrap"+ dateTime={session.updatedAt}+ title={new Date(session.updatedAt).toLocaleString()}+ >+ {relativeTime(session.updatedAt, now)}+ </time>+ ),+ },+ {+ key: 'open',+ header: <span className="sr-only">Open</span>,+ align: 'right',+ cell: (session) =>+ session.slackUrl ? (+ <Button variant="ghost" size="sm" asChild>+ <a href={session.slackUrl} target="_blank" rel="noreferrer">+ Open in Slack+ <ExternalLink className="size-3.5" aria-hidden />+ </a>+ </Button>+ ) : null,+ },+ ]}-const SESSION_COLUMNS: Column<ComputerSession>[] = [- {- key: 'title',- header: 'Session',- cell: (session) => (- <span className="block max-w-md truncate font-medium">- {session.title || 'Untitled session'}- </span>- ),- },- {- key: 'status',- header: 'Status',- cell: (session) => (- <StatusBadge- status={SESSION_STATUS[session.status].badge}- label={SESSION_STATUS[session.status].label}- />- ),- },- {- key: 'updated',- header: 'Updated',- cell: (session) => (- <span className="text-muted-foreground whitespace-nowrap">- {new Date(session.updatedAt).toLocaleString()}- </span>- ),- },- {- key: 'open',- header: <span className="sr-only">Open</span>,- align: 'right',- cell: (session) =>- session.slackUrl ? (- <Button variant="ghost" size="sm" asChild>- <a href={session.slackUrl} target="_blank" rel="noreferrer">- Open in Slack- <ExternalLink className="size-3.5" aria-hidden />- </a>- </Button>- ) : null,- },-]-function SessionsPanel({+ title,+ description,+ emptyTitle,+ emptyDescription,hasComputer,sessions,+ readAt,loading,failed,}: {+ title: string+ description: string+ emptyTitle: string+ emptyDescription: stringhasComputer: booleansessions: ComputerSession[]+ readAt: numberloading: booleanfailed: boolean}) {+ const now = Math.max(useNow(30_000), readAt)+ const columns = useMemo(() => sessionColumns(now), [now])return (<Panel><PanelHeader><div>- <PanelTitle>Sessions</PanelTitle>- <PanelDescription className="mt-1">- Work your computer is doing for your team, newest first.- </PanelDescription>+ <PanelTitle>{title}</PanelTitle>+ <PanelDescription className="mt-1">{description}</PanelDescription></div></PanelHeader><ResourceTable- columns={SESSION_COLUMNS}+ columns={columns}rows={sessions}rowKey={(session) => session.key}loading={loading}@@ -579,11 +932,11 @@ function SessionsPanel({failed? 'Sessions are temporarily unavailable': hasComputer- ? 'No sessions yet'+ ? emptyTitle: 'Sessions appear once your computer is set up'}description={- failed ? 'They reload by themselves.' : START_SESSION_COPY+ failed ? 'They reload by themselves.' : emptyDescription}/>}diff --git a/web/src/managed-agents/computer-state.test.ts b/web/src/managed-agents/computer-state.test.tsindex ef277fff..5d394bb8 100644--- a/web/src/managed-agents/computer-state.test.ts+++ b/web/src/managed-agents/computer-state.test.ts@@ -4,16 +4,24 @@ import {computerStatusSchema,computerSlackInstallSchema,type Computer,+ type ComputerSession,type ComputerStatus,} from './computer-api'import {FAST_POLL_MS,+ LIVE_SESSION_POLL_MS,+ SESSION_POLL_MS,SLOW_POLL_MS,+ compactStatusLine,computerChecklist,+ computerIsOnboarded,computerPollInterval,computerPresentation,heroCopy,+ relativeTime,+ sessionPollInterval,slackReturnFromSearch,+ splitSessions,} from './computer-state'const computer: Computer = {@@ -243,3 +251,123 @@ describe('Slack install return', () => {expect(slackReturnFromSearch(new URLSearchParams(''))).toBeNull()})})++function session(+ key: string,+ status: ComputerSession['status'],+ updatedAt: string,+): ComputerSession {+ return {+ key,+ title: key,+ channelId: 'C1',+ threadTs: '1.2',+ ownerSlackUserId: null,+ status,+ updatedAt,+ slackUrl: null,+ }+}++describe('onboarding', () => {+ it('is onboarded once Slack is installed and GitHub connected', () => {+ const slack = { installed: true, teamName: 'Acme' }+ const github = {+ connected: true,+ installations: [{ id: '1', accountLogin: 'acme' }],+ }+ expect(computerIsOnboarded(status())).toBe(false)+ expect(computerIsOnboarded(status({ slack }))).toBe(false)+ expect(computerIsOnboarded(status({ github }))).toBe(false)+ expect(computerIsOnboarded(status({ slack, github }))).toBe(true)+ // Onboarding is about the person's setup, not the computer's mood.+ expect(+ computerIsOnboarded(+ status({ slack, github, computer: { ...computer, state: 'parked' } }),+ ),+ ).toBe(true)+ })+})++describe('live and recent sessions', () => {+ const sessions = [+ session('old-idle', 'idle', '2026-10-11T09:00:00.000Z'),+ session('busy', 'busy', '2026-10-11T10:00:00.000Z'),+ session('ended', 'ended', '2026-10-11T11:00:00.000Z'),+ session('starting', 'starting', '2026-10-11T12:00:00.000Z'),+ session('error', 'error', '2026-10-11T08:00:00.000Z'),+ ]++ it('splits starting and busy from the rest, each newest first', () => {+ const { live, recent } = splitSessions(sessions)+ expect(live.map((s) => s.key)).toEqual(['starting', 'busy'])+ expect(recent.map((s) => s.key)).toEqual(['ended', 'old-idle', 'error'])+ expect(splitSessions([])).toEqual({ live: [], recent: [] })+ })++ it('polls sessions faster while any is live', () => {+ expect(sessionPollInterval(undefined)).toBe(SESSION_POLL_MS)+ expect(sessionPollInterval([])).toBe(SESSION_POLL_MS)+ expect(+ sessionPollInterval(sessions.filter((s) => s.status === 'idle')),+ ).toBe(SESSION_POLL_MS)+ expect(sessionPollInterval(sessions)).toBe(LIVE_SESSION_POLL_MS)+ expect(LIVE_SESSION_POLL_MS).toBe(5_000)+ expect(SESSION_POLL_MS).toBe(15_000)+ })+})++describe('relative time', () => {+ const now = new Date('2026-10-11T12:00:00.000Z').getTime()+ const ago = (ms: number) =>+ relativeTime(new Date(now - ms).toISOString(), now)++ it('reads like a person would say it', () => {+ expect(ago(0)).toBe('just now')+ expect(ago(59_000)).toBe('just now')+ expect(ago(2 * 60_000)).toBe('2 min ago')+ expect(ago(59 * 60_000 + 59_000)).toBe('59 min ago')+ expect(ago(3 * 3_600_000)).toBe('3 hr ago')+ expect(ago(30 * 3_600_000)).toBe('yesterday')+ expect(ago(4 * 86_400_000)).toBe('4 days ago')+ expect(ago(30 * 86_400_000)).not.toMatch(/ago|yesterday/)+ })++ it('treats clock skew as now and ignores bad timestamps', () => {+ expect(ago(-60_000)).toBe('just now')+ expect(relativeTime('not a date', now)).toBe('')+ })+})++describe('compact status line', () => {+ it('talks about the work when there is work', () => {+ expect(compactStatusLine(computer, 'free', 0).headline).toBe(+ 'Ready when you are.',+ )+ expect(compactStatusLine(computer, 'free', 1).headline).toContain(+ 'One thing',+ )+ expect(compactStatusLine(computer, 'free', 3).headline).toContain(+ '3 things',+ )+ })++ it('keeps resting, waking and failure visible, upgrade for free only', () => {+ const parked = { ...computer, state: 'parked' as const }+ expect(compactStatusLine(parked, 'free', 0)).toEqual({+ headline: 'Resting — wakes when you mention it.',+ detail: 'Upgrade and it never sleeps.',+ })+ expect(compactStatusLine(parked, 'paid', 0).detail).toBeUndefined()+ expect(+ compactStatusLine({ ...computer, state: 'waking' }, 'free', 0).headline,+ ).toContain('Waking')+ expect(+ compactStatusLine(+ { ...computer, state: 'failed', lastError: 'Setup timed out.' },+ 'free',+ 0,+ ),+ ).toEqual({ headline: 'Something went wrong.', detail: 'Setup timed out.' })+ })+})diff --git a/web/src/managed-agents/computer-state.ts b/web/src/managed-agents/computer-state.tsindex 65cda583..9da37b2d 100644--- a/web/src/managed-agents/computer-state.ts+++ b/web/src/managed-agents/computer-state.ts@@ -260,3 +260,110 @@ export const EXAMPLE_ASKS = ['upgrade us to the latest React and tell me what broke.','every morning, summarize what changed in main yesterday.',] as const++/**+ * Onboarded: the computer is in Slack and knows the code. From then on the+ * page stops selling and setting up, and shows the work instead (Mohamed,+ * 2026-10-11: "mainly showcase the sessions that are live").+ */+export function computerIsOnboarded(status: ComputerStatus): boolean {+ return status.slack.installed && status.github.connected+}++/** A session the computer is working on right now. */+export function sessionIsLive(session: ComputerSession): boolean {+ return session.status === 'starting' || session.status === 'busy'+}++/** Live sessions and everything else, each newest first. */+export function splitSessions(sessions: readonly ComputerSession[]): {+ live: ComputerSession[]+ recent: ComputerSession[]+} {+ const sorted = [...sessions].sort((left, right) =>+ right.updatedAt.localeCompare(left.updatedAt),+ )+ return {+ live: sorted.filter(sessionIsLive),+ recent: sorted.filter((session) => !sessionIsLive(session)),+ }+}++export const LIVE_SESSION_POLL_MS = 5_000+export const SESSION_POLL_MS = 15_000++/** Watch closely while something is being worked on. */+export function sessionPollInterval(+ sessions: readonly ComputerSession[] | undefined,+): number {+ return sessions?.some(sessionIsLive) ? LIVE_SESSION_POLL_MS : SESSION_POLL_MS+}++const MINUTE = 60_000+const HOUR = 60 * MINUTE+const DAY = 24 * HOUR++/** "just now", "2 min ago", "3 hr ago", "yesterday", "4 days ago", then a date. */+export function relativeTime(iso: string, now: number = Date.now()): string {+ const then = new Date(iso).getTime()+ if (Number.isNaN(then)) return ''+ const elapsed = Math.max(0, now - then)+ if (elapsed < MINUTE) return 'just now'+ if (elapsed < HOUR) return `${Math.floor(elapsed / MINUTE)} min ago`+ if (elapsed < DAY) return `${Math.floor(elapsed / HOUR)} hr ago`+ const days = Math.floor(elapsed / DAY)+ if (days === 1) return 'yesterday'+ if (days < 7) return `${days} days ago`+ return new Date(then).toLocaleDateString(undefined, {+ month: 'short',+ day: 'numeric',+ year:+ new Date(then).getFullYear() === new Date(now).getFullYear()+ ? undefined+ : 'numeric',+ })+}++export type StatusLine = { headline: string; detail?: string }++/**+ * The one line under the status dot once onboarded: short, in the hero's+ * voice, and about the work when there is work.+ */+export function compactStatusLine(+ computer: Computer | null,+ plan: ComputerStatus['plan'],+ liveCount: number,+): StatusLine {+ switch (computer?.state ?? 'provisioning') {+ case 'provisioning':+ return { headline: 'Coming to life. A minute or two.' }+ case 'ready':+ if (!computer?.connected) {+ return { headline: 'Reconnecting. Usually within a minute.' }+ }+ if (liveCount === 0) return { headline: 'Ready when you are.' }+ return {+ headline:+ liveCount === 1+ ? 'On it. One thing in flight.'+ : `On it. ${liveCount} things in flight.`,+ }+ case 'parked':+ return {+ headline: 'Resting — wakes when you mention it.',+ detail: plan === 'paid' ? undefined : 'Upgrade and it never sleeps.',+ }+ case 'waking':+ return { headline: 'Waking up. Picking up where it left off.' }+ case 'failed':+ return {+ headline: 'Something went wrong.',+ detail:+ computer?.lastError ??+ 'Your computer could not start. Try again, or tell us if it keeps happening.',+ }+ case 'deleting':+ return { headline: 'Saying goodbye.' }+ }+}