From 1955af1e2c823bf9b100a95f83cceee4d42e01c2 Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 10 Nov 2026 09:02:13 -0800 Subject: [PATCH] feat(cloud): folders can pick Orca Cloud; the panel offers a GitHub repository instead (D3 for folders, design-squad) --- .../NewWorkspaceComposerProjectSection.tsx | 33 ++++- .../new-workspace/ProjectCombobox.tsx | 133 ++++++++---------- .../ProjectComboboxCloudSection.tsx | 44 +++++- .../run-on/CloudStart.fixture.tsx | 36 +++++ .../run-on/FolderGitHubActions.tsx | 30 ++++ .../run-on/OrcaCloudSetupPanel.tsx | 20 ++- .../run-on/cloud-start-preview-fixture.tsx | 7 +- .../new-workspace/run-on/cloud-start-view.ts | 2 + .../run-on/use-cloud-only-repo.ts | 60 +++++++- .../run-on/use-cloud-start-composer.ts | 31 ++-- .../src/hooks/useEphemeralVmRecipeOptions.ts | 26 ++-- src/renderer/src/i18n/locales/en.json | 8 +- 12 files changed, 314 insertions(+), 116 deletions(-) create mode 100644 src/renderer/src/components/new-workspace/run-on/FolderGitHubActions.tsx diff --git a/src/renderer/src/components/new-workspace/NewWorkspaceComposerProjectSection.tsx b/src/renderer/src/components/new-workspace/NewWorkspaceComposerProjectSection.tsx index 63cb1e6042e..e9d9f5fa7dc 100644 --- a/src/renderer/src/components/new-workspace/NewWorkspaceComposerProjectSection.tsx +++ b/src/renderer/src/components/new-workspace/NewWorkspaceComposerProjectSection.tsx @@ -1,4 +1,4 @@ -import React from 'react' +import React, { useState } from 'react' import { FolderPlus, LoaderCircle, PlugZap } from 'lucide-react' import { Button } from '@/components/ui/button' import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip' @@ -22,6 +22,7 @@ import { OrcaCloudSetupPanel } from './run-on/OrcaCloudSetupPanel' import { isOrcaCloudRecipe, isOrcaCloudSelection } from './run-target-options' import { useOrcaCloudRunTargetAccess } from './orca-cloud-billing-cache' import type { OrcaCloudRunTargetAccess } from './orca-cloud-run-target-access' +import { FolderGitHubActions } from './run-on/FolderGitHubActions' type NewWorkspaceComposerProjectSectionProps = Pick< NewWorkspaceComposerCardProps, @@ -103,8 +104,12 @@ export function NewWorkspaceComposerProjectSection({ quickAgent = null, cloudStart = null }: NewWorkspaceComposerProjectSectionProps): React.JSX.Element { + // D4 rows: while Orca Cloud is picked, and for a folder, which can only start from GitHub. const cloudOnly = - selectedEphemeralVmRecipeId === ORCA_CLOUD_RECIPE_ID ? cloudStart?.cloudOnly : undefined + selectedEphemeralVmRecipeId === ORCA_CLOUD_RECIPE_ID || cloudStart?.folderProject + ? cloudStart?.cloudOnly + : undefined + const [pickerSignal, setPickerSignal] = useState(0) const t = useTranslate() const orcaCloudOffered = shouldShowRunTargetPicker && ephemeralVmRecipes.some(isOrcaCloudRecipe) // Shared with the picker; mounting the composer prefetches it so the row rarely shows a skeleton. @@ -159,7 +164,11 @@ export function NewWorkspaceComposerProjectSection({ // D4: while Orca Cloud is picked, GitHub repositories with no clone here. cloudRepos={cloudOnly?.repos ?? null} cloudRepoValue={cloudOnly?.picked?.fullName ?? null} - onCloudRepoSelected={cloudOnly?.pick} + onCloudRepoSelected={(fullName) => { + cloudOnly?.pick(fullName) + cloudStart?.onSelectOrcaCloud() + }} + openSignal={pickerSignal} onMoreCloudAccess={cloudOnly?.moreAccess} onShowMoreCloudRepos={cloudOnly?.showMore ?? null} placeholder={ @@ -249,7 +258,23 @@ export function NewWorkspaceComposerProjectSection({ {cloudStart?.panelVisible && selectedEphemeralVmRecipeId === ORCA_CLOUD_RECIPE_ID ? ( // The panel's own Agent row (G) comes from the same model as the standalone one below. - + setPickerSignal((n) => n + 1)} + onAddProject={onAddProject} + /> + ) + } + : undefined + } + /> ) : // Agent row (cloud-start G) without the panel: links to the one-time setup; never blocks Start. selectedEphemeralVmRecipeId === ORCA_CLOUD_RECIPE_ID ? ( void /** Present while GitHub has more repositories than are listed. */ onShowMoreCloudRepos?: (() => void) | null + /** Bumped to open the list at its cloud-only section ("Choose a GitHub repository"). */ + openSignal?: number } const ADD_PROJECT_KEY = 'add-project' @@ -63,7 +66,8 @@ export default function ProjectCombobox({ cloudRepoValue = null, onCloudRepoSelected, onMoreCloudAccess, - onShowMoreCloudRepos = null + onShowMoreCloudRepos = null, + openSignal = 0 }: ProjectComboboxProps): React.JSX.Element { const t = useTranslate() const [tooltipOpen, setTooltipOpen] = useState(false) @@ -113,6 +117,14 @@ export default function ProjectCombobox({ () => sectionProjectOptions(matches, query, recentIds), [matches, query, recentIds] ) + // "Choose a GitHub repository": open with the first cloud-only row armed (scrolled into view). + useOpenOnSignal(openSignal, () => { + inputRef.current?.focus() + setOpen(true) + if (cloudRepos?.[0]) { + arm(cloudRepoKey(cloudRepos[0].fullName)) + } + }) const ambiguous = useMemo(() => getAmbiguousProjectOptionIds(options), [options]) const cloudMatches = useMemo( () => (cloudRepos ? filterCloudRepos(cloudRepos, query) : []), @@ -123,76 +135,53 @@ export default function ProjectCombobox({ const committed = (selected !== null || cloudRepoValue !== null) && query.length === 0 const committedName = cloudRepoValue ?? selected?.displayName ?? '' - const commit = useCallback( - (key: string | null): void => { - if (key === null) { - return - } - if (key === CLOUD_REPO_SHOW_MORE_KEY) { - // Keep the list open: the next page appends in place. - onShowMoreCloudRepos?.() - return - } - close() - if (key === ADD_PROJECT_KEY) { - onAddProject?.() - return - } - if (key === CLOUD_REPO_MORE_KEY) { - onMoreCloudAccess?.() - return - } - // Only a listed cloud-only row; a project id never reaches this branch. - if ( - key.startsWith(CLOUD_REPO_KEY_PREFIX) && - cloudRepos?.some((repo) => cloudRepoKey(repo.fullName) === key) - ) { - onCloudRepoSelected?.(key.slice(CLOUD_REPO_KEY_PREFIX.length)) - return - } - onValueChange(key) - onValueSelected?.(key) - }, - [ - close, - onAddProject, - cloudRepos, - onCloudRepoSelected, - onMoreCloudAccess, - onShowMoreCloudRepos, - onValueChange, - onValueSelected - ] - ) + const cloudRows = { cloudRepos, onShowMoreCloudRepos, onMoreCloudAccess, onCloudRepoSelected } + const commit = (key: string | null): void => { + if (key === null) { + return + } + // Show more keeps the list open: the next page appends in place. + const cloudRow = commitCloudRow(key, cloudRows) + if (cloudRow === 'kept-open') { + return + } + close() + if (cloudRow === 'handled') { + return + } + if (key === ADD_PROJECT_KEY) { + onAddProject?.() + return + } + onValueChange(key) + onValueSelected?.(key) + } - const handleKeyDown = useCallback( - (event: React.KeyboardEvent): void => { - if (event.key === 'ArrowDown' || event.key === 'ArrowUp') { - event.preventDefault() - setOpen(true) - moveArm(event.key === 'ArrowDown' ? 1 : -1) - return - } - if (event.key === 'Enter' && open) { - event.preventDefault() - commit(armedKey) - return - } - // Handle Escape even while closed to clear stranded queries; bubble only when there is no committed display to restore. - if (event.key === 'Escape' && (open || query.length > 0)) { - event.preventDefault() - event.stopPropagation() - close() - return - } - if (event.key === 'Backspace' && committed) { - event.preventDefault() - setQuery(committedName) - setOpen(true) - } - }, - [armedKey, close, commit, committed, committedName, moveArm, open, query, setOpen, setQuery] - ) + const handleKeyDown = (event: React.KeyboardEvent): void => { + if (event.key === 'ArrowDown' || event.key === 'ArrowUp') { + event.preventDefault() + setOpen(true) + moveArm(event.key === 'ArrowDown' ? 1 : -1) + return + } + if (event.key === 'Enter' && open) { + event.preventDefault() + commit(armedKey) + return + } + // Handle Escape even while closed to clear stranded queries; bubble only when there is no committed display to restore. + if (event.key === 'Escape' && (open || query.length > 0)) { + event.preventDefault() + event.stopPropagation() + close() + return + } + if (event.key === 'Backspace' && committed) { + event.preventDefault() + setQuery(committedName) + setOpen(true) + } + } return ( diff --git a/src/renderer/src/components/new-workspace/ProjectComboboxCloudSection.tsx b/src/renderer/src/components/new-workspace/ProjectComboboxCloudSection.tsx index c6d6d8aa949..23c59fad5dc 100644 --- a/src/renderer/src/components/new-workspace/ProjectComboboxCloudSection.tsx +++ b/src/renderer/src/components/new-workspace/ProjectComboboxCloudSection.tsx @@ -1,7 +1,7 @@ // The Project picker's "On GitHub · Orca Cloud only" section (cloud-start D4): repositories Orca // Cloud can reach with no clone on this computer, plus a way to give it access to more. Shown only // while Orca Cloud is the Run on target. -import React from 'react' +import React, { useEffect, useRef } from 'react' import { Check, ChevronDown, Github, Plus } from 'lucide-react' import { cn } from '@/lib/utils' import { useTranslate } from '@/i18n/use-translate' @@ -13,10 +13,52 @@ export const CLOUD_REPO_KEY_PREFIX = 'cloud-only-repo:' export const CLOUD_REPO_MORE_KEY = 'cloud-only-repo-more-access' export const CLOUD_REPO_SHOW_MORE_KEY = 'cloud-only-repo-show-more' +/** Runs `open` each time `signal` is bumped (never on mount), with the latest closure. */ +export function useOpenOnSignal(signal: number, open: () => void): void { + const openRef = useRef(open) + useEffect(() => { + openRef.current = open + }) + useEffect(() => { + if (signal > 0) { + openRef.current() + } + }, [signal]) +} + export function cloudRepoKey(fullName: string): string { return `${CLOUD_REPO_KEY_PREFIX}${fullName}` } +/** + * Commits a cloud-only row (D4). 'kept-open' for Show more, 'handled' for the access link or a + * listed repository, null for anything else (a project id, Add project). Project ids such as + * `github:/` never match: rows live in their own `cloud-only-repo:` namespace. + */ +export function commitCloudRow( + key: string, + rows: { + cloudRepos: readonly OrcaCloudGitHubRepository[] | null + onShowMoreCloudRepos?: (() => void) | null + onMoreCloudAccess?: () => void + onCloudRepoSelected?: (fullName: string) => void + } +): 'kept-open' | 'handled' | null { + if (key === CLOUD_REPO_SHOW_MORE_KEY) { + rows.onShowMoreCloudRepos?.() + return 'kept-open' + } + if (key === CLOUD_REPO_MORE_KEY) { + rows.onMoreCloudAccess?.() + return 'handled' + } + if (rows.cloudRepos?.some((repo) => cloudRepoKey(repo.fullName) === key)) { + rows.onCloudRepoSelected?.(key.slice(CLOUD_REPO_KEY_PREFIX.length)) + return 'handled' + } + return null +} + /** Case-insensitive substring match; the list is short and names are owner/repo. */ export function filterCloudRepos( repos: readonly OrcaCloudGitHubRepository[], diff --git a/src/renderer/src/components/new-workspace/run-on/CloudStart.fixture.tsx b/src/renderer/src/components/new-workspace/run-on/CloudStart.fixture.tsx index 6243f7b8b6e..ee6a0cd0554 100644 --- a/src/renderer/src/components/new-workspace/run-on/CloudStart.fixture.tsx +++ b/src/renderer/src/components/new-workspace/run-on/CloudStart.fixture.tsx @@ -254,6 +254,42 @@ export const d4GitHubProjectPicked = defineFixture({ /> ) }) +/** D3 for a folder: Orca Cloud stays selectable; the panel offers a GitHub repository instead. */ +export const d3FolderProject = defineFixture({ + width: 560, + setup, + render: () => ( + + ) +}) +/** D3 for a folder, after "Choose a GitHub repository": the picker opens at the D4 section. */ +export const d3FolderChooseRepository = defineFixture({ + ...d3FolderProject, + interact: async (frame) => { + const link = [...frame.querySelectorAll('button')].find((b) => + b.textContent?.includes('Choose a GitHub repository') + ) + link?.click() + await new Promise((resolve) => setTimeout(resolve, 300)) + } +}) /** E: returning, entitled; remembered Orca Cloud, no panel, "Start in Orca Cloud". */ export const eReturning = defineFixture({ width: 560, diff --git a/src/renderer/src/components/new-workspace/run-on/FolderGitHubActions.tsx b/src/renderer/src/components/new-workspace/run-on/FolderGitHubActions.tsx new file mode 100644 index 00000000000..9795f55b688 --- /dev/null +++ b/src/renderer/src/components/new-workspace/run-on/FolderGitHubActions.tsx @@ -0,0 +1,30 @@ +// The setup panel's way forward for a plain folder on Orca Cloud (design-squad: D3 for folders): +// choose a GitHub repository from the Project picker (D4), or add a GitHub project. +import React from 'react' +import { Button } from '@/components/ui/button' +import { useTranslate } from '@/i18n/use-translate' + +export function FolderGitHubActions({ + canChoose, + onChooseRepository, + onAddProject +}: { + /** Signed in with GitHub access: the Project picker lists repositories to choose from. */ + canChoose: boolean + onChooseRepository: () => void + onAddProject: () => void +}): React.JSX.Element { + const t = useTranslate() + return ( + + {canChoose ? ( + + ) : null} + + + ) +} diff --git a/src/renderer/src/components/new-workspace/run-on/OrcaCloudSetupPanel.tsx b/src/renderer/src/components/new-workspace/run-on/OrcaCloudSetupPanel.tsx index 852a524db46..7783aa28c67 100644 --- a/src/renderer/src/components/new-workspace/run-on/OrcaCloudSetupPanel.tsx +++ b/src/renderer/src/components/new-workspace/run-on/OrcaCloudSetupPanel.tsx @@ -220,15 +220,21 @@ export function OrcaCloudSetupPanel({ {allSet ? t('components.newWorkspace.cloudSetup.starting', 'Starting your cloud workspace…') : (subtitle ?? - (cloudSetupNeedsPlan(steps) + // No browser trip fixes a project without a GitHub repository (D3): say what holds. + (steps.some((step) => step.blocksStart && step.state === 'failed') ? t( - 'components.newWorkspace.cloudSetup.subtitleChoosePlan', - 'One visit to your browser to choose a plan. Your prompt stays here and starts when you’re done.' + 'components.newWorkspace.cloudSetup.subtitleNeedsRepository', + 'Orca Cloud needs a GitHub repository. Your prompt stays here.' ) - : t( - 'components.newWorkspace.cloudSetup.subtitleNoCard', - 'One visit to your browser, no card. Your prompt stays here and starts when you’re done.' - )))} + : cloudSetupNeedsPlan(steps) + ? t( + 'components.newWorkspace.cloudSetup.subtitleChoosePlan', + 'One visit to your browser to choose a plan. Your prompt stays here and starts when you’re done.' + ) + : t( + 'components.newWorkspace.cloudSetup.subtitleNoCard', + 'One visit to your browser, no card. Your prompt stays here and starts when you’re done.' + )))}

