An open-source, faster Devin alternative
TypeScript
Computer: show the computer coming to life during setup
Igor Zalutski via Computer34e80225bc3b
diff --git a/web/src/api/mock.ts b/web/src/api/mock.tsindex f74d5b4d..48841d19 100644--- a/web/src/api/mock.ts+++ b/web/src/api/mock.ts@@ -1280,27 +1280,41 @@ const previewServiceConnection = {// one live and two recent sessions; `?computer=setup` shows the page before// Slack and GitHub are connected (no computer yet: it comes with the Slack// install), `?computer=quiet` nothing live, `?computer=parked` a sleeping-// computer and `?computer=first` the last setup step until its first task-// lands a few seconds in.+// computer, `?computer=first` the last setup step until its first task+// lands a few seconds in, and `?computer=booting` a new computer coming online+// over about twenty seconds.function previewComputerMode() {return new URLSearchParams(window.location.search).get('computer')}+// When the booting preview first asked for the computer.+let previewBootSince: number | null = null+function previewComputer() {const mode = previewComputerMode()const setup = mode === 'setup'const parked = mode === 'parked'+ let booted = { state: parked ? 'parked' : 'ready', connected: !parked }+ if (mode === 'booting') {+ previewBootSince ??= Date.now()+ const elapsed = Date.now() - previewBootSince+ booted =+ elapsed < 12_000+ ? { state: 'provisioning', connected: false }+ : { state: 'ready', connected: elapsed >= 20_000 }+ }return {computer: setup? null: {- state: parked ? 'parked' : 'ready',- connected: !parked,+ ...booted,vcpus: 2,memoryGiB: 8,diskGiB: 128,lastError: null,- createdAt: new Date(BASE).toISOString(),+ createdAt: new Date(+ mode === 'booting' ? (previewBootSince ?? BASE) : BASE,+ ).toISOString(),updatedAt: new Date(BASE).toISOString(),},slack: setup@@ -1345,6 +1359,7 @@ function previewComputerSessions() {slackUrl: `https://acme.slack.com/archives/C0PREVIEW/p${ts.replace('.', '')}`,})const mode = previewComputerMode()+ if (mode === 'booting') return []if (mode === 'first') {previewFirstTaskSince ??= Date.now()return Date.now() - previewFirstTaskSince < 6_000diff --git a/web/src/managed-agents/Computer.test.tsx b/web/src/managed-agents/Computer.test.tsxindex a2238e52..fb96e4df 100644--- a/web/src/managed-agents/Computer.test.tsx+++ b/web/src/managed-agents/Computer.test.tsx@@ -184,6 +184,7 @@ describe('Computer page', () => {)expect(container.textContent).toContain('Step 1 of 3')+ expect(container.textContent).toContain('Not a Slack admin?')// Before Slack there is no computer to report on, and no pitch.expect(container.textContent).not.toContain('Not set up yet')expect(container.textContent).not.toContain('Setting up')@@ -234,7 +235,7 @@ describe('Computer page', () => {render('/computer')await settle(- () => container.textContent?.includes('Setting up') === true,+ () => container.textContent?.includes('Creating') === true,'provisioning computer',)expect(computerApi.createComputer).toHaveBeenCalledTimes(1)@@ -246,7 +247,7 @@ describe('Computer page', () => {render('/computer')await settle(- () => container.textContent?.includes('Setting up') === true,+ () => container.textContent?.includes('Creating') === true,'computer status',)expect(computerApi.createComputer).not.toHaveBeenCalled()@@ -516,6 +517,37 @@ describe('Computer page', () => {).toBeNull()})+ it('shows a new computer coming to life during setup', async () => {+ computerApi.getComputer.mockResolvedValue({+ ...onboarded,+ computer: {+ ...onboarded.computer,+ state: 'provisioning',+ connected: false,+ createdAt: minutesAgo(1),+ },+ })++ render('/computer')+ const boot = () =>+ container.querySelector('[role="status"][aria-label^="Your computer"]')+ await settle(() => boot() !== null, 'boot progress')+ expect(boot()!.getAttribute('aria-label')).toBe('Your computer: Creating')+ expect(boot()!.textContent).toContain('Starting')+ expect(boot()!.textContent).toMatch(/1:0\d/)++ computerApi.getComputer.mockResolvedValue(onboarded)+ await act(async () => {+ await client.invalidateQueries({ queryKey: ['managed-computer'] })+ })+ await settle(+ () => boot()?.getAttribute('aria-label') === 'Your computer: Online',+ 'online',+ )+ // Done: no clock left running.+ expect(boot()!.textContent).not.toMatch(/\d:\d\d/)+ })+it('opens a DM with the app when the bot is known', async () => {computerApi.getComputer.mockResolvedValue({...onboarded,diff --git a/web/src/managed-agents/Computer.tsx b/web/src/managed-agents/Computer.tsxindex 19ada881..4e1a6bf3 100644--- a/web/src/managed-agents/Computer.tsx+++ b/web/src/managed-agents/Computer.tsx@@ -75,7 +75,10 @@ import {START_SESSION_COPY,computerIsOnboarded,computerPollInterval,+ BOOT_STAGES,+ bootProgress,computerPresentation,+ elapsedClock,firstSession,firstTaskCopy,relativeTime,@@ -388,6 +391,77 @@ function StatusLabel({)}+/**+ * A new computer coming to life, stage by stage, with the time it has taken+ * so far: waiting reads as progress, not as a page that forgot about you.+ */+function BootProgress({+ stage,+ since,+}: {+ stage: number+ since: string | null+}) {+ const now = useNow(1_000)+ const online = stage === BOOT_STAGES.length - 1+ return (+ <div+ role="status"+ aria-label={`Your computer: ${BOOT_STAGES[stage]}`}+ className="flex items-center gap-2 text-sm"+ >+ <ol className="flex items-center gap-2">+ {BOOT_STAGES.map((label, index) => {+ const done = index < stage || online+ const current = index === stage && !online+ return (+ <li key={label} className="flex items-center gap-2">+ {index > 0 ? (+ <span+ className={cn(+ 'h-px w-4 transition-colors',+ done || current ? 'bg-foreground/30' : 'bg-border',+ )}+ aria-hidden+ />+ ) : null}+ {done ? (+ online && index === stage ? (+ <PulseDot tone="alive" />+ ) : (+ <Check className="size-3.5 text-emerald-600" aria-hidden />+ )+ ) : current ? (+ <PulseDot tone="busy" />+ ) : (+ <span+ className="border-muted-foreground/40 size-2 rounded-full border"+ aria-hidden+ />+ )}+ <span+ className={cn(+ current || (online && index === stage)+ ? 'font-medium'+ : 'text-muted-foreground',+ )}+ >+ {label}+ </span>+ </li>+ )+ })}+ </ol>+ {since && !online ? (+ <span className="text-muted-foreground tabular-nums">+ <span aria-hidden>· </span>+ <time dateTime={since}>{elapsedClock(since, now)}</time>+ </span>+ ) : null}+ </div>+ )+}+function RetryButton({creating,onRetry,@@ -724,6 +798,7 @@ function Setup({const failedToCreate = !computer && createError !== nullconst failed = failedToCreate || computer?.state === 'failed'const position = SETUP_STEPS.indexOf(step) + 1+ const boot = bootProgress(status)const done: Record<SetupStep, boolean> = {slack: status.slack.installed,github: status.github.connected,@@ -742,8 +817,11 @@ function Setup({<p className="text-muted-foreground text-sm font-medium">Step {position} of {SETUP_STEPS.length}</p>- {/* Before Slack there is no computer to report on. */}- {computer || status.slack.installed ? (+ {/* Before Slack there is no computer to report on; while it+ comes to life, how far along it is. */}+ {boot && !failed ? (+ <BootProgress stage={boot.stage} since={boot.since} />+ ) : computer || status.slack.installed ? (<StatusLabel status={status} failedToCreate={failedToCreate} />) : null}</div>@@ -814,6 +892,12 @@ function Setup({right there.</p><SlackInstallButton size="lg" label="Add to Slack" />+ {/* Most workspaces only let admins add apps; where approval is+ on, Slack itself lets a member ask for it. */}+ <p className="text-xs">+ Not a Slack admin? Click it anyway: Slack lets you ask your+ admin to approve it. Come back here once they have.+ </p></SetupItem><SetupItemnumber={2}diff --git a/web/src/managed-agents/computer-state.test.ts b/web/src/managed-agents/computer-state.test.tsindex 5ae5c4e2..54b1a889 100644--- a/web/src/managed-agents/computer-state.test.ts+++ b/web/src/managed-agents/computer-state.test.ts@@ -23,6 +23,8 @@ import {alreadyLinkedCopy,firstSession,firstTaskCopy,+ bootProgress,+ elapsedClock,slackReturnFromSearch,splitSessions,} from './computer-state'@@ -383,6 +385,49 @@ describe('first task', () => {})})+describe('boot progress', () => {+ const base = {+ computer: null,+ slack: { installed: true },+ github: { connected: true, installations: [] },+ plan: 'free' as const,+ }+ const at = '2026-10-11T10:00:00.000Z'+ const withState = (state: Computer['state'], connected = false) => ({+ ...base,+ computer: { ...computer, state, connected, createdAt: at },+ })++ it('walks from the Slack install to online', () => {+ expect(bootProgress({ ...base, slack: { installed: false } })).toBeNull()+ expect(bootProgress(base)).toEqual({ stage: 0, since: null })+ expect(bootProgress(withState('provisioning'))).toEqual({+ stage: 0,+ since: at,+ })+ expect(bootProgress(withState('ready'))).toEqual({ stage: 1, since: at })+ expect(bootProgress(withState('ready', true))).toEqual({+ stage: 2,+ since: at,+ })+ })++ it('is not booting asleep, failed or going', () => {+ for (const state of ['parked', 'waking', 'failed', 'deleting'] as const) {+ expect(bootProgress(withState(state))).toBeNull()+ }+ })++ it('reads the time taken as a clock', () => {+ const start = new Date(at).getTime()+ expect(elapsedClock(at, start + 7_000)).toBe('0:07')+ expect(elapsedClock(at, start + 161_000)).toBe('2:41')+ expect(elapsedClock(at, start + 3_723_000)).toBe('1:02:03')+ expect(elapsedClock(at, start - 5_000)).toBe('0:00')+ expect(elapsedClock('nope', start)).toBe('')+ })+})+describe('relative time', () => {const now = new Date('2026-10-11T12:00:00.000Z').getTime()const ago = (ms: number) =>diff --git a/web/src/managed-agents/computer-state.ts b/web/src/managed-agents/computer-state.tsindex be3fe39b..77edfe16 100644--- a/web/src/managed-agents/computer-state.ts+++ b/web/src/managed-agents/computer-state.ts@@ -100,6 +100,38 @@ export function computerPresentation(}}+export const BOOT_STAGES = ['Creating', 'Starting', 'Online'] as const++/**+ * How far a new computer is in coming to life, from the Slack install to+ * online: the stage it is in (the last one, Online, means done) and when it+ * began. Null when it is not booting: not set up, asleep, failed or going.+ */+export function bootProgress(+ status: ComputerStatus,+): { stage: number; since: string | null } | null {+ const { computer } = status+ if (!computer)+ return status.slack.installed ? { stage: 0, since: null } : null+ if (computer.state === 'provisioning')+ return { stage: 0, since: computer.createdAt }+ if (computer.state !== 'ready') return null+ return { stage: computer.connected ? 2 : 1, since: computer.createdAt }+}++/** Time since `iso` as a clock: "0:07", "2:41", "1:02:03". */+export function elapsedClock(iso: string, now: number = Date.now()): string {+ const then = new Date(iso).getTime()+ if (Number.isNaN(then)) return ''+ const seconds = Math.floor(Math.max(0, now - then) / 1000)+ const pad = (value: number) => String(value).padStart(2, '0')+ const hours = Math.floor(seconds / 3600)+ const minutes = Math.floor(seconds / 60) % 60+ return hours > 0+ ? `${hours}:${pad(minutes)}:${pad(seconds % 60)}`+ : `${minutes}:${pad(seconds % 60)}`+}+export const FAST_POLL_MS = 5_000export const SLOW_POLL_MS = 30_000