An open-source, faster Devin alternative
TypeScript
web: land on the computer once per session, not on every Projects click
Slack U06GFN8DJ7Pd24081f117b4
diff --git a/web/src/managed-agents/Home.test.tsx b/web/src/managed-agents/Home.test.tsxindex cbb4aae1..07b33790 100644--- a/web/src/managed-agents/Home.test.tsx+++ b/web/src/managed-agents/Home.test.tsx@@ -1,7 +1,7 @@import { QueryClient, QueryClientProvider } from '@tanstack/react-query'import { renderToStaticMarkup } from 'react-dom/server'import { MemoryRouter } from 'react-router-dom'-import { describe, expect, it } from 'vitest'+import { afterEach, describe, expect, it, vi } from 'vitest'import ProjectsHome from './Home'import { INSTALL_CLI_COMMAND } from './ProjectOnboarding'@@ -19,16 +19,33 @@ function renderProjects(projects: unknown[], archived: unknown[] = []) {)}+function stubSessionStorage(initial: Record<string, string> = {}) {+ const store = new Map(Object.entries(initial))+ vi.stubGlobal('sessionStorage', {+ getItem: (key: string) => store.get(key) ?? null,+ setItem: (key: string, value: string) => void store.set(key, value),+ })+}++afterEach(() => vi.unstubAllGlobals())+describe('projects home onboarding', () => {- it('does not show CLI onboarding on the home screen without projects', () => {- // An organization without projects is sent to its computer (see- // Computer.test.tsx); CLI onboarding stays at /new.+ it('sends the first landing without projects to the computer, not CLI onboarding', () => {+ // An organization's first screen is its computer (work 052).+ stubSessionStorage()const markup = renderProjects([])expect(markup).not.toContain(INSTALL_CLI_COMMAND)expect(markup).not.toContain('Create project')})+ it('shows CLI onboarding when Projects is opened after the first landing', () => {+ stubSessionStorage({ 'oc.computerLanding': '1' })+ const markup = renderProjects([])++ expect(markup).toContain(INSTALL_CLI_COMMAND)+ })+it('sends New project to the same CLI onboarding route', () => {const now = new Date().toISOString()const markup = renderProjects([diff --git a/web/src/managed-agents/Home.tsx b/web/src/managed-agents/Home.tsxindex e6584b02..82427fbf 100644--- a/web/src/managed-agents/Home.tsx+++ b/web/src/managed-agents/Home.tsx@@ -20,6 +20,21 @@ import {getManagedProjects,restoreManagedProject,} from './api'+import ProjectOnboarding from './ProjectOnboarding'++// Set once per browser session: the first landing goes to the computer, an+// explicit visit to Projects afterwards shows project onboarding.+const COMPUTER_LANDING_KEY = 'oc.computerLanding'++function firstLandingThisSession(): boolean {+ try {+ if (sessionStorage.getItem(COMPUTER_LANDING_KEY)) return false+ sessionStorage.setItem(COMPUTER_LANDING_KEY, '1')+ return true+ } catch {+ return false+ }+}export default function ProjectsHome() {const queryClient = useQueryClient()@@ -82,10 +97,15 @@ export default function ProjectsHome() {)}- // An organization's first screen is its computer (017, work 052). Project- // creation stays CLI-first at /new, which the computer page links to.+ // An organization's first screen is its computer (017, work 052): the+ // 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 <Navigate to="/computer" replace />+ return firstLandingThisSession() ? (+ <Navigate to="/computer" replace />+ ) : (+ <ProjectOnboarding />+ )}return (