fix(w8): DS-28 new cloud workspace repo picker + idle-sleep line (#231)

* feat(w8): DS-28 new cloud workspace: pick the repository from this phone's recents and the team's projects ('Other repository…' for any other), and say 'Sleeps after N minutes idle' (new screen, empty Home)

* copy(w8): DS-28 with the picker, the note says 'Pick none for a blank project'

* fix(w8): DS-28 review: explicit 'No repository (blank project)' row, the field stays while typing an unlisted repo, choosing 'Other repository…' again keeps the text

* fix(w8): DS-28 nit: typing in the field selects 'Other repository…'
This commit is contained in:
Neil
2026-11-10 04:03:15 -08:00
committed by GitHub
parent a7989dfd1e
commit 2d99d9b591
7 changed files with 249 additions and 20 deletions
+84 -19
View File
@@ -41,7 +41,12 @@ import {
import { nextCloudWorkspaceTitle } from './cloud-workspace-display'
import { roleForCloudError } from './cloud-entitlement-copy'
import { createErrorMessage } from './cloud-workspace-copy'
import { ORCA_CLOUD_SANDBOX_SPEC } from '../../../src/shared/hosted-sandbox/hosted-sandbox-wire'
import {
ORCA_CLOUD_IDLE_SLEEP_MINUTES,
ORCA_CLOUD_SANDBOX_SPEC
} from '../../../src/shared/hosted-sandbox/hosted-sandbox-wire'
import { cloudRepoPickerRows } from './cloud-repo-picker-rows'
import { cloudRepoChoices, loadRecentCloudRepos, recordRecentCloudRepo } from './cloud-recent-repos'
export function NewCloudWorkspaceScreen() {
useMobileColorScheme()
@@ -51,6 +56,18 @@ export function NewCloudWorkspaceScreen() {
const invalidate = useInvalidateCloudWorkspaces()
const existing = useCloudWorkspaces(useCloudEnrollment()).data
const [repo, setRepo] = useState('')
const [recents, setRecents] = useState<string[]>([])
// "Other repository…": the free-text field, also the only field when there is nothing to pick.
const [typing, setTyping] = useState(false)
useEffect(() => {
void loadRecentCloudRepos().then(setRecents)
}, [])
const choices = cloudRepoChoices(
recents,
(existing ?? []).flatMap((workspace) => (workspace.repo ? [workspace.repo.url] : []))
)
// The field stays while what's typed isn't one of the rows, even if the rows load mid-typing.
const showField = typing || choices.length === 0 || (repo !== '' && !choices.includes(repo))
const [branch, setBranch] = useState('')
const [agent, setAgent] = useState(ORCA_CLOUD_DEFAULT_AGENT)
const [prompt, setPrompt] = useState('')
@@ -125,6 +142,9 @@ export function NewCloudWorkspaceScreen() {
}
// The sandbox exists from here on: nothing below may report "couldn't create" or create again.
const { projectRoot } = created
if (repoUrl) {
void recordRecentCloudRepo(repoUrl).catch(() => undefined)
}
const workspace = {
...created.workspace,
title: nextCloudWorkspaceTitle(created.workspace.title, existing ?? [])
@@ -169,12 +189,18 @@ export function NewCloudWorkspaceScreen() {
>
<SettingsSection
first
radioGroup={choices.length > 0}
title={t('cloud.new.repoHeading', 'Repository')}
footer={
repoInvalid ? (
<SettingsNote error>
{t('cloud.new.repoInvalid', 'Use a GitHub repository, like owner/repo.')}
</SettingsNote>
) : choices.length > 0 ? (
t(
'cloud.new.repoNotePicker',
'Private repos need the Orca Cloud GitHub app, connected once from Orca on your computer.'
)
) : (
t(
'cloud.new.repoNote',
@@ -183,20 +209,47 @@ export function NewCloudWorkspaceScreen() {
)
}
>
<View key="repo" style={styles.field}>
<TextInput
style={styles.input}
value={repo}
onChangeText={setRepo}
editable={!creating}
placeholder={t('cloud.new.repoPlaceholder', 'owner/repo')}
placeholderTextColor={colors.textMuted}
autoCapitalize="none"
autoCorrect={false}
keyboardType="url"
accessibilityLabel={t('cloud.new.repoLabel', 'GitHub repository')}
/>
</View>
{cloudRepoPickerRows({
choices,
repo,
typing,
disabled: creating,
t,
onPick: (next) => {
setTyping(false)
setRepo(next)
},
onOther: () => {
// Choosing it again keeps what was typed.
if (!typing) {
setTyping(true)
setRepo('')
}
}
})}
{showField ? (
<View key="repo" style={styles.field}>
<TextInput
style={styles.input}
value={repo}
onChangeText={(text) => {
setRepo(text)
// Typing here is choosing "Other repository…", even if the rows load mid-typing.
if (choices.length > 0) {
setTyping(true)
}
}}
editable={!creating}
autoFocus={typing}
placeholder={t('cloud.new.repoPlaceholder', 'owner/repo')}
placeholderTextColor={colors.textMuted}
autoCapitalize="none"
autoCorrect={false}
keyboardType="url"
accessibilityLabel={t('cloud.new.repoLabel', 'GitHub repository')}
/>
</View>
) : null}
</SettingsSection>
<SettingsSection title={t('cloud.new.branchLabel', 'Branch')}>
<View key="branch" style={styles.field}>
@@ -216,10 +269,22 @@ export function NewCloudWorkspaceScreen() {
<SettingsSection
title={t('cloud.new.agentHeading', 'First task')}
footer={t('cloud.size.note', 'Every sandbox gets {{vcpus}} vCPU · {{memoryGb}} GB.', {
vcpus: String(ORCA_CLOUD_SANDBOX_SPEC.vcpus),
memoryGb: String(ORCA_CLOUD_SANDBOX_SPEC.memoryGb)
})}
footer={
<>
<SettingsNote>
{t('cloud.size.note', 'Every sandbox gets {{vcpus}} vCPU · {{memoryGb}} GB.', {
vcpus: String(ORCA_CLOUD_SANDBOX_SPEC.vcpus),
memoryGb: String(ORCA_CLOUD_SANDBOX_SPEC.memoryGb)
})}
</SettingsNote>
<SettingsNote>
{t('cloud.idle.sleeps', 'Sleeps after {{count}} minutes idle.', {
count: ORCA_CLOUD_IDLE_SLEEP_MINUTES,
defaultValue_one: 'Sleeps after {{count}} minute idle.'
})}
</SettingsNote>
</>
}
>
<View key="task" style={styles.field}>
<CloudAgentPicker value={agent} onChange={setAgent} disabled={creating} />
@@ -0,0 +1,40 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
const store = vi.hoisted(() => new Map<string, string>())
vi.mock('@react-native-async-storage/async-storage', () => ({
default: {
getItem: async (key: string) => store.get(key) ?? null,
setItem: async (key: string, value: string) => void store.set(key, value)
}
}))
import {
cloudRepoChoices,
cloudRepoSlug,
loadRecentCloudRepos,
recordRecentCloudRepo
} from './cloud-recent-repos'
describe('repository picker choices', () => {
beforeEach(() => store.clear())
it('reads owner/repo from GitHub URLs and slugs, nothing else', () => {
expect(cloudRepoSlug('https://github.com/octocat/Hello-World')).toBe('octocat/Hello-World')
expect(cloudRepoSlug('https://github.com/acme/app.git')).toBe('acme/app')
expect(cloudRepoSlug('acme/app')).toBe('acme/app')
expect(cloudRepoSlug('https://gitlab.com/acme/app')).toBeNull()
})
it('lists this phone’s recents first, then the team’s projects, each once', async () => {
await recordRecentCloudRepo('https://github.com/acme/app')
await recordRecentCloudRepo('https://github.com/acme/web')
await recordRecentCloudRepo('https://github.com/acme/app')
expect(await loadRecentCloudRepos()).toEqual(['acme/app', 'acme/web'])
expect(
cloudRepoChoices(await loadRecentCloudRepos(), [
'https://github.com/acme/web',
'https://github.com/octocat/Hello-World'
])
).toEqual(['acme/app', 'acme/web', 'octocat/Hello-World'])
})
})
+56
View File
@@ -0,0 +1,56 @@
import AsyncStorage from '@react-native-async-storage/async-storage'
import { z } from 'zod'
// Repositories this phone started cloud workspaces from, newest first, for the new-workspace picker.
const KEY = 'orca:cloud-recent-repos:v1'
const MAX = 8
/** "owner/repo" for a GitHub URL (or an "owner/repo" already), else null. */
export function cloudRepoSlug(url: string): string | null {
const match =
/^(?:https?:\/\/github\.com\/)?([A-Za-z0-9-]+)\/([A-Za-z0-9._-]+?)(?:\.git)?\/?$/.exec(
url.trim()
)
return match ? `${match[1]}/${match[2]}` : null
}
export async function loadRecentCloudRepos(): Promise<string[]> {
try {
const parsed = z
.array(z.string())
.safeParse(JSON.parse((await AsyncStorage.getItem(KEY)) ?? '[]'))
return parsed.success ? parsed.data.slice(0, MAX) : []
} catch {
return []
}
}
export async function recordRecentCloudRepo(url: string): Promise<void> {
const slug = cloudRepoSlug(url)
if (!slug) {
return
}
const next = [slug, ...(await loadRecentCloudRepos()).filter((entry) => entry !== slug)].slice(
0,
MAX
)
await AsyncStorage.setItem(KEY, JSON.stringify(next))
}
/** Recents first, then the team's projects (repos of its cloud workspaces), each once. */
export function cloudRepoChoices(
recents: readonly string[],
teamRepoUrls: readonly string[]
): string[] {
const seen = new Set<string>()
const choices: string[] = []
for (const slug of [...recents, ...teamRepoUrls.flatMap((url) => cloudRepoSlug(url) ?? [])]) {
const key = slug.toLowerCase()
if (!seen.has(key)) {
seen.add(key)
choices.push(slug)
}
}
return choices.slice(0, 12)
}
@@ -0,0 +1,50 @@
import type { ReactElement } from 'react'
import { ListRow } from '../components/list/ListGroup'
import type { Translate } from '../i18n/mobile-i18n'
/**
* The repository picker's rows: recents and the team's projects, "No repository (blank project)",
* then "Other repository…" for any other repo (the free-text field). Keyed rows, not a fragment, so
* the group draws its separators.
*/
export function cloudRepoPickerRows(args: {
choices: readonly string[]
repo: string
typing: boolean
disabled: boolean
t: Translate
onPick: (repo: string) => void
onOther: () => void
}): ReactElement[] {
if (args.choices.length === 0) {
return []
}
return [
...args.choices.map((choice) => (
<ListRow
key={`repo:${choice}`}
title={choice}
selected={!args.typing && args.repo === choice}
accessibilityRole="radio"
disabled={args.disabled}
onPress={() => args.onPick(choice)}
/>
)),
<ListRow
key="repo:none"
title={args.t('cloud.new.repoNone', 'No repository (blank project)')}
selected={!args.typing && args.repo === ''}
accessibilityRole="radio"
disabled={args.disabled}
onPress={() => args.onPick('')}
/>,
<ListRow
key="repo:other"
title={args.t('cloud.new.repoOther', 'Other repository…')}
selected={args.typing}
accessibilityRole="radio"
disabled={args.disabled}
onPress={args.onOther}
/>
]
}
@@ -18,6 +18,7 @@ import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
import { homeListStyles as styles } from './home-list-styles'
import { MobileHomeSectionHeading } from './MobileHomeSectionHeading'
import { ORCA_CLOUD_IDLE_SLEEP_MINUTES } from '../../../src/shared/hosted-sandbox/hosted-sandbox-wire'
export type CloudEnrollDesktop = { name: string; client: RpcClient }
@@ -84,6 +85,12 @@ export function MobileHomeCloudSection(props: {
'Start one here. It keeps running while this phone and your computer sleep.'
)}
</Text>
<Text style={styles.subtitle}>
{t('cloud.idle.sleeps', 'Sleeps after {{count}} minutes idle.', {
count: ORCA_CLOUD_IDLE_SLEEP_MINUTES,
defaultValue_one: 'Sleeps after {{count}} minute idle.'
})}
</Text>
</View>
</View>
) : (
+4
View File
@@ -141,6 +141,10 @@
}
},
"cloud": {
"idle": {
"sleeps_one": "Sleeps after {{count}} minute idle.",
"sleeps_other": "Sleeps after {{count}} minutes idle."
},
"snapshot": {
"git": {
"files_one": "{{count}} changed file",
+8 -1
View File
@@ -5088,7 +5088,10 @@
"promptPlaceholder": "Optional. What should the agent start on?",
"creating": "Starting your cloud workspace",
"createAndStart": "Start workspace and agent",
"create": "Start workspace"
"create": "Start workspace",
"repoOther": "Other repository…",
"repoNotePicker": "Private repos need the Orca Cloud GitHub app, connected once from Orca on your computer.",
"repoNone": "No repository (blank project)"
},
"line": {
"runningFor": "Up {{elapsed}}. Agents keep working when you close the app.",
@@ -5214,6 +5217,10 @@
"asleep": "{{name}} is asleep",
"asleepDetail": "Files are kept. Wake it to keep working.",
"wake": "Wake"
},
"idle": {
"sleeps_one": "Sleeps after {{count}} minute idle.",
"sleeps_other": "Sleeps after {{count}} minutes idle."
}
}
}