An open-source, faster Devin alternative
TypeScript
feat: select workspace onboarding experience through D1
Igor Zalutski via Computerccc846d50dd7
diff --git a/.agents/reference/web-frontend.md b/.agents/reference/web-frontend.mdindex b90a92af..bbd40064 100644--- a/.agents/reference/web-frontend.md+++ b/.agents/reference/web-frontend.md@@ -29,6 +29,11 @@ afford it. Unused code may sit dead and removed features move to a clearlydormant module, but neither should masquerade as a live alternative. The code infront of you should describe what actually ships.+The narrow exception is administrator-selected onboarding experiences (Igor,+2026-10-27): existing customers can be directed into the current onboarding by+changing workspace data. This is presentation only, not a general feature-flag+system. See [workspace onboarding](workspace-onboarding.md) for the control.+## Preserve product contracts while rewriting internalsA dashboard rewrite can simplify the code without narrowing the product. Beforediff --git a/.agents/reference/workspace-onboarding.md b/.agents/reference/workspace-onboarding.mdnew file mode 100644index 00000000..f9cf8649--- /dev/null+++ b/.agents/reference/workspace-onboarding.md@@ -0,0 +1,44 @@+# Workspace onboarding selection++`orgs.onboarding_experience` in production D1 selects the workspace's dashboard+landing experience. `/api/dashboard/me` reads the current organization's value+on every request; the UI refreshes it on a full page reload. It is not stored in+the WorkOS user, session token, or browser storage.++- `NULL`: existing behavior (empty workspaces go to Computer when enabled,+ otherwise project onboarding; workspaces with active or archived automation+ projects see the project list).+- `computer`: `/` and `/getting-started` go to `/computer`, including workspaces+ with projects. Computer setup shows the remaining steps from its actual state.+- `automations`: `/` and `/getting-started` go to `/automations`, including empty+ workspaces.++Explicit `/automations`, `/computer`, project links, and `/new` retain their+behavior. The Computer availability gate still applies; the override grants no+permissions and does not create a VM, delete projects, or reset connections.+No customer-facing preference endpoint can update it. This is a narrow exception+to the general rule against feature flags, approved by Igor on 2026-10-27.++## Operator procedure++After migration `0015_orgs_onboarding_experience.sql` has shipped, first resolve+and verify the intended workspace (one user can belong to multiple):++```sql+SELECT o.id, o.name, o.onboarding_experience, u.email+FROM orgs o+JOIN org_memberships m ON m.org_id = o.id+JOIN users u ON u.id = m.user_id+WHERE lower(u.email) = lower(?);+```++Set the verified workspace's value with bound parameters:++```sql+UPDATE orgs SET onboarding_experience = 'computer' WHERE id = ?;+```++Verify with `SELECT id, name, onboarding_experience FROM orgs WHERE id = ?`.+Set the value back to `NULL` to restore default routing. Obtain any production+SQL approval required by `AGENTS.md` before executing a write. These examples+are an operator procedure, not a record that the statements were executed.diff --git a/cloudflare-workers/api-edge/migrations/0015_orgs_onboarding_experience.sql b/cloudflare-workers/api-edge/migrations/0015_orgs_onboarding_experience.sqlnew file mode 100644index 00000000..3ffeaf1f--- /dev/null+++ b/cloudflare-workers/api-edge/migrations/0015_orgs_onboarding_experience.sql@@ -0,0 +1,4 @@+-- Administrator-managed landing experience. NULL preserves the default routing.+-- This controls onboarding presentation, never permissions or resource lifecycle.+ALTER TABLE orgs ADD COLUMN onboarding_experience TEXT+ CHECK (onboarding_experience IN ('computer', 'automations'));diff --git a/cloudflare-workers/api-edge/src/dashboard.ts b/cloudflare-workers/api-edge/src/dashboard.tsindex bd7d6513..5b8040a3 100644--- a/cloudflare-workers/api-edge/src/dashboard.ts+++ b/cloudflare-workers/api-edge/src/dashboard.ts@@ -392,10 +392,10 @@ async function handleMe(req: Request, env: DashboardEnv, caller: Caller): Promisif (!user) return json({ error: "user not found" }, 404);const { results } = await env.OPENCOMPUTER_DB.prepare(- `SELECT o.id, o.name, o.is_personal FROM orgs o+ `SELECT o.id, o.name, o.is_personal, o.onboarding_experience FROM orgs oJOIN org_memberships m ON m.org_id = o.idWHERE m.user_id = ?1`,- ).bind(caller.userID).all<{ id: string; name: string; is_personal: number }>();+ ).bind(caller.userID).all<{ id: string; name: string; is_personal: number; onboarding_experience: string | null }>();const orgs = (results ?? []).map((r) => ({id: r.id, name: r.name, isPersonal: !!r.is_personal, isActive: r.id === caller.orgID,}));@@ -409,6 +409,7 @@ async function handleMe(req: Request, env: DashboardEnv, caller: Caller): PromisdurableSessionsEnabled: !!user.durable_sessions_enabled,infrastructureEnabled: !!user.infrastructure_enabled,computerEnabled: computerEnabledFor(env, caller.orgID),+ onboardingExperience: (results ?? []).find((org) => org.id === caller.orgID)?.onboarding_experience ?? null,});}diff --git a/cloudflare-workers/api-edge/src/dashboard_preferences.test.ts b/cloudflare-workers/api-edge/src/dashboard_preferences.test.tsindex b0909df3..ea860559 100644--- a/cloudflare-workers/api-edge/src/dashboard_preferences.test.ts+++ b/cloudflare-workers/api-edge/src/dashboard_preferences.test.ts@@ -52,6 +52,11 @@ function testEnv(durableSessionsEnabled = false) {infrastructureEnabled: true,};+ const orgs = [+ { id: orgID, name: "Personal", is_personal: 1, onboarding_experience: null as string | null },+ { id: "org-other", name: "Other", is_personal: 0, onboarding_experience: "automations" as string | null },+ ];+class Statement {private args: unknown[] = [];@@ -79,7 +84,7 @@ function testEnv(durableSessionsEnabled = false) {async all<T>() {if (this.sql.includes("JOIN org_memberships")) {return {- results: [{ id: orgID, name: "Personal", is_personal: 1 }] as T[],+ results: orgs as T[],};}return { results: [] as T[] };@@ -102,7 +107,7 @@ function testEnv(durableSessionsEnabled = false) {},} as unknown as DashboardEnv;- return { env, preferences };+ return { env, preferences, orgs };}async function request(body: unknown): Promise<Request> {@@ -139,6 +144,33 @@ describe("dashboard navigation preferences", () => {});});+ it("reads the current workspace onboarding choice afresh and isolates other workspaces", async () => {+ const { env, orgs } = testEnv();+ const read = async () => {+ const response = await handleDashboard(await meRequest(), env, {} as ExecutionContext, "/api/dashboard/me");+ expect(response.status).toBe(200);+ return response.json() as Promise<{ onboardingExperience: string | null }>;+ };+ expect((await read()).onboardingExperience).toBeNull();+ orgs[0].onboarding_experience = "computer";+ expect((await read()).onboardingExperience).toBe("computer");+ orgs[0].onboarding_experience = "automations";+ expect((await read()).onboardingExperience).toBe("automations");+ orgs[0].onboarding_experience = null;+ expect((await read()).onboardingExperience).toBeNull();+ });++ it("does not let customer preferences change onboarding", async () => {+ const { env, orgs } = testEnv();+ const response = await handleDashboard(+ await request({ infrastructureEnabled: false, onboardingExperience: "computer" }),+ env, {} as ExecutionContext, "/api/dashboard/me/preferences",+ );+ expect(response.status).toBe(200);+ expect(orgs[0].onboarding_experience).toBeNull();+ expect(await response.json()).toMatchObject({ onboardingExperience: null });+ });+it("updates one preference without changing the other", async () => {const { env, preferences } = testEnv();const response = await handleDashboard(diff --git a/web/src/api/schemas.ts b/web/src/api/schemas.tsindex 6e4c7f72..6302876f 100644--- a/web/src/api/schemas.ts+++ b/web/src/api/schemas.ts@@ -23,6 +23,11 @@ export const MeResponseSchema = z.object({infrastructureEnabled: z.boolean(),/** Work 052 rollout: the organization has its computer. Absent on older edges. */computerEnabled: z.boolean().optional(),+ /** Administrator-selected workspace landing experience; absent on older edges. */+ onboardingExperience: z+ .enum(['computer', 'automations'])+ .nullable()+ .optional(),authMode: z.string().optional(),capabilities: z.object({diff --git a/web/src/hooks/useAuth.ts b/web/src/hooks/useAuth.tsindex d2324b99..58dbe453 100644--- a/web/src/hooks/useAuth.ts+++ b/web/src/hooks/useAuth.ts@@ -1,5 +1,5 @@import { createContext, useContext } from 'react'-import type { OrgInfo } from '../api/client'+import type { MeResponse, OrgInfo } from '../api/client'export const ME_QUERY_KEY = ['me'] as const@@ -11,6 +11,7 @@ export interface AuthUser {durableSessionsEnabled: booleaninfrastructureEnabled: booleancomputerEnabled?: boolean+ onboardingExperience?: MeResponse['onboardingExperience']authMode?: stringcapabilities?: {signOut: booleandiff --git a/web/src/managed-agents/Computer.test.tsx b/web/src/managed-agents/Computer.test.tsxindex fb96e4df..29753ab8 100644--- a/web/src/managed-agents/Computer.test.tsx+++ b/web/src/managed-agents/Computer.test.tsx@@ -27,7 +27,11 @@ vi.mock('./api', () => projectsApi)const { default: ComputerPage } = await import('./Computer')const { AuthContext } = await import('@/hooks/useAuth')-const authWith = (computerEnabled: boolean) =>+import type { AuthUser } from '@/hooks/useAuth'+const authWith = (+ computerEnabled: boolean,+ onboardingExperience?: AuthUser['onboardingExperience'],+) =>({user: {id: 'u1',@@ -36,6 +40,7 @@ const authWith = (computerEnabled: boolean) =>durableSessionsEnabled: false,infrastructureEnabled: false,computerEnabled,+ onboardingExperience,},loading: false,error: null,@@ -151,14 +156,20 @@ describe('Computer page', () => {document.body.replaceChildren()})- function render(url: string) {+ function render(+ url: string,+ experience?: AuthUser['onboardingExperience'],+ computerEnabled = true,+ ) {act(() => {root.render(- <AuthContext.Provider value={authWith(true)}>+ <AuthContext.Provider value={authWith(computerEnabled, experience)}><QueryClientProvider client={client}><MemoryRouter initialEntries={[url]}><Routes><Route index element={<ProjectsHome />} />+ <Route path="getting-started" element={<ProjectsHome />} />+ <Route path="automations" element={<ProjectsHome list />} /><Route path="computer" element={<ComputerPage />} /></Routes><Location />@@ -172,6 +183,78 @@ describe('Computer page', () => {const location = () =>container.querySelector('[data-testid="location"]')?.textContent+ const existingProject = {+ id: 'project_1',+ slug: 'support',+ name: 'Support',+ environments: [],+ agents: [],+ createdAt: '2026-10-27T10:00:00Z',+ updatedAt: '2026-10-27T10:00:00Z',+ }++ it.each(['/', '/getting-started'])(+ 'sends existing workspaces into Computer setup from %s',+ async (url) => {+ projectsApi.getManagedProjects.mockResolvedValue([existingProject])+ computerApi.getComputer.mockResolvedValue(empty)+ render(url, 'computer')+ await settle(() => location() === '/computer', 'Computer override')+ await settle(+ () => container.textContent?.includes('Set up your computer') === true,+ 'setup',+ )+ expect(computerApi.createComputer).not.toHaveBeenCalled()+ },+ )++ it('can reach Computer setup even when the project service fails', async () => {+ projectsApi.getManagedProjects.mockRejectedValue(new Error('unavailable'))+ computerApi.getComputer.mockResolvedValue(empty)+ render('/', 'computer')+ await settle(() => location() === '/computer', 'Computer override')+ })++ it('preserves explicit automation access with the Computer override', async () => {+ projectsApi.getManagedProjects.mockResolvedValue([existingProject])+ render('/automations', 'computer')+ await settle(+ () => container.textContent?.includes('Support') === true,+ 'project list',+ )+ expect(location()).toBe('/automations')+ })++ it('can select Automations for an empty workspace without looping', async () => {+ projectsApi.getManagedProjects.mockResolvedValue([])+ render('/', 'automations')+ await settle(+ () => container.textContent?.includes('No automations yet') === true,+ 'empty list',+ )+ expect(location()).toBe('/automations')+ })++ it('preserves default routing for existing workspaces when the override is cleared', async () => {+ projectsApi.getManagedProjects.mockResolvedValue([existingProject])+ render('/', null)+ await settle(+ () => container.textContent?.includes('Support') === true,+ 'project list',+ )+ expect(location()).toBe('/')+ })++ it('does not bypass the Computer availability gate', async () => {+ projectsApi.getManagedProjects.mockResolvedValue([existingProject])+ render('/', 'computer', false)+ await settle(+ () => container.textContent?.includes('Support') === true,+ 'project list',+ )+ expect(location()).toBe('/')+ })+it('does not create the computer on a visit: installing Slack brings it to life', async () => {computerApi.getComputer.mockResolvedValue(empty)computerApi.createComputer.mockResolvedValue(provisioning)diff --git a/web/src/managed-agents/Home.tsx b/web/src/managed-agents/Home.tsxindex 24dd1a08..22eeb31e 100644--- a/web/src/managed-agents/Home.tsx+++ b/web/src/managed-agents/Home.tsx@@ -27,12 +27,14 @@ import { AuthContext } from '@/hooks/useAuth'/*** The automation project list. At `/` (`list` unset) an organization without- * projects goes to its computer; at `/automations` it sees the empty list.+ * projects goes to its computer, unless an administrator selected a landing+ * experience. At `/automations` it always sees the project list.*/export default function ProjectsHome({ list = false }: { list?: boolean }) {// The computer is behind a rollout flag (work 052); no auth, no computer.- const computerEnabled =- useContext(AuthContext)?.user?.computerEnabled ?? false+ const user = useContext(AuthContext)?.user+ const computerEnabled = user?.computerEnabled ?? false+ const onboardingExperience = user?.onboardingExperienceconst queryClient = useQueryClient()// Always read afresh: projects are created elsewhere too (the CLI, a// template deploy), and an empty list sends the organization away to its@@ -114,6 +116,16 @@ export default function ProjectsHome({ list = false }: { list?: boolean }) {onError: (error) => notifyError("Couldn't restore the project.", error),})+ // An administrator can send an existing workspace into onboarding without+ // deleting its projects. Explicit /automations visits always keep the list.+ // Decide before project loading/errors: an override does not depend on them.+ if (!list && onboardingExperience === 'computer' && computerEnabled) {+ return <Navigate to="/computer" replace />+ }+ if (!list && onboardingExperience === 'automations') {+ return <Navigate to="/automations" replace />+ }+if (projects.isLoading || archivedProjects.isLoading) {return (<div className="flex min-h-64 items-center justify-center">