mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
fix(cloud): signed-out and not-yet-entitled users can pick Orca Cloud and reach Set up and start
This commit is contained in:
@@ -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(
|
||||
<Harness repoId="repo-1" customRecipesEnabled={false} initialRecipeId="cloud" />
|
||||
)
|
||||
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(
|
||||
<Harness repoId="repo-1" customRecipesEnabled={false} initialRecipeId="cloud" />
|
||||
)
|
||||
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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user