mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
fix(cloud): RR-c1 Orca Cloud on a plain folder keeps both selections and holds Create
design-squad (c): nothing switches on its own. One line under Project ('Orca Cloud needs a GitHub repository.') with 'Choose repository' (opens the Project picker at its GitHub repositories) or 'Add a GitHub repository' when there are none. Create is disabled with the same reason (title + aria-describedby), keyboard submit too, so the create can't fail with 'needs a GitHub repository'. Picking a GitHub repository clears it.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { ORCA_CLOUD_NEEDS_REPO_ID } from './run-on/cloud-start-view'
|
||||
import React from 'react'
|
||||
import { LoaderCircle } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
@@ -16,6 +17,7 @@ type NewWorkspaceComposerFooterProps = Pick<
|
||||
| 'createDisabled'
|
||||
| 'creating'
|
||||
| 'primaryActionLabel'
|
||||
| 'cloudStart'
|
||||
> & {
|
||||
submitShortcutModifierLabel: string
|
||||
}
|
||||
@@ -29,9 +31,16 @@ export function NewWorkspaceComposerFooter({
|
||||
createDisabled,
|
||||
creating,
|
||||
primaryActionLabel,
|
||||
submitShortcutModifierLabel
|
||||
submitShortcutModifierLabel,
|
||||
cloudStart = null
|
||||
}: NewWorkspaceComposerFooterProps): React.JSX.Element {
|
||||
const t = useTranslate()
|
||||
// RR-c1: why Create waits (a folder project on Orca Cloud), on hover and for screen readers.
|
||||
const needsRepo = Boolean(cloudStart?.needsGitHubRepo)
|
||||
const needsRepoReason = t(
|
||||
'components.newWorkspace.cloudOnly.needsRepository',
|
||||
'Orca Cloud needs a GitHub repository.'
|
||||
)
|
||||
return (
|
||||
<>
|
||||
{createError ? (
|
||||
@@ -68,19 +77,21 @@ export function NewWorkspaceComposerFooter({
|
||||
</span>
|
||||
</button>
|
||||
) : null}
|
||||
<Button
|
||||
onClick={() => void onCreate()}
|
||||
disabled={createDisabled}
|
||||
size="sm"
|
||||
className="ml-auto shrink-0"
|
||||
>
|
||||
{/* The footer's compact type, as before; the Button keeps its own variant styling. */}
|
||||
<span className="flex items-center gap-1.5 whitespace-nowrap text-xs">
|
||||
{creating ? <LoaderCircle className="size-4 animate-spin" /> : null}
|
||||
{primaryActionLabel}
|
||||
<ButtonKeyHint modifierLabel={submitShortcutModifierLabel} />
|
||||
</span>
|
||||
</Button>
|
||||
<span className="ml-auto shrink-0" title={needsRepo ? needsRepoReason : undefined}>
|
||||
<Button
|
||||
onClick={() => void onCreate()}
|
||||
disabled={createDisabled}
|
||||
size="sm"
|
||||
{...(needsRepo ? { 'aria-describedby': ORCA_CLOUD_NEEDS_REPO_ID } : {})}
|
||||
>
|
||||
{/* The footer's compact type, as before; the Button keeps its own variant styling. */}
|
||||
<span className="flex items-center gap-1.5 whitespace-nowrap text-xs">
|
||||
{creating ? <LoaderCircle className="size-4 animate-spin" /> : null}
|
||||
{primaryActionLabel}
|
||||
<ButtonKeyHint modifierLabel={submitShortcutModifierLabel} />
|
||||
</span>
|
||||
</Button>
|
||||
</span>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { OrcaCloudNeedsRepoLine } from './run-on/OrcaCloudNeedsRepoLine'
|
||||
import { OrcaCloudWallLine } from './run-on/OrcaCloudWallLine'
|
||||
import React from 'react'
|
||||
import { FolderPlus, LoaderCircle, PlugZap } from 'lucide-react'
|
||||
@@ -101,6 +102,8 @@ export function NewWorkspaceComposerProjectSection({
|
||||
? cloudStart?.cloudOnly
|
||||
: undefined
|
||||
const t = useTranslate()
|
||||
// RR-c1: "Choose repository" opens the Project picker at its GitHub repositories.
|
||||
const [repoPickerSignal, setRepoPickerSignal] = React.useState(0)
|
||||
return (
|
||||
<fieldset disabled={disabled} className="space-y-1">
|
||||
{/* One row, two equal columns: Project | Run on. Picking a target never changes the rows
|
||||
@@ -165,11 +168,18 @@ export function NewWorkspaceComposerProjectSection({
|
||||
triggerClassName="h-9 w-full border-input text-sm focus-visible:border-focus-ring focus-visible:ring-1 focus-visible:ring-focus-ring"
|
||||
invalid={Boolean(projectError)}
|
||||
describedBy={projectDescriptionId}
|
||||
openSignal={repoPickerSignal}
|
||||
/>
|
||||
{projectError ? (
|
||||
<p id={projectDescriptionId} className="text-[11px] text-destructive">
|
||||
{projectError}
|
||||
</p>
|
||||
) : cloudStart?.needsGitHubRepo ? (
|
||||
<OrcaCloudNeedsRepoLine
|
||||
hasRepos={cloudStart.needsGitHubRepo.hasRepos}
|
||||
onChooseRepository={() => setRepoPickerSignal((signal) => signal + 1)}
|
||||
onAddRepository={onAddProject}
|
||||
/>
|
||||
) : projectOptions.length === 0 ? (
|
||||
<p id={projectDescriptionId} className="text-[11px] text-muted-foreground">
|
||||
{emptyProjectMessage ??
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { defineFixture } from '../../../component-fixtures/component-fixture'
|
||||
import { OrcaCloudNeedsRepoLine } from './OrcaCloudNeedsRepoLine'
|
||||
|
||||
// Under Project (half the composer, ~230px): Orca Cloud on a plain folder.
|
||||
function Column({ children }: { children: React.ReactNode }): React.JSX.Element {
|
||||
return <div className="w-[230px] p-2">{children}</div>
|
||||
}
|
||||
|
||||
export const withGitHubRepositories = defineFixture({
|
||||
width: 260,
|
||||
render: () => (
|
||||
<Column>
|
||||
<OrcaCloudNeedsRepoLine hasRepos onChooseRepository={() => {}} onAddRepository={() => {}} />
|
||||
</Column>
|
||||
)
|
||||
})
|
||||
export const noGitHubRepositories = defineFixture({
|
||||
width: 260,
|
||||
render: () => (
|
||||
<Column>
|
||||
<OrcaCloudNeedsRepoLine
|
||||
hasRepos={false}
|
||||
onChooseRepository={() => {}}
|
||||
onAddRepository={() => {}}
|
||||
/>
|
||||
</Column>
|
||||
)
|
||||
})
|
||||
@@ -0,0 +1,49 @@
|
||||
import React from 'react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { useTranslate } from '@/i18n/use-translate'
|
||||
import { ORCA_CLOUD_NEEDS_REPO_ID } from './cloud-start-view'
|
||||
|
||||
/**
|
||||
* RR-c1 (design-squad): Orca Cloud is selected but the project is a plain folder. Nothing switches
|
||||
* on its own; this line says why Create waits and offers the one way forward: choose a GitHub
|
||||
* repository (the Project picker opens at them), or add one when there are none.
|
||||
*/
|
||||
export function OrcaCloudNeedsRepoLine({
|
||||
hasRepos,
|
||||
onChooseRepository,
|
||||
onAddRepository
|
||||
}: {
|
||||
hasRepos: boolean
|
||||
onChooseRepository: () => void
|
||||
onAddRepository: () => void
|
||||
}): React.JSX.Element {
|
||||
const t = useTranslate()
|
||||
return (
|
||||
<div
|
||||
id={ORCA_CLOUD_NEEDS_REPO_ID}
|
||||
role="status"
|
||||
className="flex flex-col items-start text-[11px]"
|
||||
data-orca-cloud-needs-repo
|
||||
>
|
||||
<p className="text-muted-foreground">
|
||||
{t(
|
||||
'components.newWorkspace.cloudOnly.needsRepository',
|
||||
'Orca Cloud needs a GitHub repository.'
|
||||
)}
|
||||
</p>
|
||||
{/* statusAction pads its label by px-1; -mx-1 keeps the text flush with the line above. */}
|
||||
<div className="-mx-1">
|
||||
<Button
|
||||
type="button"
|
||||
variant="link"
|
||||
size="statusAction"
|
||||
onClick={hasRepos ? onChooseRepository : onAddRepository}
|
||||
>
|
||||
{hasRepos
|
||||
? t('components.newWorkspace.cloudOnly.chooseRepository', 'Choose repository')
|
||||
: t('components.newWorkspace.cloudOnly.addRepository', 'Add a GitHub repository')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -13,8 +13,28 @@ export type CloudStartView = {
|
||||
folderProject?: boolean
|
||||
/** JA-21b (flagged): Orca Cloud is selected and a billing wall applies; Create waits for the fix. */
|
||||
wall?: OrcaCloudWallNotice | null
|
||||
/**
|
||||
* RR-c1: Orca Cloud is selected but the project is a plain folder. Both selections stay; one line
|
||||
* under Project says so and Create waits for a GitHub repository. `hasRepos`: any to choose from.
|
||||
*/
|
||||
needsGitHubRepo?: { hasRepos: boolean } | null
|
||||
}
|
||||
|
||||
/** RR-c1: Orca Cloud on a plain folder, with no GitHub repository picked yet: Create waits. */
|
||||
export function orcaCloudNeedsGitHubRepo(args: {
|
||||
cloudSelected: boolean
|
||||
folderProject: boolean
|
||||
pickedRepo: boolean
|
||||
repoCount: number
|
||||
}): { hasRepos: boolean } | null {
|
||||
return args.cloudSelected && args.folderProject && !args.pickedRepo
|
||||
? { hasRepos: args.repoCount > 0 }
|
||||
: null
|
||||
}
|
||||
|
||||
/** The line under Project that explains why Create waits; Create's aria-describedby points here. */
|
||||
export const ORCA_CLOUD_NEEDS_REPO_ID = 'orca-cloud-needs-github-repo'
|
||||
|
||||
export function prefersReducedMotion(): boolean {
|
||||
return (
|
||||
typeof window !== 'undefined' &&
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
// @vitest-environment happy-dom
|
||||
import { cleanup, render } from '@testing-library/react'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { NewWorkspaceComposerFooter } from '../NewWorkspaceComposerFooter'
|
||||
import {
|
||||
ORCA_CLOUD_NEEDS_REPO_ID,
|
||||
orcaCloudNeedsGitHubRepo,
|
||||
type CloudStartView
|
||||
} from './cloud-start-view'
|
||||
|
||||
afterEach(() => {
|
||||
cleanup()
|
||||
})
|
||||
|
||||
describe('Orca Cloud on a plain-folder project (RR-c1)', () => {
|
||||
it('waits for a GitHub repository only while Orca Cloud is on a folder with none picked', () => {
|
||||
const base = { cloudSelected: true, folderProject: true, pickedRepo: false, repoCount: 3 }
|
||||
expect(orcaCloudNeedsGitHubRepo(base)).toEqual({ hasRepos: true })
|
||||
expect(orcaCloudNeedsGitHubRepo({ ...base, repoCount: 0 })).toEqual({ hasRepos: false })
|
||||
// Picking a GitHub repository resolves it; a git project or This computer never needs it.
|
||||
expect(orcaCloudNeedsGitHubRepo({ ...base, pickedRepo: true })).toBeNull()
|
||||
expect(orcaCloudNeedsGitHubRepo({ ...base, folderProject: false })).toBeNull()
|
||||
expect(orcaCloudNeedsGitHubRepo({ ...base, cloudSelected: false })).toBeNull()
|
||||
})
|
||||
|
||||
it('Create is disabled and says why, so it never fails after a click', () => {
|
||||
const onCreate = vi.fn()
|
||||
const cloudStart: CloudStartView = {
|
||||
onSelectOrcaCloud: () => {},
|
||||
onUserPick: () => {},
|
||||
needsGitHubRepo: { hasRepos: true }
|
||||
}
|
||||
const { getByRole } = render(
|
||||
<NewWorkspaceComposerFooter
|
||||
onCreate={onCreate}
|
||||
createDisabled
|
||||
creating={false}
|
||||
primaryActionLabel="Create workspace"
|
||||
submitShortcutModifierLabel="⌘"
|
||||
cloudStart={cloudStart}
|
||||
/>
|
||||
)
|
||||
const button = getByRole('button', { name: /Create workspace/ })
|
||||
expect(button).toHaveProperty('disabled', true)
|
||||
expect(button.getAttribute('aria-describedby')).toBe(ORCA_CLOUD_NEEDS_REPO_ID)
|
||||
expect(button.parentElement?.getAttribute('title')).toBe(
|
||||
'Orca Cloud needs a GitHub repository.'
|
||||
)
|
||||
button.click()
|
||||
expect(onCreate).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
@@ -26,7 +26,7 @@ import { useSwitchTeamSteps } from '../cloud-setup/use-cloud-setup-tracker'
|
||||
import { cloudSetupRequired } from '../../orca-cloud-setup/cloud-setup-page-model'
|
||||
import { useRunOnDefault } from './use-run-on-default'
|
||||
import { useCloudOnlyCreate, useCloudOnlyRepo } from './use-cloud-only-repo'
|
||||
import type { CloudStartView } from './cloud-start-view'
|
||||
import { orcaCloudNeedsGitHubRepo, type CloudStartView } from './cloud-start-view'
|
||||
import { showCloudAgentNotStartedToast } from '@/lib/orca-cloud/cloud-agent-not-started-toast'
|
||||
import { orcaCloudWallNotice, useRunOnPreflightEnabled } from '@/lib/orca-cloud/run-on-preflight'
|
||||
import { isOrcaCloudAccountAgent } from '../../../../../shared/orca-cloud-agents/orca-cloud-agents-wire'
|
||||
@@ -222,9 +222,15 @@ export function useCloudStartComposer({
|
||||
onUserPick: markTouched,
|
||||
cloudOnly,
|
||||
folderProject: cloudOnly.folderProject,
|
||||
wall
|
||||
wall,
|
||||
needsGitHubRepo: orcaCloudNeedsGitHubRepo({
|
||||
cloudSelected,
|
||||
folderProject: cloudOnly.folderProject,
|
||||
pickedRepo: cloudOnly.picked !== null,
|
||||
repoCount: cloudOnly.repos?.length ?? 0
|
||||
})
|
||||
},
|
||||
[cloudOnly, markTouched, onSelectOrcaCloud, segment, wall]
|
||||
[cloudOnly, cloudSelected, markTouched, onSelectOrcaCloud, segment, wall]
|
||||
)
|
||||
if (!view || !cloudSelected) {
|
||||
return { view, onPrimary: null, recordCreated }
|
||||
|
||||
@@ -72,7 +72,9 @@ export function useComposerCloudStart({
|
||||
cloudStart,
|
||||
// Local and Orca Cloud share one button: same label, same rules for when it's enabled.
|
||||
// JA-21b: a billing wall on the selected Orca Cloud holds Create until it's fixed.
|
||||
primaryCreateDisabled: createDisabled || Boolean(cloudStart.view?.wall),
|
||||
// RR-c1: a folder project on Orca Cloud waits for a GitHub repository; Create never fails after.
|
||||
primaryCreateDisabled:
|
||||
createDisabled || Boolean(cloudStart.view?.wall) || Boolean(cloudStart.view?.needsGitHubRepo),
|
||||
onPrimary: cloudStart.onPrimary ?? runCreate
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23298,6 +23298,9 @@
|
||||
"askForPlan": "Ask for a Team plan"
|
||||
},
|
||||
"cloudOnly": {
|
||||
"needsRepository": "Orca Cloud needs a GitHub repository.",
|
||||
"chooseRepository": "Choose repository",
|
||||
"addRepository": "Add a GitHub repository",
|
||||
"heading": "On GitHub · Orca Cloud only",
|
||||
"detail": "Orca Cloud clones it. No copy on this computer needed.",
|
||||
"moreAccess": "Give Orca Cloud access to more repositories…",
|
||||
|
||||
Reference in New Issue
Block a user