diff --git a/src/renderer/src/components/new-workspace/ComposerBranchChoice.tsx b/src/renderer/src/components/new-workspace/ComposerBranchChoice.tsx index abe3afbadf7..5dc000cf63e 100644 --- a/src/renderer/src/components/new-workspace/ComposerBranchChoice.tsx +++ b/src/renderer/src/components/new-workspace/ComposerBranchChoice.tsx @@ -14,6 +14,8 @@ type Props = { onBranchNameOverrideChange: (value: string | undefined) => void onOpenSelectedBranchWorkspace?: () => void disabled: boolean + /** Orca Cloud is the run target: the unit of work is a workspace (JA-25 glossary). */ + cloud?: boolean } export function ComposerBranchChoice({ @@ -23,19 +25,21 @@ export function ComposerBranchChoice({ branchNameOverride, onBranchNameOverrideChange, onOpenSelectedBranchWorkspace, - disabled + disabled, + cloud = false }: Props) { const t = useTranslate() + const title = cloud + ? t('workspace.branchChoice.titleCloud', 'Branch for this workspace') + : t('workspace.branchChoice.title', 'Branch for this worktree') const id = useId() const branchNameInputRef = useRef(null) const showOpenWorkspace = reuseSelectedBranch && Boolean(onOpenSelectedBranchWorkspace) return (
- - {t('workspace.branchChoice.title', 'Branch for this worktree')} - + {title} onReuseSelectedBranchChange(value === 'existing')} disabled={disabled} @@ -115,7 +119,9 @@ export function ComposerBranchChoice({ {t('workspace.branchChoice.new', 'New branch')} - {t('workspace.branchChoice.newHint', 'Create a new local branch')} + {cloud + ? t('workspace.branchChoice.newHintCloud', 'Create a new branch.') + : t('workspace.branchChoice.newHint', 'Create a new local branch')} diff --git a/src/renderer/src/components/new-workspace/NewWorkspaceComposerNameSection.fixture.tsx b/src/renderer/src/components/new-workspace/NewWorkspaceComposerNameSection.fixture.tsx index 89440567c0d..06bd9ac5c0b 100644 --- a/src/renderer/src/components/new-workspace/NewWorkspaceComposerNameSection.fixture.tsx +++ b/src/renderer/src/components/new-workspace/NewWorkspaceComposerNameSection.fixture.tsx @@ -1,19 +1,31 @@ import { useState } from 'react' import { defineFixture } from '../../component-fixtures/component-fixture' import { NewWorkspaceComposerNameSection } from './NewWorkspaceComposerNameSection' +import type { EphemeralVmRecipeOption } from './run-target-options' + +const orcaCloudRecipe: EphemeralVmRecipeOption = { + id: 'cloud', + name: 'Orca Cloud', + description: 'Hosted by Orca. Sleeps when idle and keeps your files.', + provider: 'orca-cloud', + create: 'orca-cloud create' +} function BranchReusePreview({ busy = false, remote = true, initialReuse = true, initialBranchName, - existingBranch = 'feature/nested' + existingBranch = 'feature/nested', + cloud = false }: { busy?: boolean remote?: boolean initialReuse?: boolean initialBranchName?: string existingBranch?: string + /** Run on is Orca Cloud: the branch choice is titled for a workspace, not a worktree. */ + cloud?: boolean }) { const [reuse, setReuse] = useState(initialReuse) const [branchName, setBranchName] = useState(initialBranchName) @@ -52,6 +64,8 @@ function BranchReusePreview({ baseBranch={ remote ? `refs/remotes/origin/${existingBranch}` : `refs/heads/${existingBranch}` } + ephemeralVmRecipes={cloud ? [orcaCloudRecipe] : []} + selectedEphemeralVmRecipeId={cloud ? orcaCloudRecipe.id : null} onNamePlainEnter={() => {}} /> @@ -84,3 +98,7 @@ export const namedNewBranch = defineFixture({ /> ) }) +export const orcaCloudRemoteBranch = defineFixture({ + width: 480, + render: () => +}) diff --git a/src/renderer/src/components/new-workspace/NewWorkspaceComposerNameSection.test.tsx b/src/renderer/src/components/new-workspace/NewWorkspaceComposerNameSection.test.tsx index c410c3ca40a..fa1090f94bd 100644 --- a/src/renderer/src/components/new-workspace/NewWorkspaceComposerNameSection.test.tsx +++ b/src/renderer/src/components/new-workspace/NewWorkspaceComposerNameSection.test.tsx @@ -5,6 +5,7 @@ import { cleanup, render, screen, waitFor } from '@testing-library/react' import userEvent from '@testing-library/user-event' import { afterEach, describe, expect, it, vi } from 'vitest' import { NewWorkspaceComposerNameSection } from './NewWorkspaceComposerNameSection' +import type { EphemeralVmRecipeOption } from './run-target-options' vi.mock('@/components/new-workspace/SmartWorkspaceNameField', () => ({ default: ({ value, selectedSource }: { value: string; selectedSource?: { label: string } }) => ( @@ -101,4 +102,42 @@ describe('NewWorkspaceComposerNameSection branch reuse', () => { expect(props.onNameValueChange).not.toHaveBeenCalled() expect(props.onClearSmartNameSelection).not.toHaveBeenCalled() }) + + it('titles the branch choice for a workspace only when Run on is Orca Cloud (JA-25)', () => { + const props = branchProps() + const cloudRecipe: EphemeralVmRecipeOption = { + id: 'cloud', + name: 'Orca Cloud', + description: 'Hosted by Orca.', + provider: 'orca-cloud', + create: 'orca-cloud create' + } + const localRecipe: EphemeralVmRecipeOption = { id: 'vm', name: 'My VM', create: './vm up' } + const { rerender } = render() + expect(screen.getByRole('radiogroup', { name: 'Branch for this worktree' })).toBeTruthy() + + rerender( + + ) + expect(screen.getByRole('radiogroup', { name: 'Branch for this worktree' })).toBeTruthy() + expect(screen.getByText('Create a new local branch')).toBeTruthy() + + rerender( + + ) + expect(screen.getByRole('radiogroup', { name: 'Branch for this workspace' })).toBeTruthy() + expect(screen.getByText('Branch for this workspace')).toBeTruthy() + expect(screen.queryByText('Branch for this worktree')).toBeNull() + // The branch lives in the sandbox, not on this computer. + expect(screen.getByText('Create a new branch.')).toBeTruthy() + expect(screen.queryByText('Create a new local branch')).toBeNull() + }) }) diff --git a/src/renderer/src/components/new-workspace/NewWorkspaceComposerNameSection.tsx b/src/renderer/src/components/new-workspace/NewWorkspaceComposerNameSection.tsx index 782a044ae42..26ed7d0b432 100644 --- a/src/renderer/src/components/new-workspace/NewWorkspaceComposerNameSection.tsx +++ b/src/renderer/src/components/new-workspace/NewWorkspaceComposerNameSection.tsx @@ -6,6 +6,7 @@ import { useTranslate } from '@/i18n/use-translate' import { shouldShowComposerBaseRefPicker } from './base-ref-picker-visibility' import { ComposerBaseRefPicker } from './ComposerBaseRefPicker' import { ComposerBranchChoice } from './ComposerBranchChoice' +import { isOrcaCloudSelection } from './run-target-options' import type { NewWorkspaceComposerCardProps } from './new-workspace-composer-card-props' type NewWorkspaceComposerNameSectionProps = Pick< @@ -38,6 +39,8 @@ type NewWorkspaceComposerNameSectionProps = Pick< | 'smartNameMode' | 'forkPushWarning' | 'canReuseSelectedBranch' + | 'ephemeralVmRecipes' + | 'selectedEphemeralVmRecipeId' | 'reuseSelectedBranch' | 'reuseEligibleBranch' | 'branchNameOverride' @@ -87,6 +90,8 @@ export function NewWorkspaceComposerNameSection({ onBranchNameOverrideChange, onReuseSelectedBranchChange, onOpenSelectedBranchWorkspace, + ephemeralVmRecipes, + selectedEphemeralVmRecipeId, baseBranch, onBaseBranchChange, startFromResetHint @@ -177,6 +182,7 @@ export function NewWorkspaceComposerNameSection({ onBranchNameOverrideChange={onBranchNameOverrideChange} onOpenSelectedBranchWorkspace={onOpenSelectedBranchWorkspace} disabled={!canReuseSelectedBranch} + cloud={isOrcaCloudSelection({ ephemeralVmRecipes, selectedEphemeralVmRecipeId })} /> diff --git a/src/renderer/src/components/new-workspace/RunTargetOrcaCloudRow.tsx b/src/renderer/src/components/new-workspace/RunTargetOrcaCloudRow.tsx index 4ffa5269bcd..d56e53f9c08 100644 --- a/src/renderer/src/components/new-workspace/RunTargetOrcaCloudRow.tsx +++ b/src/renderer/src/components/new-workspace/RunTargetOrcaCloudRow.tsx @@ -53,8 +53,8 @@ function RowAction({ } /** - * "Sandbox · 8 vCPU · 16 GB". The specs never split: below a 28rem container (the menu, or - * the hint under the field) they drop out whole so "N sandbox hours left" keeps its room. + * "Sandbox · 8 vCPU · 16 GB" in the Run on menu row. The specs never split: below a 28rem + * container they drop out whole so "N sandbox hours left" keeps its room. */ export function OrcaCloudSpecs({ t }: { t: Translate }): React.JSX.Element { return ( diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index 13f61851f95..34d1f80ee96 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -24939,8 +24939,10 @@ "existingHint": "New commits go on this branch.", "new": "New branch", "newHint": "Create a new local branch", + "newHintCloud": "Create a new branch.", "newName": "New branch name", - "automaticName": "Automatic name" + "automaticName": "Automatic name", + "titleCloud": "Branch for this workspace" }, "links": { "foreignReview": "This review belongs to another repository. Add reviews from this workspace’s repository.",