diff --git a/src/renderer/src/components/new-workspace/NewWorkspaceComposerProjectSection.tsx b/src/renderer/src/components/new-workspace/NewWorkspaceComposerProjectSection.tsx
index e95688e22ef..948b0a9839d 100644
--- a/src/renderer/src/components/new-workspace/NewWorkspaceComposerProjectSection.tsx
+++ b/src/renderer/src/components/new-workspace/NewWorkspaceComposerProjectSection.tsx
@@ -240,6 +240,7 @@ export function NewWorkspaceComposerProjectSection({
!projectError && needsRepo ? ORCA_CLOUD_NEEDS_REPO_ID : projectDescriptionId
}
focusSignal={needsRepo?.attempt ?? 0}
+ openSignal={cloudStart?.openRepoPickerSignal ?? 0}
/>
{projectError ? (
diff --git a/src/renderer/src/components/new-workspace/composer-modal-data.ts b/src/renderer/src/components/new-workspace/composer-modal-data.ts
index 188bfae6e71..830cd93cb68 100644
--- a/src/renderer/src/components/new-workspace/composer-modal-data.ts
+++ b/src/renderer/src/components/new-workspace/composer-modal-data.ts
@@ -27,6 +27,8 @@ export type ComposerModalData = {
initialEphemeralVmRecipeId?: string
/** Orca Cloud: a GitHub repository with no clone here, picked again (GH-CREATE-SHEET's Back to draft). */
initialCloudGitHubRepo?: string
+ /** Open the Project picker at its GitHub repositories (CLONE-ACCESS-ERROR's Choose another). */
+ openCloudRepoPicker?: boolean
initialProjectGroupId?: string
linkedWorkItem?: LinkedWorkItemSummary | null
initialGitHubWorkItem?: GitHubWorkItem | null
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 8e2e26635b0..f61a1ca8391 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
@@ -17,6 +17,8 @@ export type CloudStartView = {
* Project on each); absent until the first.
*/
needsGitHubRepo?: { hasRepos: boolean; attempt?: number } | null
+ /** Bumped to open the Project picker at its GitHub repositories (CLONE-ACCESS-ERROR's Choose another). */
+ openRepoPickerSignal?: number
}
/**
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 002eadb5864..f6bc3d7e557 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
@@ -41,6 +41,7 @@ export function useCloudStartComposer({
setRecipeId,
repoId,
initialGitHubRepo = null,
+ openRepoPicker = false,
prompt,
agent,
initialTargetFixed,
@@ -58,6 +59,8 @@ export function useCloudStartComposer({
repoId: string
/** A GitHub-only repository to start with picked (`owner/repo`). */
initialGitHubRepo?: string | null
+ /** Open the Project picker once, after the dialog opens ("Choose another repository"). */
+ openRepoPicker?: boolean
prompt: string
agent: string | null
/** The composer was opened on an explicit target (Landing card, a recovery). */
@@ -204,6 +207,8 @@ export function useCloudStartComposer({
// PC-5: no "Using sandbox hours" toast on start; hours live in billing (Neil: noise).
}, [cloudSelected, profileId, repoId])
+ // A signal above 0 when the dialog mounts opens the picker once (useOpenOnSignal).
+ const openRepoPickerSignal = openRepoPicker ? 1 : 0
const view = useMemo(
() =>
segment === 'hidden'
@@ -212,6 +217,7 @@ export function useCloudStartComposer({
onSelectOrcaCloud,
onUserPick: markTouched,
cloudOnly,
+ openRepoPickerSignal,
folderProject: cloudOnly.folderProject,
needsGitHubRepo: orcaCloudNeedsGitHubRepo({
cloudSelected,
@@ -221,7 +227,15 @@ export function useCloudStartComposer({
githubProjectCount
})
},
- [cloudOnly, cloudSelected, githubProjectCount, markTouched, onSelectOrcaCloud, segment]
+ [
+ cloudOnly,
+ cloudSelected,
+ githubProjectCount,
+ markTouched,
+ onSelectOrcaCloud,
+ openRepoPickerSignal,
+ segment
+ ]
)
if (!view || !cloudSelected) {
return { view, onPrimary: null, recordCreated }
diff --git a/src/renderer/src/components/new-workspace/run-on/use-composer-cloud-start.ts b/src/renderer/src/components/new-workspace/run-on/use-composer-cloud-start.ts
index cdef73ffa5d..721bc19b45a 100644
--- a/src/renderer/src/components/new-workspace/run-on/use-composer-cloud-start.ts
+++ b/src/renderer/src/components/new-workspace/run-on/use-composer-cloud-start.ts
@@ -60,6 +60,7 @@ export function useComposerCloudStart({
setRecipeId: cardProps.onEphemeralVmRecipeChange,
repoId: cardProps.repoId,
initialGitHubRepo: modalData.initialCloudGitHubRepo ?? null,
+ openRepoPicker: modalData.openCloudRepoPicker === true,
prompt: cardProps.name,
agent: quickAgent,
initialTargetFixed: Boolean(
diff --git a/src/renderer/src/components/ui/inline-error.tsx b/src/renderer/src/components/ui/inline-error.tsx
index d4c788f139e..984654d8b30 100644
--- a/src/renderer/src/components/ui/inline-error.tsx
+++ b/src/renderer/src/components/ui/inline-error.tsx
@@ -1,5 +1,6 @@
import React from 'react'
-import { CircleAlert, Info, RotateCw } from 'lucide-react'
+import { CircleAlert, Info, RotateCw, TriangleAlert } from 'lucide-react'
+import { BANNER_TONE } from './banner-tone'
import { cn } from '@/lib/class-names'
import { Button } from './button'
@@ -8,8 +9,9 @@ type InlineErrorProps = {
title: React.ReactNode
/** Optional detail or next step, shown muted under the title. */
detail?: React.ReactNode
- /** 'error' for failures; 'neutral' for soft states such as "status unavailable". */
- tone?: 'error' | 'neutral'
+ /** 'error' for failures; 'warning' for a precondition the person fixes (missing access);
+ * 'neutral' for soft states such as "status unavailable". */
+ tone?: 'error' | 'warning' | 'neutral'
/** Label for the retry action; the button only renders with onRetry. */
retryLabel?: React.ReactNode
onRetry?: () => void
@@ -49,8 +51,14 @@ function InlineError({
children,
className
}: InlineErrorProps): React.JSX.Element {
- const Icon = tone === 'error' ? CircleAlert : Info
+ const Icon = tone === 'error' ? CircleAlert : tone === 'warning' ? TriangleAlert : Info
const liveRole = tone === 'error' ? 'alert' : 'status'
+ const iconTone =
+ tone === 'error'
+ ? 'text-destructive'
+ : tone === 'warning'
+ ? BANNER_TONE.warning.icon
+ : 'text-muted-foreground'
// Why: announcing a whole card would read every button and list row along with the cause.
const announceTextOnly = React.Children.toArray(children).length > 0
if (layout === 'line') {
@@ -60,13 +68,7 @@ function InlineError({
data-slot="inline-error"
className={cn('flex items-start gap-1.5 text-xs text-muted-foreground', className)}
>
-
+
{title}
{detail ? {detail} : null}
@@ -92,16 +94,14 @@ function InlineError({
detail || announceTextOnly ? 'items-start' : 'items-center',
tone === 'error'
? 'border-destructive/15 bg-destructive/5 dark:border-destructive/25'
- : 'border-border bg-muted/40',
+ : tone === 'warning'
+ ? cn(BANNER_TONE.warning.surface, BANNER_TONE.warning.border)
+ : 'border-border bg-muted/40',
className
)}
>
diff --git a/src/renderer/src/components/worktree-creation/VmBuildFailureActions.tsx b/src/renderer/src/components/worktree-creation/VmBuildFailureActions.tsx
index 4187554cc97..5c9b7e92704 100644
--- a/src/renderer/src/components/worktree-creation/VmBuildFailureActions.tsx
+++ b/src/renderer/src/components/worktree-creation/VmBuildFailureActions.tsx
@@ -23,6 +23,7 @@ import {
} from '@/components/ui/dropdown-menu'
import type { Translate } from '@/i18n/use-translate'
import type { VmBuildFailure } from './vm-build-failure'
+import { cloneFailedActions, type CloneAccessHandlers } from './clone-access-actions'
export type VmBuildFailureActions = {
onFixWithAgent: () => void
@@ -41,6 +42,10 @@ export type VmBuildFailureActions = {
onContactSupport: () => void
onConnectGitHub: () => void
onPushToGitHub: () => void
+ /** CLONE-ACCESS-ERROR: back to the draft with the Project picker open. */
+ onChooseAnotherRepo?: () => void
+ /** CLONE-ACCESS-ERROR: what GitHub says about Orca's access to the refused repository. */
+ cloneAccess?: CloneAccessHandlers
}
type Action = {
@@ -272,10 +277,11 @@ function failureActions(
],
more: []
}
+ case 'cloneFailed':
+ return { primary: cloneFailedActions(failure.reason, actions, tryAgain, t), more: [] }
case 'unavailable':
case 'network':
case 'create':
- case 'cloneFailed':
return { primary: [tryAgain], more: [] }
}
}
diff --git a/src/renderer/src/components/worktree-creation/VmBuildFailureCard.tsx b/src/renderer/src/components/worktree-creation/VmBuildFailureCard.tsx
index 244680ee047..f8a67c0f2f6 100644
--- a/src/renderer/src/components/worktree-creation/VmBuildFailureCard.tsx
+++ b/src/renderer/src/components/worktree-creation/VmBuildFailureCard.tsx
@@ -10,6 +10,8 @@ import { FailureActionRow, type VmBuildFailureActions } from './VmBuildFailureAc
import { CheckRow } from './VmBuildCheckRow'
import { VmBuildErrorDetails } from './VmBuildErrorDetails'
import { BlockedSandboxHoursNote } from './BlockedSandboxHoursNote'
+import { cloneAccessCopy } from './clone-access-actions'
+import { githubRepoUrlFor, useCloneAccessHandoff } from './use-clone-access-handoff'
export type { VmBuildFailureActions }
@@ -57,19 +59,33 @@ export function VmBuildFailureCard({
setShown(failure)
}
const visible = failure ?? shown
- const copy = visible
- ? vmBuildFailureCopy(
- visible,
- {
- cloud,
- canManageBilling,
- repoName,
- sandboxLimit: sandboxLimitFromBilling(getLastBillingStatus()),
- sandboxKept: vmKept
- },
- t
- )
- : null
+ // CLONE-ACCESS-ERROR: GitHub refused the clone; name the cause and offer to fix access.
+ const accessFix =
+ cloud &&
+ visible?.kind === 'cloneFailed' &&
+ visible.reason === 'repo_unreachable' &&
+ Boolean(actions.onChooseAnotherRepo) &&
+ githubRepoUrlFor(repoName) !== null
+ const cloneAccess = useCloneAccessHandoff({
+ repoName,
+ enabled: accessFix && failure !== null,
+ onRetry: actions.onRetry
+ })
+ const copy = accessFix
+ ? cloneAccessCopy(cloneAccess.phase, repoName, t)
+ : visible
+ ? vmBuildFailureCopy(
+ visible,
+ {
+ cloud,
+ canManageBilling,
+ repoName,
+ sandboxLimit: sandboxLimitFromBilling(getLastBillingStatus()),
+ sandboxKept: vmKept
+ },
+ t
+ )
+ : null
const headingRef = React.useRef(null)
const cardRef = React.useRef(null)
// Move focus to the card when it opens, so keyboard and screen-reader users land on the way forward.
@@ -99,7 +115,14 @@ export function VmBuildFailureCard({
{/* InlineError announces only the cause; the check rows and actions are read on demand.
An account limit isn't a broken build, so it reads as a neutral notice. */}
@@ -125,7 +148,7 @@ export function VmBuildFailureCard({
canManageBilling={canManageBilling}
signingIn={signingIn}
connectingGitHub={connectingGitHub}
- actions={actions}
+ actions={accessFix ? { ...actions, cloneAccess } : actions}
t={t}
/>
{visible.kind === 'checks' ? (
diff --git a/src/renderer/src/components/worktree-creation/VmBuildSheet.tsx b/src/renderer/src/components/worktree-creation/VmBuildSheet.tsx
index 8ebc473c98e..5e65fa3501a 100644
--- a/src/renderer/src/components/worktree-creation/VmBuildSheet.tsx
+++ b/src/renderer/src/components/worktree-creation/VmBuildSheet.tsx
@@ -123,7 +123,7 @@ export function VmBuildSheet({
/** Leaves the build; when a VM is still up the caller confirms before it is deleted. */
onDismiss: () => void
/** Leaves a refused build for the composer with its prompt; `local` runs it on this computer. */
- onReturnToComposer: (options: { local: boolean }) => void
+ onReturnToComposer: (options: { local: boolean; pickRepo?: boolean }) => void
onEditRecipe: () => void
/** Fixtures only: a fixed sign-in row in place of the live one. */
agentSignInRow?: React.ReactNode
@@ -378,7 +378,8 @@ export function VmBuildSheet({
onShowWorkspaces: () => openCloudWorkspacePicker({ kind: 'running' }),
onContactSupport: () => openAppHttpLink(ORCA_SUPPORT_URL),
onConnectGitHub: connectGitHub,
- onPushToGitHub: () => openAppHttpLink(PUSH_TO_GITHUB_URL)
+ onPushToGitHub: () => openAppHttpLink(PUSH_TO_GITHUB_URL),
+ onChooseAnotherRepo: () => onReturnToComposer({ local: false, pickRepo: true })
}}
/>
diff --git a/src/renderer/src/components/worktree-creation/VmBuildSheetCloneAccess.fixture.tsx b/src/renderer/src/components/worktree-creation/VmBuildSheetCloneAccess.fixture.tsx
new file mode 100644
index 00000000000..c6b8071738d
--- /dev/null
+++ b/src/renderer/src/components/worktree-creation/VmBuildSheetCloneAccess.fixture.tsx
@@ -0,0 +1,67 @@
+import { defineFixture } from '../../component-fixtures/component-fixture'
+import {
+ CLOUD_LOG,
+ CLOUD_RECIPE,
+ entry,
+ frame,
+ seedFixtureRepo,
+ stubBillingRole,
+ T0
+} from './vm-build-sheet-fixture-support'
+
+// CLONE-ACCESS-ERROR: GitHub refused the clone of stablyai/orca-plugins. The card names the cause and
+// fixes access, by what GitHub says about Orca's access now.
+
+const REPO = 'https://github.com/stablyai/orca-plugins.git'
+
+function cloneRefused(access: 'missing' | 'requested' | 'granted', interact?: boolean) {
+ const fixture = frame(
+ entry(
+ {
+ status: 'error',
+ errorCode: 'cloudCloneFailed',
+ provisioningLog: `${CLOUD_LOG}\nOrca Cloud: repo_unreachable`,
+ errorAt: T0 + 2_000
+ },
+ CLOUD_RECIPE
+ ),
+ 'Couldn’t clone stablyai/orca-plugins.',
+ T0 + 2_000
+ )
+ return defineFixture({
+ ...fixture,
+ setup: () => {
+ seedFixtureRepo(REPO)
+ stubBillingRole(true)
+ window.api.orcaCloudWorkspace = {
+ ...window.api.orcaCloudWorkspace,
+ getRepoAccess: async () => ({
+ ok: true,
+ value: { access, owner: 'stablyai', repo: 'https://github.com/stablyai/orca-plugins' }
+ }),
+ connectGitHub: async () => ({ ok: true, value: null })
+ }
+ },
+ ...(interact
+ ? {
+ interact: async (frameElement: HTMLElement) => {
+ await new Promise((resolve) => setTimeout(resolve, 300))
+ const button = [...frameElement.querySelectorAll('button')].find(
+ (candidate) => candidate.textContent?.trim() === 'Give Orca access'
+ )
+ button?.click()
+ await new Promise((resolve) => setTimeout(resolve, 300))
+ }
+ }
+ : {})
+ })
+}
+
+/** The App doesn't reach the repository: Give Orca access, or choose another. */
+export const accessMissing = cloneRefused('missing')
+/** Back from GitHub's page, re-checking until access lands (then the create starts again). */
+export const accessWaiting = cloneRefused('missing', true)
+/** GitHub made the install a request for an owner: say who to ask, with a message to send. */
+export const accessRequested = cloneRefused('requested')
+/** Orca can reach it now: the clone failed for another reason. */
+export const accessReachable = cloneRefused('granted')
diff --git a/src/renderer/src/components/worktree-creation/WorktreeCreationPanel.tsx b/src/renderer/src/components/worktree-creation/WorktreeCreationPanel.tsx
index 056300b2d23..65be1d81322 100644
--- a/src/renderer/src/components/worktree-creation/WorktreeCreationPanel.tsx
+++ b/src/renderer/src/components/worktree-creation/WorktreeCreationPanel.tsx
@@ -100,8 +100,8 @@ export default function WorktreeCreationPanel({
onCancel={dismiss}
onRetry={() => retryBackgroundWorktreeCreation(creationId)}
onDismiss={leave}
- onReturnToComposer={({ local }) => {
- const data = composerDataFromRefusedCreate(entry, { local })
+ onReturnToComposer={({ local, pickRepo }) => {
+ const data = composerDataFromRefusedCreate(entry, { local, pickRepo })
dismiss()
const store = useAppStore.getState()
// Never replace a dialog the user opened meanwhile.
diff --git a/src/renderer/src/components/worktree-creation/clone-access-actions.test.tsx b/src/renderer/src/components/worktree-creation/clone-access-actions.test.tsx
new file mode 100644
index 00000000000..85e892c2f2a
--- /dev/null
+++ b/src/renderer/src/components/worktree-creation/clone-access-actions.test.tsx
@@ -0,0 +1,63 @@
+import { describe, expect, it, vi } from 'vitest'
+import { translate } from '@/i18n/i18n'
+import { cloneAccessActions, cloneAccessCopy } from './clone-access-actions'
+import type { CloneAccessPhase } from './use-clone-access-handoff'
+
+const REPO = 'stablyai/orca-plugins'
+
+function row(phase: CloneAccessPhase) {
+ const handlers = { onRetry: vi.fn(), onChooseAnotherRepo: vi.fn() }
+ const access = { phase, giveAccess: vi.fn(), copyRequest: vi.fn() }
+ return { actions: cloneAccessActions(access, handlers, translate), handlers, access }
+}
+
+describe('CLONE-ACCESS-ERROR card', () => {
+ it('names the cause and offers to fix access, with another repository as the way around', () => {
+ expect(cloneAccessCopy('missing', REPO, translate).title).toBe(
+ 'Orca can’t access stablyai/orca-plugins'
+ )
+ const { actions, access, handlers } = row('missing')
+ expect(actions.map((action) => action.label)).toEqual([
+ 'Give Orca access',
+ 'Choose another repository'
+ ])
+ // The App's install page is a plain button: no Copy link (AUTH-ONLY-COPY-LINK).
+ expect(actions[0]).not.toHaveProperty('link')
+ actions[0]?.onClick()
+ expect(access.giveAccess).toHaveBeenCalledOnce()
+ actions[1]?.onClick()
+ expect(handlers.onChooseAnotherRepo).toHaveBeenCalledOnce()
+ expect(actions[1]?.secondary).toBe(true)
+ })
+
+ it('while waiting, the fix reads as in progress', () => {
+ const [first] = row('waiting').actions
+ expect(first).toMatchObject({ label: 'Waiting for GitHub…', pending: true })
+ })
+
+ it('someone who can’t install is told who to ask, with a request to send', () => {
+ expect(cloneAccessCopy('requested', REPO, translate).body).toContain(
+ 'Ask an owner of stablyai to give Orca access'
+ )
+ const { actions, access } = row('requested')
+ expect(actions[0]?.label).toBe('Copy request for an owner')
+ actions[0]?.onClick()
+ expect(access.copyRequest).toHaveBeenCalledOnce()
+ const copied = cloneAccessActions(
+ { phase: 'requested', giveAccess: vi.fn(), copyRequest: vi.fn(), copied: true },
+ { onRetry: vi.fn(), onChooseAnotherRepo: vi.fn() },
+ translate
+ )
+ expect(copied[0]?.label).toBe('Copied')
+ })
+
+ it('reachable now: a plain Try again', () => {
+ expect(cloneAccessCopy('reachable', REPO, translate).title).toBe(
+ 'Couldn’t clone stablyai/orca-plugins'
+ )
+ const { actions, handlers } = row('reachable')
+ expect(actions[0]?.label).toBe('Try again')
+ actions[0]?.onClick()
+ expect(handlers.onRetry).toHaveBeenCalledOnce()
+ })
+})
diff --git a/src/renderer/src/components/worktree-creation/clone-access-actions.tsx b/src/renderer/src/components/worktree-creation/clone-access-actions.tsx
new file mode 100644
index 00000000000..86e82dc152b
--- /dev/null
+++ b/src/renderer/src/components/worktree-creation/clone-access-actions.tsx
@@ -0,0 +1,136 @@
+// CLONE-ACCESS-ERROR: the card's copy and actions for a clone GitHub refused, by what GitHub says
+// about Orca's access now (use-clone-access-handoff).
+import { Check, Copy, FolderSearch, Github, Loader2 } from 'lucide-react'
+import type { Translate } from '@/i18n/use-translate'
+import type { CloneAccessPhase } from './use-clone-access-handoff'
+import { repoOwner } from './vm-build-clone-failure-copy'
+
+export type CloneAccessHandlers = {
+ phase: CloneAccessPhase
+ giveAccess: () => void
+ copyRequest: () => void
+ copied?: boolean
+}
+
+export type CloneAccessAction = {
+ key: string
+ label: string
+ icon?: React.ReactNode
+ onClick: () => void
+ pending?: boolean
+ secondary?: boolean
+}
+
+export function cloneAccessCopy(
+ phase: CloneAccessPhase,
+ repoName: string,
+ t: Translate
+): { title: string; body: string } {
+ const repo = repoName
+ const owner = repoOwner(repoName)
+ if (phase === 'reachable') {
+ return {
+ title: t('worktreeCreation.cloneAccess.reachableTitle', 'Couldn’t clone {{repo}}', { repo }),
+ body: t(
+ 'worktreeCreation.cloneAccess.reachableBody',
+ 'GitHub refused the clone, but Orca can reach this repository now. Try again. The sandbox was deleted.'
+ )
+ }
+ }
+ const title = t('worktreeCreation.cloneAccess.title', 'Orca can’t access {{repo}}', { repo })
+ if (phase === 'requested') {
+ return {
+ title,
+ body: t(
+ 'worktreeCreation.cloneAccess.askOwnerBody',
+ 'Ask an owner of {{owner}} to give Orca access. Orca tries again once they do. The sandbox was deleted.',
+ { owner }
+ )
+ }
+ }
+ return {
+ title,
+ body: t(
+ 'worktreeCreation.cloneAccess.body',
+ 'The Orca GitHub App on {{owner}} doesn’t include this repository. Give Orca access, and Orca tries again. The sandbox was deleted.',
+ { owner }
+ )
+ }
+}
+
+export function cloneAccessActions(
+ access: CloneAccessHandlers,
+ handlers: { onRetry: () => void; onChooseAnotherRepo: () => void },
+ t: Translate
+): CloneAccessAction[] {
+ const chooseAnother: CloneAccessAction = {
+ key: 'chooseAnotherRepo',
+ label: t('worktreeCreation.cloneAccess.chooseAnother', 'Choose another repository'),
+ icon: ,
+ onClick: handlers.onChooseAnotherRepo,
+ secondary: true
+ }
+ switch (access.phase) {
+ case 'reachable':
+ return [
+ {
+ key: 'retry',
+ label: t('auto.components.worktree.creation.VmBuildFailureCard.tryAgain', 'Try again'),
+ onClick: handlers.onRetry
+ },
+ chooseAnother
+ ]
+ case 'requested':
+ return [
+ {
+ key: 'copyRequest',
+ label: access.copied
+ ? t('worktreeCreation.cloneAccess.copied', 'Copied')
+ : t('worktreeCreation.cloneAccess.copyRequest', 'Copy request for an owner'),
+ icon: access.copied ? : ,
+ onClick: access.copyRequest
+ },
+ chooseAnother
+ ]
+ case 'waiting':
+ return [
+ {
+ key: 'giveAccess',
+ label: t('worktreeCreation.cloneAccess.waiting', 'Waiting for GitHub…'),
+ icon: ,
+ onClick: access.giveAccess,
+ pending: true
+ },
+ chooseAnother
+ ]
+ case 'checking':
+ case 'missing':
+ return [
+ {
+ // The App's install page, not a sign-in: no Copy link (AUTH-ONLY-COPY-LINK).
+ key: 'giveAccess',
+ label: t('worktreeCreation.cloneAccess.giveAccess', 'Give Orca access'),
+ icon: ,
+ onClick: access.giveAccess
+ },
+ chooseAnother
+ ]
+ }
+}
+
+/** A failed clone's actions: access fixes when the clone was refused, else Try again. */
+export function cloneFailedActions(
+ reason: string,
+ actions: {
+ onRetry: () => void
+ onChooseAnotherRepo?: () => void
+ cloneAccess?: CloneAccessHandlers
+ },
+ tryAgain: A,
+ t: Translate
+): (A | CloneAccessAction)[] {
+ const { cloneAccess, onChooseAnotherRepo } = actions
+ return reason === 'repo_unreachable' && cloneAccess && onChooseAnotherRepo
+ ? cloneAccessActions(cloneAccess, { onRetry: actions.onRetry, onChooseAnotherRepo }, t)
+ : [tryAgain]
+}
diff --git a/src/renderer/src/components/worktree-creation/use-clone-access-handoff.test.tsx b/src/renderer/src/components/worktree-creation/use-clone-access-handoff.test.tsx
new file mode 100644
index 00000000000..694b114effc
--- /dev/null
+++ b/src/renderer/src/components/worktree-creation/use-clone-access-handoff.test.tsx
@@ -0,0 +1,139 @@
+// @vitest-environment happy-dom
+
+import { act, cleanup, renderHook, waitFor } from '@testing-library/react'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+
+const mocks = vi.hoisted(() => ({
+ access: vi.fn(),
+ install: vi.fn(),
+ clipboard: vi.fn()
+}))
+vi.mock('@/lib/orca-cloud/use-orca-cloud-repo-access', () => ({
+ fetchOrcaCloudRepoAccess: mocks.access
+}))
+vi.mock('@/lib/orca-cloud/cloud-setup-notice-actions', () => ({
+ openOrcaGitHubAppInstall: mocks.install
+}))
+vi.mock('sonner', () => ({ toast: { success: vi.fn(), error: vi.fn() } }))
+
+import {
+ CLONE_ACCESS_WAIT_MS,
+ copyOwnerRequest,
+ githubRepoUrlFor,
+ useCloneAccessHandoff
+} from './use-clone-access-handoff'
+
+const REPO = 'stablyai/orca-plugins'
+
+function answer(access: string) {
+ return { access, owner: 'stablyai', repo: `https://github.com/${REPO}` }
+}
+
+function setup() {
+ const onRetry = vi.fn()
+ const hook = renderHook(() => useCloneAccessHandoff({ repoName: REPO, enabled: true, onRetry }))
+ return { hook, onRetry }
+}
+
+describe('CLONE-ACCESS-ERROR: a clone GitHub refused', () => {
+ beforeEach(() => {
+ vi.spyOn(document, 'hasFocus').mockReturnValue(true)
+ Object.defineProperty(window, 'api', {
+ configurable: true,
+ value: { ui: { writeClipboardText: mocks.clipboard } }
+ })
+ })
+ afterEach(() => {
+ cleanup()
+ vi.useRealTimers()
+ vi.restoreAllMocks()
+ for (const mock of Object.values(mocks)) {
+ mock.mockReset()
+ }
+ })
+
+ it('asks GitHub first: missing access offers the fix; reachable means try again', async () => {
+ mocks.access.mockResolvedValueOnce(answer('missing'))
+ const missing = setup()
+ await waitFor(() => expect(missing.hook.result.current.phase).toBe('missing'))
+ expect(mocks.access).toHaveBeenCalledWith(`https://github.com/${REPO}`, { force: true })
+ missing.hook.unmount()
+ mocks.access.mockResolvedValueOnce(answer('granted'))
+ const reachable = setup()
+ await waitFor(() => expect(reachable.hook.result.current.phase).toBe('reachable'))
+ // Reachable at first look is news, not a handoff: nothing starts on its own.
+ expect(reachable.onRetry).not.toHaveBeenCalled()
+ })
+
+ it('Give Orca access opens the install page, waits, and starts again once access lands', async () => {
+ mocks.access.mockResolvedValueOnce(answer('missing'))
+ mocks.install.mockResolvedValue(true)
+ const { hook, onRetry } = setup()
+ await waitFor(() => expect(hook.result.current.phase).toBe('missing'))
+ act(() => hook.result.current.giveAccess())
+ await waitFor(() => expect(hook.result.current.phase).toBe('waiting'))
+ expect(mocks.install).toHaveBeenCalledWith(`https://github.com/${REPO}`)
+ // Back from GitHub before the webhook: still waiting.
+ mocks.access.mockResolvedValueOnce(answer('missing'))
+ act(() => {
+ window.dispatchEvent(new Event('focus'))
+ })
+ await waitFor(() => expect(mocks.access).toHaveBeenCalledTimes(2))
+ expect(hook.result.current.phase).toBe('waiting')
+ expect(onRetry).not.toHaveBeenCalled()
+ mocks.access.mockResolvedValueOnce(answer('granted'))
+ act(() => {
+ window.dispatchEvent(new Event('focus'))
+ })
+ await waitFor(() => expect(onRetry).toHaveBeenCalledOnce())
+ })
+
+ it('an install that became a request for an owner says who to ask, and an approval starts again', async () => {
+ mocks.access.mockResolvedValueOnce(answer('missing'))
+ mocks.install.mockResolvedValue(true)
+ const { hook, onRetry } = setup()
+ await waitFor(() => expect(hook.result.current.phase).toBe('missing'))
+ act(() => hook.result.current.giveAccess())
+ await waitFor(() => expect(hook.result.current.phase).toBe('waiting'))
+ mocks.access.mockResolvedValueOnce(answer('requested'))
+ act(() => {
+ window.dispatchEvent(new Event('focus'))
+ })
+ await waitFor(() => expect(hook.result.current.phase).toBe('requested'))
+ mocks.access.mockResolvedValueOnce(answer('granted'))
+ act(() => {
+ window.dispatchEvent(new Event('focus'))
+ })
+ await waitFor(() => expect(onRetry).toHaveBeenCalledOnce())
+ })
+
+ it('waiting gives up after a while, and the button comes back', async () => {
+ vi.useFakeTimers({ shouldAdvanceTime: true })
+ mocks.access.mockResolvedValue(answer('missing'))
+ mocks.install.mockResolvedValue(true)
+ const { hook } = setup()
+ await waitFor(() => expect(hook.result.current.phase).toBe('missing'))
+ act(() => hook.result.current.giveAccess())
+ await waitFor(() => expect(hook.result.current.phase).toBe('waiting'))
+ await act(async () => {
+ vi.advanceTimersByTime(CLONE_ACCESS_WAIT_MS)
+ })
+ await waitFor(() => expect(hook.result.current.phase).toBe('missing'))
+ })
+
+ it('the request for an owner carries the install link that preselects the repository', async () => {
+ mocks.access.mockResolvedValue({
+ ...answer('requested'),
+ installUrl: 'https://github.com/apps/orca/install'
+ })
+ await copyOwnerRequest(REPO, githubRepoUrlFor(REPO))
+ const [text] = mocks.clipboard.mock.calls[0] ?? []
+ expect(text).toContain(REPO)
+ expect(text).toContain('https://github.com/apps/orca/install')
+ })
+
+ it('names only owner/repo as a GitHub repository', () => {
+ expect(githubRepoUrlFor('stablyai/orca')).toBe('https://github.com/stablyai/orca')
+ expect(githubRepoUrlFor('My project')).toBeNull()
+ })
+})
diff --git a/src/renderer/src/components/worktree-creation/use-clone-access-handoff.ts b/src/renderer/src/components/worktree-creation/use-clone-access-handoff.ts
new file mode 100644
index 00000000000..fa58a208f1a
--- /dev/null
+++ b/src/renderer/src/components/worktree-creation/use-clone-access-handoff.ts
@@ -0,0 +1,185 @@
+// CLONE-ACCESS-ERROR: a cloud create whose clone GitHub refused. The card asks GitHub whether Orca
+// can reach the repository, sends the person to the Orca GitHub App's install page for its owner
+// (repository preselected), and once access shows up starts the create again on its own. Someone
+// who can't install (GitHub turns their install into a request for an owner) is told who to ask.
+import { useCallback, useEffect, useRef, useState } from 'react'
+import { toast } from 'sonner'
+import { translate } from '@/i18n/i18n'
+import { openOrcaGitHubAppInstall } from '@/lib/orca-cloud/cloud-setup-notice-actions'
+import { fetchOrcaCloudRepoAccess } from '@/lib/orca-cloud/use-orca-cloud-repo-access'
+
+/**
+ * `checking`: asking GitHub. `missing`: the App doesn't reach it (Give Orca access). `waiting`:
+ * back from GitHub's page, re-checking. `requested`: an owner must approve (Ask an owner).
+ * `reachable`: Orca can reach it, so the clone failed for another reason (Try again).
+ */
+export type CloneAccessPhase = 'checking' | 'missing' | 'waiting' | 'requested' | 'reachable'
+
+/** Re-check delays while focused after Give Orca access (as REPO-ACCESS-REFRESH backs off). */
+export const CLONE_ACCESS_POLL_DELAYS_MS = [4_000, 4_000, 8_000, 15_000, 30_000] as const
+/** How long "Copied" stays on the request button. */
+export const COPIED_MS = 1_500
+/** Stop waiting after this long: the button comes back. */
+export const CLONE_ACCESS_WAIT_MS = 3 * 60_000
+
+export function githubRepoUrlFor(repoName: string): string | null {
+ return /^[\w.-]+\/[\w.-]+$/.test(repoName) ? `https://github.com/${repoName}` : null
+}
+
+function phaseFor(access: string | undefined): CloneAccessPhase {
+ if (access === 'granted' || access === 'public') {
+ return 'reachable'
+ }
+ return access === 'requested' ? 'requested' : 'missing'
+}
+
+export function useCloneAccessHandoff({
+ repoName,
+ enabled,
+ onRetry
+}: {
+ /** owner/repo. */
+ repoName: string
+ /** Only for an Orca Cloud clone GitHub refused. */
+ enabled: boolean
+ /** Starts the create again (access arrived while waiting). */
+ onRetry: () => void
+}): {
+ phase: CloneAccessPhase
+ giveAccess: () => void
+ copyRequest: () => void
+ /** The request was just copied: the button reads Copied for a moment (like the W-number chip). */
+ copied: boolean
+} {
+ const repoUrl = githubRepoUrlFor(repoName)
+ const [phase, setPhase] = useState('checking')
+ const onRetryRef = useRef(onRetry)
+ useEffect(() => {
+ onRetryRef.current = onRetry
+ })
+
+ /** What GitHub says about Orca's access now, as a phase. */
+ const check = useCallback(async (): Promise => {
+ if (!repoUrl) {
+ return 'missing'
+ }
+ return phaseFor((await fetchOrcaCloudRepoAccess(repoUrl, { force: true }))?.access)
+ }, [repoUrl])
+
+ useEffect(() => {
+ if (!enabled) {
+ return
+ }
+ let cancelled = false
+ void check().then((next) => {
+ if (!cancelled) {
+ setPhase(next)
+ }
+ })
+ return () => {
+ cancelled = true
+ }
+ }, [check, enabled])
+
+ // After Give Orca access (or while an owner is asked): re-check on focus, and on a backing-off
+ // timer while focused; an owner's approval also lands here and the create starts again.
+ const watching = enabled && (phase === 'waiting' || phase === 'requested')
+ useEffect(() => {
+ if (!watching) {
+ return
+ }
+ let attempt = 0
+ let timer = 0
+ // An answer that lands after the wait ended (or moved on) changes nothing.
+ let cancelled = false
+ const recheck = (): void => {
+ if (cancelled || document.visibilityState !== 'visible' || !document.hasFocus()) {
+ return
+ }
+ void check().then((next) => {
+ if (cancelled) {
+ return
+ }
+ if (next === 'reachable') {
+ // One retry per handoff: the card closes as the create starts again.
+ cancelled = true
+ onRetryRef.current()
+ return
+ }
+ // Still nothing: keep waiting (or asking) rather than flip back to the button.
+ setPhase(next === 'missing' ? phase : next)
+ })
+ }
+
+ const schedule = (): void => {
+ const delays = CLONE_ACCESS_POLL_DELAYS_MS
+ timer = window.setTimeout(
+ () => {
+ recheck()
+ schedule()
+ },
+ delays[Math.min(attempt++, delays.length - 1)]
+ )
+ }
+ schedule()
+ window.addEventListener('focus', recheck)
+ const giveUp =
+ phase === 'waiting'
+ ? window.setTimeout(() => {
+ // Before the state change: a check still in flight must not undo it.
+ cancelled = true
+ setPhase('missing')
+ }, CLONE_ACCESS_WAIT_MS)
+ : undefined
+ return () => {
+ cancelled = true
+ window.clearTimeout(timer)
+ window.clearTimeout(giveUp)
+ window.removeEventListener('focus', recheck)
+ }
+ }, [check, phase, watching])
+
+ const giveAccess = useCallback(() => {
+ if (!repoUrl) {
+ return
+ }
+ void openOrcaGitHubAppInstall(repoUrl).then((opened) => {
+ if (opened) {
+ setPhase('waiting')
+ }
+ })
+ }, [repoUrl])
+
+ const [copied, setCopied] = useState(false)
+ const copiedTimer = useRef(undefined)
+ useEffect(() => () => window.clearTimeout(copiedTimer.current), [])
+ const copyRequest = useCallback(() => {
+ void copyOwnerRequest(repoName, repoUrl).then((ok) => {
+ if (ok) {
+ setCopied(true)
+ window.clearTimeout(copiedTimer.current)
+ copiedTimer.current = window.setTimeout(() => setCopied(false), COPIED_MS)
+ }
+ })
+ }, [repoName, repoUrl])
+
+ return { phase, giveAccess, copyRequest, copied }
+}
+
+/** A message for an owner of the repository's org, with the install link that preselects it. */
+export async function copyOwnerRequest(repoName: string, repoUrl: string | null): Promise {
+ // The repo-access answer carries GitHub's install page with this repository preselected.
+ const link = repoUrl ? ((await fetchOrcaCloudRepoAccess(repoUrl))?.installUrl ?? null) : null
+ const message = translate(
+ 'worktreeCreation.cloneAccess.requestMessage',
+ 'Could you give the Orca GitHub App access to {{repo}}? Orca Cloud needs it to start workspaces from this repository.',
+ { repo: repoName }
+ )
+ try {
+ await window.api.ui.writeClipboardText(link ? `${message}\n${link}` : message)
+ return true
+ } catch {
+ toast.error(translate('worktreeCreation.cloneAccess.requestCopyFailed', 'Couldn’t copy it.'))
+ return false
+ }
+}
diff --git a/src/renderer/src/components/worktree-creation/vm-build-composer-return.test.ts b/src/renderer/src/components/worktree-creation/vm-build-composer-return.test.ts
index d50217b88cf..9872851fb75 100644
--- a/src/renderer/src/components/worktree-creation/vm-build-composer-return.test.ts
+++ b/src/renderer/src/components/worktree-creation/vm-build-composer-return.test.ts
@@ -73,6 +73,17 @@ describe('Back to draft from a GitHub-only create (GH-CREATE-SHEET)', () => {
})
})
+ it('"Choose another repository" (CLONE-ACCESS-ERROR) opens the picker instead of the refused repository', () => {
+ const data = composerDataFromRefusedCreate(
+ { request: github },
+ { local: false, pickRepo: true }
+ )
+ expect(data.openCloudRepoPicker).toBe(true)
+ expect(data.initialCloudGitHubRepo).toBeUndefined()
+ expect(data.initialEphemeralVmRecipeId).toBe('cloud')
+ expect(data.prefilledName).toBe('Fix login')
+ })
+
it('"Create locally" keeps the composer’s own project, with no cloud repository', () => {
expect(composerDataFromRefusedCreate({ request: github }, { local: true })).toEqual({
initialRepoId: 'repo-1',
diff --git a/src/renderer/src/components/worktree-creation/vm-build-composer-return.ts b/src/renderer/src/components/worktree-creation/vm-build-composer-return.ts
index e5774256370..a7fd62ee1e5 100644
--- a/src/renderer/src/components/worktree-creation/vm-build-composer-return.ts
+++ b/src/renderer/src/components/worktree-creation/vm-build-composer-return.ts
@@ -15,7 +15,7 @@ export function typedComposerPrompt(entry: ReturnSource): string {
*/
export function composerDataFromRefusedCreate(
entry: ReturnSource,
- { local }: { local: boolean }
+ { local, pickRepo = false }: { local: boolean; pickRepo?: boolean }
): ComposerModalData {
const { request } = entry
const recipe = request.ephemeralVmRecipe
@@ -29,7 +29,10 @@ export function composerDataFromRefusedCreate(
? {}
: {
initialEphemeralVmRecipeId: recipe?.recipeId,
- initialCloudGitHubRepo: github.fullName
+ // "Choose another repository": the picker opens instead of the refused one coming back.
+ ...(pickRepo
+ ? { openCloudRepoPicker: true }
+ : { initialCloudGitHubRepo: github.fullName })
}),
prefilledName: entry.heldChatMessage ?? github.prompt,
recovery: { note: '', agent: request.agent },
@@ -39,6 +42,7 @@ export function composerDataFromRefusedCreate(
return {
initialRepoId: recipe?.sourceRepoId ?? request.repoId,
...(!local && recipe ? { initialEphemeralVmRecipeId: recipe.recipeId } : {}),
+ ...(pickRepo ? { openCloudRepoPicker: true } : {}),
// A generated name is regenerated; only a name the user typed comes back.
...(request.displayNameKind === 'user' && request.displayName
? { prefilledName: request.displayName }
diff --git a/src/renderer/src/components/worktree-creation/vm-build-steps.test.ts b/src/renderer/src/components/worktree-creation/vm-build-steps.test.ts
index 9b3ed412bc7..a212a1cd167 100644
--- a/src/renderer/src/components/worktree-creation/vm-build-steps.test.ts
+++ b/src/renderer/src/components/worktree-creation/vm-build-steps.test.ts
@@ -18,6 +18,22 @@ const base = {
}
describe('deriveVmBuildSteps', () => {
+ it('a clone GitHub refused marks the clone failed, not the sandbox start (CLONE-ACCESS-ERROR)', () => {
+ const steps = deriveVmBuildSteps(
+ {
+ ...base,
+ status: 'error',
+ errorCode: 'cloudCloneFailed',
+ errorAt: 3000,
+ provisioningLog: 'Orca Cloud: repo_unreachable'
+ },
+ 4000,
+ { cloud: true }
+ )
+ expect(steps.find((step) => step.id === 'provision')?.state).toBe('done')
+ expect(steps.find((step) => step.id === 'clone')?.state).toBe('failed')
+ })
+
it('keeps the sheet moving through fetch and checkout instead of stalling on checks', () => {
const steps = deriveVmBuildSteps(
{
diff --git a/src/renderer/src/components/worktree-creation/vm-build-steps.ts b/src/renderer/src/components/worktree-creation/vm-build-steps.ts
index 9bda9f62b80..cbaf2c939cd 100644
--- a/src/renderer/src/components/worktree-creation/vm-build-steps.ts
+++ b/src/renderer/src/components/worktree-creation/vm-build-steps.ts
@@ -43,6 +43,7 @@ type VmBuildEntry = Pick<
| 'checkoutProgress'
| 'worktreeId'
| 'errorAt'
+ | 'errorCode'
| 'provisioningLog'
| 'provisioningLogStamps'
>
@@ -129,7 +130,10 @@ export function deriveVmBuildSteps(
(cloud ? orcaCloudPlannedRepoMode(entry.provisioningLog ?? '') : null) ??
undefined
const afterClone = clone?.endedAt ?? check?.startedAt ?? createAt
- const provisionDone = Boolean(check) || workspacePhase || cloneAt !== undefined
+ // A clone that failed (CLONE-ACCESS-ERROR: GitHub refused it) means the sandbox started, even
+ // when no clone line made it into the log: the steps tell the same story as the card.
+ const cloneRefused = failed && cloud && entry.errorCode === 'cloudCloneFailed'
+ const provisionDone = Boolean(check) || workspacePhase || cloneAt !== undefined || cloneRefused
const provision = provisionDone
? step(
@@ -148,7 +152,12 @@ export function deriveVmBuildSteps(
? null
: cloneAt === undefined
? {
- ...step('clone', provisionDone ? 'done' : 'pending', null, undefined),
+ ...step(
+ 'clone',
+ cloneRefused ? 'failed' : provisionDone ? 'done' : 'pending',
+ null,
+ undefined
+ ),
...(cloneMode ? { cloneMode } : {})
}
: clone?.ended || check || workspacePhase
diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json
index 91ec55737cb..90db0b330bf 100644
--- a/src/renderer/src/i18n/locales/en.json
+++ b/src/renderer/src/i18n/locales/en.json
@@ -29519,6 +29519,20 @@
"raiseCapAndContinue": "Raise spend cap and continue",
"backToDraft": "Back to draft",
"saveFailed": "Couldn’t save that. Try again, or change it in Plan & billing."
+ },
+ "cloneAccess": {
+ "reachableTitle": "Couldn’t clone {{repo}}",
+ "reachableBody": "GitHub refused the clone, but Orca can reach this repository now. Try again. The sandbox was deleted.",
+ "title": "Orca can’t access {{repo}}",
+ "askOwnerBody": "Ask an owner of {{owner}} to give Orca access. Orca tries again once they do. The sandbox was deleted.",
+ "body": "The Orca GitHub App on {{owner}} doesn’t include this repository. Give Orca access, and Orca tries again. The sandbox was deleted.",
+ "chooseAnother": "Choose another repository",
+ "copyRequest": "Copy request for an owner",
+ "waiting": "Waiting for GitHub…",
+ "giveAccess": "Give Orca access",
+ "requestMessage": "Could you give the Orca GitHub App access to {{repo}}? Orca Cloud needs it to start workspaces from this repository.",
+ "requestCopyFailed": "Couldn’t copy it.",
+ "copied": "Copied"
}
},
"renderer": {