{/* One polite announcement per row change ("Team plan, done"). */}
    diff --git a/src/renderer/src/components/new-workspace/run-on/cloud-start-preview-fixture.tsx b/src/renderer/src/components/new-workspace/run-on/cloud-start-preview-fixture.tsx index 8855c76d7af..47c09c52729 100644 --- a/src/renderer/src/components/new-workspace/run-on/cloud-start-preview-fixture.tsx +++ b/src/renderer/src/components/new-workspace/run-on/cloud-start-preview-fixture.tsx @@ -68,7 +68,8 @@ export function ComposerPreview({ allSet = false, prompt = 'Fix the flaky login test in e2e/auth.spec.ts and open a PR.', cloudRepos, - pickedCloudRepo = null + pickedCloudRepo = null, + folderProject = false }: { availability: OrcaCloudAvailability access: OrcaCloudRunTargetAccess @@ -81,6 +82,8 @@ export function ComposerPreview({ /** D4: GitHub repositories with no clone here. */ cloudRepos?: OrcaCloudGitHubRepository[] pickedCloudRepo?: string | null + /** The project is a plain folder (D3 for folders). */ + folderProject?: boolean }): React.JSX.Element { const [picked, setPicked] = useState(pickedCloudRepo) const [host, setHost] = useState('local') @@ -100,6 +103,7 @@ export function ComposerPreview({ allSet, onSelectOrcaCloud: () => setRecipe('cloud'), onUserPick: () => {}, + folderProject, ...(cloudRepos ? { cloudOnly: { @@ -107,6 +111,7 @@ export function ComposerPreview({ showMore: () => {}, picked: cloudRepos.find((repo) => repo.fullName === picked) ?? null, githubStep: null, + folderProject, pick: setPicked, clear: () => setPicked(null), moreAccess: () => {}, diff --git a/src/renderer/src/components/new-workspace/run-on/cloud-start-view.ts b/src/renderer/src/components/new-workspace/run-on/cloud-start-view.ts index 321694cbc89..b2de8153a5b 100644 --- a/src/renderer/src/components/new-workspace/run-on/cloud-start-view.ts +++ b/src/renderer/src/components/new-workspace/run-on/cloud-start-view.ts @@ -13,6 +13,8 @@ export type CloudStartView = { onUseThisComputer?: () => void /** D4: GitHub repositories with no clone here, and the one picked. */ cloudOnly?: CloudOnlyRepo + /** The project is a plain folder: Orca Cloud needs a GitHub repository instead (D3/D4). */ + folderProject?: boolean } export function prefersReducedMotion(): boolean { diff --git a/src/renderer/src/components/new-workspace/run-on/use-cloud-only-repo.ts b/src/renderer/src/components/new-workspace/run-on/use-cloud-only-repo.ts index b59b7b3ac88..7326ddc2015 100644 --- a/src/renderer/src/components/new-workspace/run-on/use-cloud-only-repo.ts +++ b/src/renderer/src/components/new-workspace/run-on/use-cloud-only-repo.ts @@ -1,6 +1,7 @@ // D4 in the composer: while Orca Cloud is picked, the Project picker also offers GitHub // repositories with no clone here. Picking one keeps Orca Cloud and starts it from GitHub. import { useCallback, useMemo, useState } from 'react' +import { useAppStore } from '@/store' import { toast } from 'sonner' import { translate } from '@/i18n/i18n' import { clearCloudStartDraft } from '@/lib/orca-cloud/cloud-start-draft' @@ -17,6 +18,8 @@ export type CloudOnlyRepo = { /** Fetches GitHub's next pages; null when everything is listed. */ showMore: (() => void) | null picked: OrcaCloudGitHubRepository | null + /** The project is a plain folder: Orca Cloud needs a GitHub repository (D3/D4). */ + folderProject: boolean /** The GitHub row is done for a repository listed from the team's installations. */ githubStep: CloudSetupStep | null pick: (fullName: string) => void @@ -26,14 +29,22 @@ export type CloudOnlyRepo = { } export function useCloudOnlyRepo({ - enabled, + repoId, + cloudSelected, + cloudOffered, signedIn }: { + repoId: string /** Orca Cloud is the Run on target. */ - enabled: boolean + cloudSelected: boolean + /** This build offers Orca Cloud (the Run on segment is enabled). */ + cloudOffered: boolean /** The list needs an account; signed out, setup comes first. */ signedIn: boolean }): CloudOnlyRepo { + const { folderProject, folderStep } = useFolderGitHubStep(repoId) + // D4 rows show while Orca Cloud is picked, or for a folder, which can only start from GitHub. + const enabled = (cloudSelected || folderProject) && cloudOffered const { repos, showMore } = useOrcaCloudGitHubRepositories(enabled && signedIn) const [pickedName, setPickedName] = useState(null) const picked = useMemo( @@ -68,7 +79,17 @@ export function useCloudOnlyRepo({ : Promise.resolve(false), [picked] ) - return { repos, showMore, picked, githubStep, pick: setPickedName, clear, moreAccess, start } + return { + repos, + showMore, + picked, + githubStep: githubStep ?? folderStep, + folderProject, + pick: setPickedName, + clear, + moreAccess, + start + } } /** @@ -107,3 +128,36 @@ export function useCloudOnlyCreate({ onClose?.() }, [agent, createWorkspace, hoursToast, onClose, picked, profileId, prompt, start]) } + +/** + * A plain folder can't start in Orca Cloud (a sandbox clones from GitHub), but picking Orca Cloud + * still works: the panel's GitHub repository row says so and offers the way forward (D3 for + * folders), and the Project picker lists GitHub repositories with no clone here (D4). + */ +export function useFolderGitHubStep(repoId: string): { + folderProject: boolean + folderStep: CloudSetupStep | null +} { + const folderProject = useAppStore( + (s) => s.repos.find((repo) => repo.id === repoId)?.kind === 'folder' + ) + const folderStep = useMemo( + () => + folderProject + ? { + id: 'github', + state: 'failed', + need: 'github', + blocksStart: true, + label: translate('orcaCloud.setup.github.repositoryLabel', 'GitHub repository'), + status: translate('orcaCloud.setup.github.neededStatus', 'Needed'), + detail: translate( + 'components.newWorkspace.cloudOnly.folderDetail', + 'Orca Cloud starts from a GitHub repository. This project is a folder on this computer.' + ) + } + : null, + [folderProject] + ) + return { folderProject, folderStep } +} diff --git a/src/renderer/src/components/new-workspace/run-on/use-cloud-start-composer.ts b/src/renderer/src/components/new-workspace/run-on/use-cloud-start-composer.ts index e891177b82d..6148492613c 100644 --- a/src/renderer/src/components/new-workspace/run-on/use-cloud-start-composer.ts +++ b/src/renderer/src/components/new-workspace/run-on/use-cloud-start-composer.ts @@ -88,7 +88,9 @@ export function useCloudStartComposer({ const fetched = useOrcaCloudRunTargetAccess(segment === 'enabled' && !accessOverride) const access = accessOverride ?? fetched const cloudOnly = useCloudOnlyRepo({ - enabled: cloudSelected && segment === 'enabled', + repoId, + cloudSelected, + cloudOffered: segment === 'enabled', signedIn: availability !== 'needs-sign-in' && access.state !== 'signed-out' }) const onCreate = useCloudOnlyCreate({ @@ -278,15 +280,16 @@ export function useCloudStartComposer({ } }, [access, cloudSelected, profileId, repoId]) + // Orca Cloud isn't the target (or this build has none): the composer's own create runs. + const plainCreate = { + primaryActionLabel: null, + onPrimary: null, + primaryDisabled: false, + primaryIsCreate: true, + recordCreated + } if (segment === 'hidden') { - return { - view: null, - primaryActionLabel: null, - onPrimary: null, - primaryDisabled: false, - primaryIsCreate: true, - recordCreated - } + return { view: null, ...plainCreate } } const view: CloudStartView = { steps, @@ -295,19 +298,13 @@ export function useCloudStartComposer({ onSelectOrcaCloud, onUserPick: markTouched, cloudOnly, + folderProject: cloudOnly.folderProject, ...(panelVisible && localOption && action !== 'useThisComputer' && !cloudOnly.picked ? { onUseThisComputer: useThisComputer } : {}) } if (!cloudSelected) { - return { - view, - primaryActionLabel: null, - onPrimary: null, - primaryDisabled: false, - primaryIsCreate: true, - recordCreated - } + return { view, ...plainCreate } } const onPrimary = action === 'start' diff --git a/src/renderer/src/hooks/useEphemeralVmRecipeOptions.ts b/src/renderer/src/hooks/useEphemeralVmRecipeOptions.ts index a11a1af0b14..32d3c55efc8 100644 --- a/src/renderer/src/hooks/useEphemeralVmRecipeOptions.ts +++ b/src/renderer/src/hooks/useEphemeralVmRecipeOptions.ts @@ -34,16 +34,21 @@ function orcaCloudNeedsSetup(availability: OrcaCloudAvailability | undefined): b 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 + availability: OrcaCloudAvailability | undefined, + /** A plain folder: main lists no recipes for it, but Orca Cloud is still offered (D3). */ + folder = false ): OrcaVmRecipe[] { - if (!orcaCloudNeedsSetup(availability) || recipes.some((r) => r.id === ORCA_CLOUD_RECIPE_ID)) { + const offeredForFolder = folder && availability === 'offered' + if ( + !(orcaCloudNeedsSetup(availability) || offeredForFolder) || + recipes.some((r) => r.id === ORCA_CLOUD_RECIPE_ID) + ) { return recipes } return [ORCA_CLOUD_SETUP_RECIPE, ...recipes] @@ -65,10 +70,11 @@ export function useEphemeralVmRecipeOptions(args: EphemeralVmRecipeOptionsArgs): const [errors, setErrors] = useState([]) const [orcaCloud, setOrcaCloud] = useState('unavailable') const requestGeneration = useRef(0) + // A plain folder still loads: it offers Orca Cloud only, and the setup panel then says the + // project needs a GitHub repository (D3/D4) instead of the option vanishing. const canLoad = args.enabled && Boolean(args.repoId) && - args.repoIsGit && !args.repoConnectionId && args.repoExecutionHostId === LOCAL_EXECUTION_HOST_ID && !args.projectGroupTarget @@ -96,9 +102,11 @@ export function useEphemeralVmRecipeOptions(args: EphemeralVmRecipeOptionsArgs): // Orca Cloud rides its account capability, not the experimental VM-recipes flag. const nextRecipes = withOrcaCloudSetupRecipe( (result.recipes ?? []).filter( - (recipe) => args.customRecipesEnabled || recipe.provider === 'orca-cloud' + (recipe) => + recipe.provider === 'orca-cloud' || (args.customRecipesEnabled && args.repoIsGit) ), - result.orcaCloud + result.orcaCloud, + !args.repoIsGit ) setRecipes(nextRecipes) setOrcaCloud(result.orcaCloud ?? 'unavailable') @@ -125,7 +133,7 @@ export function useEphemeralVmRecipeOptions(args: EphemeralVmRecipeOptionsArgs): const fieldLabel = diagnostic.field ? `.${diagnostic.field}` : '' return { error: `${recipeLabel}${fieldLabel}: ${diagnostic.message}` } }) - if (!args.customRecipesEnabled) { + if (!args.customRecipesEnabled || !args.repoIsGit) { setErrors([]) return } @@ -155,7 +163,7 @@ export function useEphemeralVmRecipeOptions(args: EphemeralVmRecipeOptionsArgs): ) }) }, - [args.customRecipesEnabled, args.initialRecipeId, args.repoId, canLoad] + [args.customRecipesEnabled, args.initialRecipeId, args.repoId, args.repoIsGit, canLoad] ) useEffect(() => { @@ -200,7 +208,7 @@ export function useEphemeralVmRecipeOptions(args: EphemeralVmRecipeOptionsArgs): selectedRecipeId, setSelectedRecipeId, error, - offered: args.customRecipesEnabled || recipes.length > 0, + offered: (args.customRecipesEnabled && args.repoIsGit) || recipes.length > 0, orcaCloud: canLoad ? orcaCloud : 'unavailable' } } diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index bb2bf16b956..3a9c4297520 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -23123,7 +23123,8 @@ "trialUsedUpChoose": "Choose a plan to keep using Orca Cloud.", "trialOffer_one": "{{hours}} sandbox hour to try Orca Cloud", "trialOffer_other": "{{hours}} sandbox hours to try Orca Cloud", - "subtitleChoosePlan": "One visit to your browser to choose a plan. Your prompt stays here and starts when you’re done." + "subtitleChoosePlan": "One visit to your browser to choose a plan. Your prompt stays here and starts when you’re done.", + "subtitleNeedsRepository": "Orca Cloud needs a GitHub repository. Your prompt stays here." }, "runOn": { "thisComputer": "This computer", @@ -23164,7 +23165,10 @@ "openLater": "Your cloud workspace started, but this computer couldn’t open it yet. Open it from Cloud workspaces.", "private": "{{owner}} · Private", "public": "{{owner}} · Public", - "showMore": "Show more repositories…" + "showMore": "Show more repositories…", + "chooseRepository": "Choose a GitHub repository", + "addGitHubProject": "Add a GitHub project…", + "folderDetail": "Orca Cloud starts from a GitHub repository. This project is a folder on this computer." }, "orcaCloudAgentFallback": "{{agent}} isn’t available on Orca Cloud yet, so {{fallback}} is selected." },