From 604bbf75fbb108c882d751b51a5de8a32f8cfa4b Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 10 Nov 2026 08:48:26 -0800 Subject: [PATCH] fix(cloud): signed-out and not-yet-entitled users can pick Orca Cloud and reach Set up and start --- .../useEphemeralVmRecipeOptions.test.tsx | 26 +++++++++++++++ .../src/hooks/useEphemeralVmRecipeOptions.ts | 33 ++++++++++++++++--- 2 files changed, 55 insertions(+), 4 deletions(-) diff --git a/src/renderer/src/hooks/useEphemeralVmRecipeOptions.test.tsx b/src/renderer/src/hooks/useEphemeralVmRecipeOptions.test.tsx index aa60e81d657..890250a7f90 100644 --- a/src/renderer/src/hooks/useEphemeralVmRecipeOptions.test.tsx +++ b/src/renderer/src/hooks/useEphemeralVmRecipeOptions.test.tsx @@ -167,6 +167,32 @@ describe('useEphemeralVmRecipeOptions', () => { expect(container.querySelector('[data-testid="error"]')?.textContent).toBe('none') }) + // A1: signed out (or no plan yet) the composer must still be able to pick Orca Cloud and reach + // "Set up and start"; main only lists the recipe once the account can use it. + it('offers Orca Cloud while the account still needs setup, and keeps an initial pick', async () => { + for (const orcaCloud of ['needs-sign-in', 'needs-capability'] as const) { + installApi(vi.fn().mockResolvedValue({ ...result([]), orcaCloud })) + const { container } = await render( + + ) + await vi.waitFor(() => + expect(container.querySelector('[data-testid="recipes"]')?.textContent).toBe('cloud') + ) + expect(container.querySelector('[data-testid="selected"]')?.textContent).toBe('cloud') + } + }) + + it('offers nothing extra when Orca Cloud is unavailable', async () => { + installApi(vi.fn().mockResolvedValue({ ...result([]), orcaCloud: 'unavailable' })) + const { container } = await render( + + ) + await vi.waitFor(() => + expect(container.querySelector('[data-testid="selected"]')?.textContent).toBe('none') + ) + expect(container.querySelector('[data-testid="recipes"]')?.textContent).toBe('') + }) + it('reloads when the account signs in, so Orca Cloud appears without switching projects', async () => { const listRecipes = vi .fn() diff --git a/src/renderer/src/hooks/useEphemeralVmRecipeOptions.ts b/src/renderer/src/hooks/useEphemeralVmRecipeOptions.ts index 6fae771716b..a11a1af0b14 100644 --- a/src/renderer/src/hooks/useEphemeralVmRecipeOptions.ts +++ b/src/renderer/src/hooks/useEphemeralVmRecipeOptions.ts @@ -26,6 +26,29 @@ function orcaCloudNeedsSetup(availability: OrcaCloudAvailability | undefined): b return availability === 'needs-sign-in' || availability === 'needs-capability' } +/** + * Main lists the Orca Cloud recipe only once the account can use it. Until then the composer still + * offers it, so a signed-out or not-yet-entitled user can pick Orca Cloud and reach "Set up and + * start" (spec A1/B1); the setup panel runs instead of a create, so this entry never starts a VM. + */ +const ORCA_CLOUD_SETUP_RECIPE: OrcaVmRecipe = { + id: ORCA_CLOUD_RECIPE_ID, + name: 'Orca Cloud', + description: 'Hosted by Orca. Sleeps when idle and keeps your files.', + provider: 'orca-cloud', + create: 'orca-cloud create' +} + +export function withOrcaCloudSetupRecipe( + recipes: OrcaVmRecipe[], + availability: OrcaCloudAvailability | undefined +): OrcaVmRecipe[] { + if (!orcaCloudNeedsSetup(availability) || recipes.some((r) => r.id === ORCA_CLOUD_RECIPE_ID)) { + return recipes + } + return [ORCA_CLOUD_SETUP_RECIPE, ...recipes] +} + export function useEphemeralVmRecipeOptions(args: EphemeralVmRecipeOptionsArgs): { recipes: OrcaVmRecipe[] selectedRecipeId: string | null @@ -71,8 +94,11 @@ export function useEphemeralVmRecipeOptions(args: EphemeralVmRecipeOptionsArgs): return } // Orca Cloud rides its account capability, not the experimental VM-recipes flag. - const nextRecipes = (result.recipes ?? []).filter( - (recipe) => args.customRecipesEnabled || recipe.provider === 'orca-cloud' + const nextRecipes = withOrcaCloudSetupRecipe( + (result.recipes ?? []).filter( + (recipe) => args.customRecipesEnabled || recipe.provider === 'orca-cloud' + ), + result.orcaCloud ) setRecipes(nextRecipes) setOrcaCloud(result.orcaCloud ?? 'unavailable') @@ -82,8 +108,7 @@ export function useEphemeralVmRecipeOptions(args: EphemeralVmRecipeOptionsArgs): // Orca Cloud stays picked while the account still needs setup: the composer's setup panel // says what's missing instead of the pick silently falling back to this computer. const keeps = (recipeId: string): boolean => - nextRecipes.some((recipe) => recipe.id === recipeId) || - (recipeId === ORCA_CLOUD_RECIPE_ID && orcaCloudNeedsSetup(result.orcaCloud)) + nextRecipes.some((recipe) => recipe.id === recipeId) setSelectedRecipeId((current) => { if (resetSelection) { return args.initialRecipeId && keeps(args.initialRecipeId)