An open-source, faster Devin alternative
TypeScript
fix: skip project queries when landing override redirects
Igor Zalutski via Computer218d7daa2e7a
diff --git a/web/src/managed-agents/Computer.test.tsx b/web/src/managed-agents/Computer.test.tsxindex 29753ab8..7585e2d5 100644--- a/web/src/managed-agents/Computer.test.tsx+++ b/web/src/managed-agents/Computer.test.tsx@@ -205,6 +205,7 @@ describe('Computer page', () => {'setup',)expect(computerApi.createComputer).not.toHaveBeenCalled()+ expect(projectsApi.getManagedProjects).not.toHaveBeenCalled()},)@@ -213,6 +214,7 @@ describe('Computer page', () => {computerApi.getComputer.mockResolvedValue(empty)render('/', 'computer')await settle(() => location() === '/computer', 'Computer override')+ expect(projectsApi.getManagedProjects).not.toHaveBeenCalled()})it('preserves explicit automation access with the Computer override', async () => {@@ -223,6 +225,10 @@ describe('Computer page', () => {'project list',)expect(location()).toBe('/automations')+ expect(projectsApi.getManagedProjects).toHaveBeenCalledWith()+ expect(projectsApi.getManagedProjects).toHaveBeenCalledWith({+ archived: true,+ })})it('can select Automations for an empty workspace without looping', async () => {diff --git a/web/src/managed-agents/Home.tsx b/web/src/managed-agents/Home.tsxindex 22eeb31e..3c0ec6c4 100644--- a/web/src/managed-agents/Home.tsx+++ b/web/src/managed-agents/Home.tsx@@ -35,17 +35,23 @@ export default function ProjectsHome({ list = false }: { list?: boolean }) {const user = useContext(AuthContext)?.userconst computerEnabled = user?.computerEnabled ?? falseconst onboardingExperience = user?.onboardingExperience+ const redirectToComputer =+ !list && onboardingExperience === 'computer' && computerEnabled+ const redirectToAutomations = !list && onboardingExperience === 'automations'+ const needsProjects = !redirectToComputer && !redirectToAutomationsconst 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// computer, so a stale cached [] must never decide that.const projects = useQuery({queryKey: ['managed-projects'],+ enabled: needsProjects,queryFn: () => getManagedProjects(),refetchOnMount: 'always',})const archivedProjects = useQuery({queryKey: ['managed-projects', 'archived'],+ enabled: needsProjects,queryFn: () => getManagedProjects({ archived: true }),refetchOnMount: 'always',})@@ -119,10 +125,10 @@ export default function ProjectsHome({ list = false }: { list?: boolean }) {// 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) {+ if (redirectToComputer) {return <Navigate to="/computer" replace />}- if (!list && onboardingExperience === 'automations') {+ if (redirectToAutomations) {return <Navigate to="/automations" replace />}