Skip to content

An open-source, faster Devin alternative

TypeScript

Computer behind a rollout flag (COMPUTER_ENABLED_ORGS / _FOR_ALL)

Slack U06GFN8DJ7P8a8e275651cd
diff --git a/cloudflare-workers/api-edge/scripts/stack.mjs b/cloudflare-workers/api-edge/scripts/stack.mjs
index bff73573..dc081bf2 100644
--- a/cloudflare-workers/api-edge/scripts/stack.mjs
+++ b/cloudflare-workers/api-edge/scripts/stack.mjs
@@ -382,6 +382,8 @@ function writeConfig(stack) {
MANAGED_AGENTS_API_URL: stack.edgeUrl ?? "",
SESSIONS_API_URL: stack.edgeUrl ?? "",
MANAGED_DEFAULT_BUDGET_USD: "5",
+ // Preview stacks give every organization its computer (work 052).
+ COMPUTER_ENABLED_FOR_ALL: "true",
// Billing (optional): with an Autumn sandbox key, new organizations land
// on Autumn's base plan and the 5-minute cron meters usage into credits.
...(autumnEnabled() ? { AUTUMN_NEW_ORGS: "true" } : {}),
diff --git a/cloudflare-workers/api-edge/src/computer.ts b/cloudflare-workers/api-edge/src/computer.ts
index 757c59a8..0ee15878 100644
--- a/cloudflare-workers/api-edge/src/computer.ts
+++ b/cloudflare-workers/api-edge/src/computer.ts
@@ -164,3 +164,21 @@ export function publicComputerBody(
}
throw new Error("Unsupported computer response");
}
+
+/**
+ * Whether an organization has its computer (work 052 rollout). Until
+ * COMPUTER_ENABLED_FOR_ALL is "true", only organizations listed in
+ * COMPUTER_ENABLED_ORGS (comma-separated ids) see it; for everyone else the
+ * computer routes do not exist and the dashboard hides the page.
+ */
+export function computerEnabledFor(
+ env: { COMPUTER_ENABLED_FOR_ALL?: string; COMPUTER_ENABLED_ORGS?: string },
+ orgID: string | null | undefined,
+): boolean {
+ if (env.COMPUTER_ENABLED_FOR_ALL === "true") return true;
+ if (!orgID) return false;
+ return (env.COMPUTER_ENABLED_ORGS ?? "")
+ .split(",")
+ .map((id) => id.trim())
+ .includes(orgID);
+}
diff --git a/cloudflare-workers/api-edge/src/dashboard.ts b/cloudflare-workers/api-edge/src/dashboard.ts
index aea082e7..5291f98a 100644
--- a/cloudflare-workers/api-edge/src/dashboard.ts
+++ b/cloudflare-workers/api-edge/src/dashboard.ts
@@ -38,10 +38,14 @@ import {
proxyManagedAgents,
proxyPublicTemplateInspection,
} from "./managed_agents";
+import { computerEnabledFor } from "./computer";
import { enableManagedBilling } from "./model_billing";
import { insufficientManagedAgentCredits } from "./managed_agent_credit_gate";
export interface DashboardEnv {
+ /** Computer rollout (work 052): see computerEnabledFor in computer.ts. */
+ COMPUTER_ENABLED_FOR_ALL?: string;
+ COMPUTER_ENABLED_ORGS?: string;
OPENCOMPUTER_DB: D1Database;
SESSIONS_KV: KVNamespace;
CREDIT_ACCOUNT: DurableObjectNamespace;
@@ -402,6 +406,7 @@ async function handleMe(req: Request, env: DashboardEnv, caller: Caller): Promis
orgs,
durableSessionsEnabled: !!user.durable_sessions_enabled,
infrastructureEnabled: !!user.infrastructure_enabled,
+ computerEnabled: computerEnabledFor(env, caller.orgID),
});
}
diff --git a/cloudflare-workers/api-edge/src/managed_agents.test.ts b/cloudflare-workers/api-edge/src/managed_agents.test.ts
index 76be00dd..c7824e9c 100644
--- a/cloudflare-workers/api-edge/src/managed_agents.test.ts
+++ b/cloudflare-workers/api-edge/src/managed_agents.test.ts
@@ -1,3 +1,4 @@
+import { computerEnabledFor } from "./computer";
import { afterEach, describe, expect, it, vi } from "vitest";
import {
@@ -6455,10 +6456,31 @@ describe("organization computer (work 052)", () => {
const env = {
MANAGED_AGENTS_API_URL: "https://managedagents.test",
OC_MANAGED_AGENTS_SECRET: "test-secret",
+ COMPUTER_ENABLED_ORGS: "org_other, org_test",
};
const caller = { orgID: "org_test", userID: "user_test", role: "admin" };
const dashboard = "/api/dashboard/managed-agents";
+ it("hides the computer from organizations outside the rollout", async () => {
+ const fetchMock = vi.fn();
+ vi.stubGlobal("fetch", fetchMock);
+ const response = await proxyManagedAgents(
+ new Request(`https://app.opencomputer.dev${dashboard}/computer`),
+ { ...env, COMPUTER_ENABLED_ORGS: "org_other" },
+ caller,
+ dashboard,
+ );
+ expect(response.status).toBe(404);
+ expect(fetchMock).not.toHaveBeenCalled();
+ });
+
+ it("enables everyone with COMPUTER_ENABLED_FOR_ALL", () => {
+ expect(computerEnabledFor({ COMPUTER_ENABLED_FOR_ALL: "true" }, "org_x")).toBe(true);
+ expect(computerEnabledFor({ COMPUTER_ENABLED_ORGS: " org_x ,org_y" }, "org_x")).toBe(true);
+ expect(computerEnabledFor({ COMPUTER_ENABLED_ORGS: "org_y" }, "org_x")).toBe(false);
+ expect(computerEnabledFor({}, "org_x")).toBe(false);
+ });
+
const computerStatus = {
computer: {
state: "ready",
diff --git a/cloudflare-workers/api-edge/src/managed_agents.ts b/cloudflare-workers/api-edge/src/managed_agents.ts
index 28202ea8..ef56038e 100644
--- a/cloudflare-workers/api-edge/src/managed_agents.ts
+++ b/cloudflare-workers/api-edge/src/managed_agents.ts
@@ -2,12 +2,16 @@ import { getAutumnCustomer } from "./autumn_webhook";
import {
COMPUTER_ERROR_MESSAGES,
computerFallbackMessage,
+ computerEnabledFor,
isComputerRoute,
isComputerRouteSuffix,
publicComputerBody,
} from "./computer";
export interface ManagedAgentsEnv {
+ /** Computer rollout (work 052): see computerEnabledFor. */
+ COMPUTER_ENABLED_FOR_ALL?: string;
+ COMPUTER_ENABLED_ORGS?: string;
MANAGED_AGENTS_API_URL?: string;
OC_MANAGED_AGENTS_SECRET?: string;
OPENCOMPUTER_DB?: D1Database;
@@ -3487,7 +3491,8 @@ export async function proxyManagedAgents(
// The computer is a dashboard surface in v1; API keys do not reach it.
if (
isComputerRouteSuffix(suffix) &&
- publicPrefix !== DASHBOARD_MANAGED_AGENTS_PREFIX
+ (publicPrefix !== DASHBOARD_MANAGED_AGENTS_PREFIX ||
+ !computerEnabledFor(env, caller.orgID))
) {
return Response.json({ error: "route not found" }, { status: 404 });
}
diff --git a/cloudflare-workers/api-edge/wrangler.prod.toml b/cloudflare-workers/api-edge/wrangler.prod.toml
index 0956b7f2..e08effc2 100644
--- a/cloudflare-workers/api-edge/wrangler.prod.toml
+++ b/cloudflare-workers/api-edge/wrangler.prod.toml
@@ -157,6 +157,10 @@ crons = ["*/5 * * * *"]
[vars]
WORKER_ENV = "prod"
+# Computer rollout (work 052): only the organizations listed (comma-separated
+# ids) see their computer until COMPUTER_ENABLED_FOR_ALL is "true".
+COMPUTER_ENABLED_FOR_ALL = "false"
+COMPUTER_ENABLED_ORGS = ""
# PoolStock sizing. SHARDS × TARGET must stay ≤ the cell's MicroVM pool
# (OPENSANDBOX_MICROVM_POOL_TARGET on the CP) or every shard sits permanently
# below low-water, restocks on every claim, and competes for a supply that can
diff --git a/cloudflare-workers/api-edge/wrangler.toml b/cloudflare-workers/api-edge/wrangler.toml
index 18637d1a..18348c5a 100644
--- a/cloudflare-workers/api-edge/wrangler.toml
+++ b/cloudflare-workers/api-edge/wrangler.toml
@@ -170,6 +170,9 @@ crons = ["*/5 * * * *"]
[vars]
WORKER_ENV = "dev"
+# Computer rollout (work 052); see wrangler.prod.toml.
+COMPUTER_ENABLED_FOR_ALL = "false"
+COMPUTER_ENABLED_ORGS = ""
# Dev override of the per-org paused-sandbox cap (prod defaults to 100) so the
# promotion path can be exercised without pausing hundreds of boxes.
PAUSED_CAP = "10"
diff --git a/web/src/api/mock.ts b/web/src/api/mock.ts
index 71c1ad96..c31b1f73 100644
--- a/web/src/api/mock.ts
+++ b/web/src/api/mock.ts
@@ -23,6 +23,7 @@ const me = {
orgId: 'org_digger',
durableSessionsEnabled: true,
infrastructureEnabled: true,
+ computerEnabled: true,
orgs: [
{ id: 'org_digger', name: 'Digger', isPersonal: false, isActive: true },
{ id: 'org_personal', name: 'Personal', isPersonal: true, isActive: false },
diff --git a/web/src/api/schemas.ts b/web/src/api/schemas.ts
index 2faf7541..d84d32c7 100644
--- a/web/src/api/schemas.ts
+++ b/web/src/api/schemas.ts
@@ -21,6 +21,8 @@ export const MeResponseSchema = z.object({
orgs: z.array(OrgInfoSchema).optional(),
durableSessionsEnabled: z.boolean(),
infrastructureEnabled: z.boolean(),
+ /** Work 052 rollout: the organization has its computer. Absent on older edges. */
+ computerEnabled: z.boolean().optional(),
authMode: z.string().optional(),
capabilities: z
.object({
diff --git a/web/src/components/app-shell-nav.ts b/web/src/components/app-shell-nav.ts
index a6bc1759..8316be30 100644
--- a/web/src/components/app-shell-nav.ts
+++ b/web/src/components/app-shell-nav.ts
@@ -39,6 +39,7 @@ export function managedAgentsNav(options: {
projectId?: string
durableSessionsEnabled: boolean
infrastructureEnabled: boolean
+ computerEnabled?: boolean
}): NavGroup[] {
const groups: NavGroup[] = []
@@ -126,7 +127,9 @@ export function managedAgentsNav(options: {
// reachable once an advanced area is open.
groups.push({
items: [
- { to: '/computer', label: 'Computer', icon: Computer },
+ ...(options.computerEnabled
+ ? [{ to: '/computer', label: 'Computer', icon: Computer }]
+ : []),
{ to: '/', label: 'Projects', icon: FolderKanban, end: true },
],
})
diff --git a/web/src/components/app-shell.test.ts b/web/src/components/app-shell.test.ts
index 8b51938e..4f9e8520 100644
--- a/web/src/components/app-shell.test.ts
+++ b/web/src/components/app-shell.test.ts
@@ -9,23 +9,29 @@ describe('managed agents navigation', () => {
}
it('lists the project list on the homepage even without advanced areas', () => {
- expect(
- managedAgentsNav(defaults).map((group) =>
- group.items.map((item) => item.label),
- ),
- ).toEqual([['Computer', 'Projects'], ['Connections']])
- expect(managedAgentsNav(defaults)[0]?.items[0]).toMatchObject({
+ const nav = managedAgentsNav({ ...defaults, computerEnabled: true })
+ expect(nav.map((group) => group.items.map((item) => item.label))).toEqual([
+ ['Computer', 'Projects'],
+ ['Connections'],
+ ])
+ expect(nav[0]?.items[0]).toMatchObject({
to: '/computer',
label: 'Computer',
})
- expect(managedAgentsNav(defaults)[0]?.items[1]?.end).toBe(true)
- expect(managedAgentsNav(defaults)[1]?.items[0]).toMatchObject({
+ expect(nav[0]?.items[1]?.end).toBe(true)
+ expect(nav[1]?.items[0]).toMatchObject({
to: '/managed-agents/connections',
label: 'Connections',
icon: Plug,
})
})
+ it('hides the computer from organizations without it (rollout flag)', () => {
+ expect(
+ managedAgentsNav(defaults)[0]?.items.map((item) => item.label),
+ ).toEqual(['Projects'])
+ })
+
it('shows project navigation only after a project is selected', () => {
const nav = managedAgentsNav({ ...defaults, projectId: 'project one' })
diff --git a/web/src/components/app-shell.tsx b/web/src/components/app-shell.tsx
index 6cef7a25..a53655c2 100644
--- a/web/src/components/app-shell.tsx
+++ b/web/src/components/app-shell.tsx
@@ -337,6 +337,7 @@ function SidebarNav({ onNavigate }: { onNavigate?: () => void }) {
projectId,
durableSessionsEnabled: user?.durableSessionsEnabled ?? false,
infrastructureEnabled: user?.infrastructureEnabled ?? false,
+ computerEnabled: user?.computerEnabled ?? false,
})
: LEGACY_NAV
const activeCollapsibleGroup = nav.find(
diff --git a/web/src/hooks/useAuth.ts b/web/src/hooks/useAuth.ts
index a7d542a4..d2324b99 100644
--- a/web/src/hooks/useAuth.ts
+++ b/web/src/hooks/useAuth.ts
@@ -10,6 +10,7 @@ export interface AuthUser {
orgs?: OrgInfo[]
durableSessionsEnabled: boolean
infrastructureEnabled: boolean
+ computerEnabled?: boolean
authMode?: string
capabilities?: {
signOut: boolean
diff --git a/web/src/managed-agents/Computer.test.tsx b/web/src/managed-agents/Computer.test.tsx
index 8cc168f3..c233942f 100644
--- a/web/src/managed-agents/Computer.test.tsx
+++ b/web/src/managed-agents/Computer.test.tsx
@@ -26,6 +26,22 @@ const projectsApi = vi.hoisted(() => ({
vi.mock('./api', () => projectsApi)
const { default: ComputerPage } = await import('./Computer')
+const { AuthContext } = await import('@/hooks/useAuth')
+const authWith = (computerEnabled: boolean) =>
+ ({
+ user: {
+ id: 'u1',
+ email: '[email protected]',
+ orgId: 'org_1',
+ durableSessionsEnabled: false,
+ infrastructureEnabled: false,
+ computerEnabled,
+ },
+ loading: false,
+ error: null,
+ switchOrg: async () => {},
+ refreshUser: async () => {},
+ }) as const
const { default: ProjectsHome } = await import('./Home')
const empty = {
@@ -138,15 +154,17 @@ describe('Computer page', () => {
function render(url: string) {
act(() => {
root.render(
- <QueryClientProvider client={client}>
- <MemoryRouter initialEntries={[url]}>
- <Routes>
- <Route index element={<ProjectsHome />} />
- <Route path="computer" element={<ComputerPage />} />
- </Routes>
- <Location />
- </MemoryRouter>
- </QueryClientProvider>,
+ <AuthContext.Provider value={authWith(true)}>
+ <QueryClientProvider client={client}>
+ <MemoryRouter initialEntries={[url]}>
+ <Routes>
+ <Route index element={<ProjectsHome />} />
+ <Route path="computer" element={<ComputerPage />} />
+ </Routes>
+ <Location />
+ </MemoryRouter>
+ </QueryClientProvider>
+ </AuthContext.Provider>,
)
})
}
diff --git a/web/src/managed-agents/Computer.tsx b/web/src/managed-agents/Computer.tsx
index db6f1fd8..c54fb852 100644
--- a/web/src/managed-agents/Computer.tsx
+++ b/web/src/managed-agents/Computer.tsx
@@ -1,6 +1,13 @@
-import { useEffect, useMemo, useRef, useState, type ReactNode } from 'react'
+import {
+ useContext,
+ useEffect,
+ useMemo,
+ useRef,
+ useState,
+ type ReactNode,
+} from 'react'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
-import { Link, useSearchParams } from 'react-router-dom'
+import { Link, Navigate, useSearchParams } from 'react-router-dom'
import {
Check,
Computer as ComputerIcon,
@@ -36,6 +43,7 @@ import { Button } from '@/components/ui/button'
import { Skeleton } from '@/components/ui/skeleton'
import { notifyError, notifySuccess } from '@/lib/errors'
import { cn } from '@/lib/utils'
+import { AuthContext } from '@/hooks/useAuth'
import { addManagedGitHubConnection } from './api'
import { launchAuthorizationWindow } from './authorization-window'
import {
@@ -69,6 +77,15 @@ import {
} from './computer-state'
export default function ComputerPage() {
+ // Behind the rollout flag (work 052): an organization without its computer
+ // goes to its projects. Rendered outside an AuthProvider (tests), no gate.
+ const auth = useContext(AuthContext)
+ if (auth?.user && !auth.user.computerEnabled)
+ return <Navigate to="/" replace />
+ return <ComputerPageContent />
+}
+
+function ComputerPageContent() {
const queryClient = useQueryClient()
const [searchParams, setSearchParams] = useSearchParams()
const status = useQuery({
diff --git a/web/src/managed-agents/Home.test.tsx b/web/src/managed-agents/Home.test.tsx
index 07b33790..5066ae62 100644
--- a/web/src/managed-agents/Home.test.tsx
+++ b/web/src/managed-agents/Home.test.tsx
@@ -5,17 +5,41 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
import ProjectsHome from './Home'
import { INSTALL_CLI_COMMAND } from './ProjectOnboarding'
-function renderProjects(projects: unknown[], archived: unknown[] = []) {
+import { AuthContext } from '@/hooks/useAuth'
+
+const authWith = (computerEnabled: boolean) =>
+ ({
+ user: {
+ id: 'u1',
+ email: '[email protected]',
+ orgId: 'org_1',
+ durableSessionsEnabled: false,
+ infrastructureEnabled: false,
+ computerEnabled,
+ },
+ loading: false,
+ error: null,
+ switchOrg: async () => {},
+ refreshUser: async () => {},
+ }) as const
+
+function renderProjects(
+ projects: unknown[],
+ archived: unknown[] = [],
+ computerEnabled = true,
+) {
const queryClient = new QueryClient()
queryClient.setQueryData(['managed-projects'], projects)
queryClient.setQueryData(['managed-projects', 'archived'], archived)
return renderToStaticMarkup(
- <QueryClientProvider client={queryClient}>
- <MemoryRouter>
- <ProjectsHome />
- </MemoryRouter>
- </QueryClientProvider>,
+ <AuthContext.Provider value={authWith(computerEnabled)}>
+ <QueryClientProvider client={queryClient}>
+ <MemoryRouter>
+ <ProjectsHome />
+ </MemoryRouter>
+ </QueryClientProvider>
+ </AuthContext.Provider>,
)
}
@@ -39,6 +63,13 @@ describe('projects home onboarding', () => {
expect(markup).not.toContain('Create project')
})
+ it('keeps CLI onboarding for an organization without the computer (rollout flag)', () => {
+ stubSessionStorage()
+ const markup = renderProjects([], [], false)
+
+ expect(markup).toContain(INSTALL_CLI_COMMAND)
+ })
+
it('shows CLI onboarding when Projects is opened after the first landing', () => {
stubSessionStorage({ 'oc.computerLanding': '1' })
const markup = renderProjects([])
diff --git a/web/src/managed-agents/Home.tsx b/web/src/managed-agents/Home.tsx
index 82427fbf..f47bd858 100644
--- a/web/src/managed-agents/Home.tsx
+++ b/web/src/managed-agents/Home.tsx
@@ -1,4 +1,4 @@
-import { useState } from 'react'
+import { useContext, useState } from 'react'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { Link, Navigate } from 'react-router-dom'
import {
@@ -21,6 +21,7 @@ import {
restoreManagedProject,
} from './api'
import ProjectOnboarding from './ProjectOnboarding'
+import { AuthContext } from '@/hooks/useAuth'
// Set once per browser session: the first landing goes to the computer, an
// explicit visit to Projects afterwards shows project onboarding.
@@ -37,6 +38,9 @@ function firstLandingThisSession(): boolean {
}
export default function ProjectsHome() {
+ // The computer is behind a rollout flag (work 052); no auth, no computer.
+ const computerEnabled =
+ useContext(AuthContext)?.user?.computerEnabled ?? false
const queryClient = useQueryClient()
const projects = useQuery({
queryKey: ['managed-projects'],
@@ -101,7 +105,7 @@ export default function ProjectsHome() {
// first landing of a session goes there. Clicking Projects afterwards shows
// the CLI-first project onboarding, as before.
if (items.length === 0 && archivedItems.length === 0) {
- return firstLandingThisSession() ? (
+ return computerEnabled && firstLandingThisSession() ? (
<Navigate to="/computer" replace />
) : (
<ProjectOnboarding />