Skip to content

An open-source, faster Devin alternative

TypeScript

Computer: show the first task landing at the end of setup

Igor Zalutski via Computeraa7a263c2910
diff --git a/web/src/api/mock.ts b/web/src/api/mock.ts
index af6a2ebd..f74d5b4d 100644
--- a/web/src/api/mock.ts
+++ b/web/src/api/mock.ts
@@ -1279,8 +1279,9 @@ const previewServiceConnection = {
// The organization's computer (work 052 contract). Onboarded by default with
// 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 and `?computer=parked` a sleeping
-// computer.
+// 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.
function previewComputerMode() {
return new URLSearchParams(window.location.search).get('computer')
}
@@ -1321,6 +1322,9 @@ function previewComputer() {
}
}
+// When the first-task preview first asked for sessions.
+let previewFirstTaskSince: number | null = null
+
function previewComputerSessions() {
// Relative to now so the page's "2 min ago" reads true in the preview.
const ago = (minutes: number) =>
@@ -1341,6 +1345,12 @@ function previewComputerSessions() {
slackUrl: `https://acme.slack.com/archives/C0PREVIEW/p${ts.replace('.', '')}`,
})
const mode = previewComputerMode()
+ if (mode === 'first') {
+ previewFirstTaskSince ??= Date.now()
+ return Date.now() - previewFirstTaskSince < 6_000
+ ? []
+ : [session('1760000300.000100', 'Fix the flaky checkout test', 'busy', 0)]
+ }
const live = mode === 'quiet' || mode === 'parked' ? 'idle' : 'busy'
return [
session('1760000300.000100', 'Fix the flaky checkout test', live, 2),
diff --git a/web/src/managed-agents/Computer.test.tsx b/web/src/managed-agents/Computer.test.tsx
index a05b3d35..a2238e52 100644
--- a/web/src/managed-agents/Computer.test.tsx
+++ b/web/src/managed-agents/Computer.test.tsx
@@ -455,6 +455,67 @@ describe('Computer page', () => {
expect(container.textContent).toContain('Repositories in acme')
expect(container.textContent).not.toContain('Live now')
})
+ it('shows the first task landing, live, once it has waited for it', async () => {
+ computerApi.getComputer.mockResolvedValue(onboarded)
+ computerApi.getComputerSessions.mockResolvedValue([])
+
+ render('/computer')
+ await settle(
+ () => container.textContent?.includes('Step 3 of 3') === true,
+ 'last setup step',
+ )
+
+ computerApi.getComputerSessions.mockResolvedValue([
+ { ...liveSession, updatedAt: minutesAgo(0) },
+ ])
+ await act(async () => {
+ await client.invalidateQueries({ queryKey: ['managed-computer'] })
+ })
+ const panel = () =>
+ container.querySelector('section[aria-labelledby="first-task-title"]')
+ await settle(() => panel() !== null, 'first task')
+ expect(panel()!.textContent).toContain("It's on your first task")
+ expect(panel()!.textContent).toContain('Fix the flaky checkout test')
+ expect(panel()!.textContent).toContain('just now')
+ expect(
+ panel()!.querySelector('a[href="https://acme.slack.com/archives/C1/p11"]')
+ ?.textContent,
+ ).toBe('Open the thread')
+ // Nothing to dismiss while it works.
+ expect(panel()!.querySelector('button[aria-label="Dismiss"]')).toBeNull()
+
+ computerApi.getComputerSessions.mockResolvedValue([
+ { ...liveSession, status: 'idle' },
+ ])
+ await act(async () => {
+ await client.invalidateQueries({ queryKey: ['managed-computer'] })
+ })
+ await settle(
+ () => panel()?.textContent?.includes('It answered') === true,
+ 'first task answered',
+ )
+ act(() => {
+ panel()!
+ .querySelector<HTMLButtonElement>('button[aria-label="Dismiss"]')!
+ .click()
+ })
+ expect(panel()).toBeNull()
+ })
+
+ it('leaves a finished first task out of a later visit', async () => {
+ computerApi.getComputer.mockResolvedValue(onboarded)
+ computerApi.getComputerSessions.mockResolvedValue([doneSession])
+
+ render('/computer')
+ await settle(
+ () => container.textContent?.includes('Explain the billing') === true,
+ 'sessions',
+ )
+ expect(
+ container.querySelector('section[aria-labelledby="first-task-title"]'),
+ ).toBeNull()
+ })
+
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.tsx
index 589cfce9..19ada881 100644
--- a/web/src/managed-agents/Computer.tsx
+++ b/web/src/managed-agents/Computer.tsx
@@ -76,7 +76,10 @@ import {
computerIsOnboarded,
computerPollInterval,
computerPresentation,
+ firstSession,
+ firstTaskCopy,
relativeTime,
+ sessionIsLive,
sessionPollInterval,
firstTaskLead,
setupStep,
@@ -162,6 +165,14 @@ function ComputerPageContent() {
setSearchParams(next, { replace: true })
}, [queryClient, searchParams, setSearchParams])
+ // Someone who waited here for the first task sees it land: setup gives way
+ // to the work with that task on top, live, and a way into its thread.
+ // Without the wait, only a first task still under way earns the panel.
+ const step = status.data ? setupStep(status.data, sessions.data) : null
+ const [waitedForFirstTask, setWaitedForFirstTask] = useState(false)
+ const [firstTaskDismissed, setFirstTaskDismissed] = useState(false)
+ if (step === 'hello' && !waitedForFirstTask) setWaitedForFirstTask(true)
+
if (status.isLoading) {
return (
<div
@@ -226,8 +237,12 @@ function ComputerPageContent() {
// Once it is in Slack, knows the code and has had its first mention, the
// page is about the work.
- const step = setupStep(status.data, sessions.data)
if (step === null) {
+ const first = firstSession(sessions.data)
+ const showFirstTask =
+ first !== null &&
+ !firstTaskDismissed &&
+ (waitedForFirstTask || sessionIsLive(first))
return (
<WithDeveloperFooter>
<div className="space-y-8">
@@ -238,6 +253,13 @@ function ComputerPageContent() {
onRetry={() => create.mutate()}
/>
{slackProblemPanel}
+ {showFirstTask ? (
+ <FirstTask
+ session={first}
+ readAt={sessions.dataUpdatedAt}
+ onDismiss={() => setFirstTaskDismissed(true)}
+ />
+ ) : null}
<SessionsPanel
live={live}
recent={recent}
@@ -543,6 +565,94 @@ function AlreadyLinked({
)
}
+/**
+ * The payoff of setup: the first task, landed. Where it is, live, and the way
+ * into its thread, so the person sees the loop close.
+ */
+function FirstTask({
+ session,
+ readAt,
+ onDismiss,
+}: {
+ session: ComputerSession
+ readAt: number
+ onDismiss: () => void
+}) {
+ const now = Math.max(useNow(30_000), readAt)
+ const copy = firstTaskCopy(session.status)
+ const live = sessionIsLive(session)
+ return (
+ <section
+ aria-labelledby="first-task-title"
+ aria-live="polite"
+ className="bg-panel relative rounded-xl border px-6 py-5 shadow-sm"
+ >
+ {live ? null : (
+ <Button
+ variant="ghost"
+ size="icon"
+ className="text-muted-foreground absolute top-3 right-3"
+ aria-label="Dismiss"
+ onClick={onDismiss}
+ >
+ <X className="size-4" aria-hidden />
+ </Button>
+ )}
+ <div className="flex gap-5">
+ <div
+ className={cn(
+ 'flex size-11 shrink-0 items-center justify-center rounded-full',
+ session.status === 'error'
+ ? 'bg-destructive/10 text-destructive'
+ : live
+ ? 'bg-amber-500/10'
+ : 'bg-primary/15 text-primary',
+ )}
+ aria-hidden
+ >
+ {session.status === 'error' ? (
+ <TriangleAlert className="size-5" />
+ ) : live ? (
+ <PulseDot tone="busy" className="size-2.5" />
+ ) : (
+ <Check className="size-5" />
+ )}
+ </div>
+ <div className="max-w-2xl min-w-0 pr-8">
+ <h2
+ id="first-task-title"
+ className="text-lg font-semibold tracking-tight text-balance"
+ >
+ {copy.headline}
+ </h2>
+ <p className="text-muted-foreground mt-1 flex min-w-0 items-baseline gap-2 text-sm">
+ <span className="text-foreground truncate font-medium">
+ {session.title || 'Untitled session'}
+ </span>
+ <span aria-hidden>·</span>
+ <time
+ className="whitespace-nowrap"
+ dateTime={session.updatedAt}
+ title={new Date(session.updatedAt).toLocaleString()}
+ >
+ {relativeTime(session.updatedAt, now)}
+ </time>
+ </p>
+ <p className="text-muted-foreground mt-3 text-sm">{copy.body}</p>
+ {session.slackUrl ? (
+ <Button className="mt-5" asChild>
+ <a href={session.slackUrl} target="_blank" rel="noreferrer">
+ <MessagesSquare className="size-4" aria-hidden />
+ Open the thread
+ </a>
+ </Button>
+ ) : null}
+ </div>
+ </div>
+ </section>
+ )
+}
+
function SlackInstallFailed({
message,
status,
diff --git a/web/src/managed-agents/computer-state.test.ts b/web/src/managed-agents/computer-state.test.ts
index 08581edb..5ae5c4e2 100644
--- a/web/src/managed-agents/computer-state.test.ts
+++ b/web/src/managed-agents/computer-state.test.ts
@@ -21,6 +21,8 @@ import {
relativeTime,
sessionPollInterval,
alreadyLinkedCopy,
+ firstSession,
+ firstTaskCopy,
slackReturnFromSearch,
splitSessions,
} from './computer-state'
@@ -347,7 +349,8 @@ describe('live and recent sessions', () => {
it('polls sessions faster while any is live', () => {
expect(sessionPollInterval(undefined)).toBe(SESSION_POLL_MS)
- expect(sessionPollInterval([])).toBe(SESSION_POLL_MS)
+ // Waiting for the first task: setup moves on by itself, promptly.
+ expect(sessionPollInterval([])).toBe(LIVE_SESSION_POLL_MS)
expect(
sessionPollInterval(sessions.filter((s) => s.status === 'idle')),
).toBe(SESSION_POLL_MS)
@@ -357,6 +360,29 @@ describe('live and recent sessions', () => {
})
})
+describe('first task', () => {
+ it('is the only session, while there is just the one', () => {
+ expect(firstSession(undefined)).toBeNull()
+ expect(firstSession([])).toBeNull()
+ const first = session('first', 'busy', '2026-10-11T10:00:00.000Z')
+ const second = session('second', 'idle', '2026-10-11T11:00:00.000Z')
+ expect(firstSession([first])).toBe(first)
+ expect(firstSession([first, second])).toBeNull()
+ })
+
+ it('says where the task is', () => {
+ expect(firstTaskCopy('starting').headline).toBe(
+ "It's picking up your first task",
+ )
+ expect(firstTaskCopy('busy').headline).toBe("It's on your first task")
+ expect(firstTaskCopy('idle').headline).toBe('It answered your first task')
+ expect(firstTaskCopy('ended').headline).toBe('Your first task is done')
+ expect(firstTaskCopy('error').headline).toBe(
+ 'Your first task hit a problem',
+ )
+ })
+})
+
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.ts
index 9d9c7805..be3fe39b 100644
--- a/web/src/managed-agents/computer-state.ts
+++ b/web/src/managed-agents/computer-state.ts
@@ -293,13 +293,58 @@ export function splitSessions(sessions: readonly ComputerSession[]): {
export const LIVE_SESSION_POLL_MS = 5_000
export const SESSION_POLL_MS = 15_000
-/** Watch closely while something is being worked on. */
+/**
+ * Watch closely while something is being worked on, and while the first task
+ * is awaited: setup promises to move on by itself the moment it lands.
+ */
export function sessionPollInterval(
sessions: readonly ComputerSession[] | undefined,
): number {
+ if (sessions?.length === 0) return LIVE_SESSION_POLL_MS
return sessions?.some(sessionIsLive) ? LIVE_SESSION_POLL_MS : SESSION_POLL_MS
}
+/** The organization's only session, while it has had just the one. */
+export function firstSession(
+ sessions: readonly ComputerSession[] | undefined,
+): ComputerSession | null {
+ return sessions?.length === 1 ? sessions[0] : null
+}
+
+/** What the first-task panel says, true to where the task is. */
+export function firstTaskCopy(status: ComputerSessionStatus): {
+ headline: string
+ body: string
+} {
+ switch (status) {
+ case 'starting':
+ return {
+ headline: "It's picking up your first task",
+ body: 'Follow along in the thread. This updates by itself.',
+ }
+ case 'busy':
+ return {
+ headline: "It's on your first task",
+ body: 'Follow along in the thread, or steer it there. This updates by itself.',
+ }
+ case 'idle':
+ return {
+ headline: 'It answered your first task',
+ body: 'Reply in the thread to keep going.',
+ }
+ case 'ended':
+ return {
+ headline: 'Your first task is done',
+ body: `Ask again whenever you need it. ${START_SESSION_COPY}`,
+ }
+ case 'error':
+ return {
+ headline: 'Your first task hit a problem',
+ body: 'Open the thread to see what happened, then ask again.',
+ }
+ }
+}
+
const MINUTE = 60_000
const HOUR = 60 * MINUTE
const DAY = 24 * HOUR