mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
Merge pull request #464 from nwparker/lc2/ja25-branch-label
copy(cloud): composer branch choice says "Branch for this workspace" when Run on is Orca Cloud (JA-25 follow-up)
This commit is contained in:
@@ -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<HTMLInputElement>(null)
|
||||
const showOpenWorkspace = reuseSelectedBranch && Boolean(onOpenSelectedBranchWorkspace)
|
||||
return (
|
||||
<fieldset className="min-w-0 space-y-2" disabled={disabled}>
|
||||
<legend className="text-xs font-medium text-muted-foreground">
|
||||
{t('workspace.branchChoice.title', 'Branch for this worktree')}
|
||||
</legend>
|
||||
<legend className="text-xs font-medium text-muted-foreground">{title}</legend>
|
||||
<RadioGroup
|
||||
aria-label={t('workspace.branchChoice.title', 'Branch for this worktree')}
|
||||
aria-label={title}
|
||||
value={reuseSelectedBranch ? 'existing' : 'new'}
|
||||
onValueChange={(value) => onReuseSelectedBranchChange(value === 'existing')}
|
||||
disabled={disabled}
|
||||
@@ -115,7 +119,9 @@ export function ComposerBranchChoice({
|
||||
{t('workspace.branchChoice.new', 'New branch')}
|
||||
</span>
|
||||
<span id={`${id}-new-description`} className="block text-xs text-muted-foreground">
|
||||
{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')}
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
|
||||
+19
-1
@@ -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<string | undefined>(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={() => {}}
|
||||
/>
|
||||
</div>
|
||||
@@ -84,3 +98,7 @@ export const namedNewBranch = defineFixture({
|
||||
/>
|
||||
)
|
||||
})
|
||||
export const orcaCloudRemoteBranch = defineFixture({
|
||||
width: 480,
|
||||
render: () => <BranchReusePreview cloud />
|
||||
})
|
||||
|
||||
@@ -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(<NewWorkspaceComposerNameSection {...props} />)
|
||||
expect(screen.getByRole('radiogroup', { name: 'Branch for this worktree' })).toBeTruthy()
|
||||
|
||||
rerender(
|
||||
<NewWorkspaceComposerNameSection
|
||||
{...props}
|
||||
ephemeralVmRecipes={[cloudRecipe, localRecipe]}
|
||||
selectedEphemeralVmRecipeId="vm"
|
||||
/>
|
||||
)
|
||||
expect(screen.getByRole('radiogroup', { name: 'Branch for this worktree' })).toBeTruthy()
|
||||
expect(screen.getByText('Create a new local branch')).toBeTruthy()
|
||||
|
||||
rerender(
|
||||
<NewWorkspaceComposerNameSection
|
||||
{...props}
|
||||
ephemeralVmRecipes={[cloudRecipe, localRecipe]}
|
||||
selectedEphemeralVmRecipeId="cloud"
|
||||
/>
|
||||
)
|
||||
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()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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 })}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -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.",
|
||||
|
||||
Reference in New Issue
Block a user