diff --git a/mobile/app/h/[hostId]/index.tsx b/mobile/app/h/[hostId]/index.tsx index e24af3d908a..f7613d03e51 100644 --- a/mobile/app/h/[hostId]/index.tsx +++ b/mobile/app/h/[hostId]/index.tsx @@ -1,4 +1,5 @@ import { useLocalSearchParams } from 'expo-router' +import { CloudHostAsleepGate } from '../../../src/cloud/CloudHostAsleepGate' import { firstParam } from '../../../src/navigation/route-param-reader' import { MobileWebShellScreen } from '../../../src/mobile-web-shell/MobileWebShellScreen' import { shellScreenRoute } from '../../../src/mobile-web-shell/shell-screen-route' @@ -24,14 +25,17 @@ function HostListScreen() { return } return ( - + // An asleep cloud workspace's VM is not an offline computer: say so and offer Wake first. + + + ) } diff --git a/mobile/app/h/[hostId]/session/[worktreeId].tsx b/mobile/app/h/[hostId]/session/[worktreeId].tsx index fdf8234cbd5..aa13ee51aaa 100644 --- a/mobile/app/h/[hostId]/session/[worktreeId].tsx +++ b/mobile/app/h/[hostId]/session/[worktreeId].tsx @@ -1,3 +1,4 @@ +import { CloudHostAsleepGate } from '../../../../src/cloud/CloudHostAsleepGate' import { withWorkspaceRoute } from '../../../../src/navigation/workspace-route' import { useWorkspaceExecutionHost, @@ -68,11 +69,13 @@ export default withWorkspaceRoute(function MobileSessionScreen() { // Keep shared shellScreenRouteKey unchanged because other screens treat param changes as identity changes. const { paneKey: _paneKey, paneView: _paneView, ...identity } = routeParams return ( - + + + ) }) diff --git a/mobile/src/cloud/CloudHostAsleepGate.tsx b/mobile/src/cloud/CloudHostAsleepGate.tsx new file mode 100644 index 00000000000..1ae3c01e354 --- /dev/null +++ b/mobile/src/cloud/CloudHostAsleepGate.tsx @@ -0,0 +1,74 @@ +import { useRouter } from 'expo-router' +import { Moon } from 'lucide-react-native' +import { useEffect, useState, type ReactNode } from 'react' +import { ActivityIndicator, View } from 'react-native' +import { SafeAreaView } from 'react-native-safe-area-context' +import { MobileStateView } from '../components/MobileStateView' +import { useMobileTranslation } from '../i18n/use-mobile-translation' +import { SettingsNavBar } from '../settings/settings-screen-frame' +import { colors } from '../theme/mobile-theme' +import { useMobileColorScheme } from '../theme/use-mobile-color-scheme' +import { cloudHostGate } from './cloud-screen-states' +import { cloudWorkspaceIdForHost } from './cloud-workspace-links' +import { useCloudEnrollment, useCloudWorkspace } from './use-cloud-workspaces' + +/** + * A cloud workspace's VM is a paired host, but an asleep one is not "a computer that's offline": + * before its page loads, say it's asleep and offer Wake (the normal wake → access → connect flow, + * which lands back on this host). Every other host, and a cloud host that is up, passes through. + * One component with fixed hooks, and the page is mounted only once the answer is known, so it is + * never mounted and then thrown away. + */ +export function CloudHostAsleepGate(props: { hostId: string; children: ReactNode }) { + useMobileColorScheme() + const t = useMobileTranslation() + const router = useRouter() + // The answer is kept with the host it was looked up for: a gate reused for another host waits + // instead of reading the previous host's workspace for a render. + const [lookup, setLookup] = useState<{ hostId: string; sandboxId: string | null } | null>(null) + useEffect(() => { + let live = true + const hostId = props.hostId + void cloudWorkspaceIdForHost(hostId) + .then((id) => live && setLookup({ hostId, sandboxId: id })) + .catch(() => live && setLookup({ hostId, sandboxId: null })) + return () => { + live = false + } + }, [props.hostId]) + const sandboxId = lookup?.hostId === props.hostId ? lookup.sandboxId : undefined + const enrollment = useCloudEnrollment() + const listed = useCloudWorkspace(enrollment, sandboxId ?? '') + const gate = cloudHostGate({ + sandboxId, + enrollment, + isPending: listed.isPending, + isError: listed.isError, + status: listed.workspace?.status ?? null + }) + if (gate === 'pass') { + return props.children + } + if (gate === 'wait') { + return ( + + + + ) + } + const sleeping = listed.workspace + return ( + + router.back()} /> + router.replace(`/cloud/${encodeURIComponent(sandboxId ?? '')}?autostart=1`) + }} + /> + + ) +} diff --git a/mobile/src/cloud/CloudStatusCard.tsx b/mobile/src/cloud/CloudStatusCard.tsx index 4917bd9db42..858b91457f4 100644 --- a/mobile/src/cloud/CloudStatusCard.tsx +++ b/mobile/src/cloud/CloudStatusCard.tsx @@ -67,11 +67,9 @@ export function CloudStatusCard(props: { - {active - ? t('cloud.status.waking', 'Waking') - : notConnected - ? t('cloud.status.cantConnect', 'Can’t connect') - : cloudStatusLabel(workspace.status, t)} + {/* Only glossary states: a running workspace this phone can't reach still reads + "Running" (with the warning dot); the error banner below says what went wrong. */} + {active ? t('cloud.status.waking', 'Waking') : cloudStatusLabel(workspace.status, t)} {active ? ( diff --git a/mobile/src/cloud/CloudWorkspaceScreen.tsx b/mobile/src/cloud/CloudWorkspaceScreen.tsx index 45f0b157920..b31ced0355c 100644 --- a/mobile/src/cloud/CloudWorkspaceScreen.tsx +++ b/mobile/src/cloud/CloudWorkspaceScreen.tsx @@ -23,7 +23,11 @@ import { CloudPromptQueueSection } from './CloudPromptQueueSection' import { CloudReadSnapshotSection } from './CloudReadSnapshotSection' import { CloudStatusCard } from './CloudStatusCard' import { CloudWorkspaceActions } from './CloudWorkspaceActions' -import { archiveCloudWorkspace, sleepCloudWorkspace } from './cloud-control-plane-client' +import { + archiveCloudWorkspace, + restartCloudWorkspace, + sleepCloudWorkspace +} from './cloud-control-plane-client' import { CloudRequestError } from './cloud-control-plane-request' import { enqueueCloudPrompt, @@ -37,6 +41,8 @@ import { useCloudHostRemoval } from './cloud-session' import { attachErrorMessage, phaseLabel } from './cloud-workspace-copy' +import { setCloudReturnTo } from './cloud-return-to' +import { cloudMissingState } from './cloud-screen-states' import { cloudRepoLine } from './cloud-workspace-display' import { cloudScrollBottomPadding, @@ -65,8 +71,14 @@ export function CloudWorkspaceScreen({ const insets = useSafeAreaInsets() const removal = useCloudHostRemoval() const enrollment = useCloudEnrollment() - const { workspace, isPending, isFetching, refetch } = useCloudWorkspace(enrollment, sandboxId) - const live = useCloudWorkspaceLiveStatus(sandboxId, workspace?.status === 'running') + const listed = useCloudWorkspace(enrollment, sandboxId) + const { isPending, isFetching, isError, refetch } = listed + const live = useCloudWorkspaceLiveStatus(sandboxId, listed.workspace?.status === 'running') + // The registry only knows "running"; the live status knows when it is up but not answering. + const workspace = + listed.workspace?.status === 'running' && live.data?.state === 'unresponsive' + ? { ...listed.workspace, status: 'unresponsive' as const } + : listed.workspace // Asleep: read its last sealed snapshot instead of waking it. Nothing here ever wakes it. const asleep = workspace?.status === 'sleeping' const snapshot = useCloudReadSnapshot(sandboxId, asleep, workspace?.readSnapshotAt ?? null) @@ -80,7 +92,7 @@ export function CloudWorkspaceScreen({ // keychain), the button already reads Waking rather than keeping "Wake to continue". const [wakeTappedAt, setWakeTappedAt] = useState(null) const wakePending = wakeTappedAt !== null && wakeTappedAt === run - const [busyAction, setBusyAction] = useState<'sleep' | 'archive' | null>(null) + const [busyAction, setBusyAction] = useState<'sleep' | 'archive' | 'restart' | null>(null) useEffect(() => { const load = () => @@ -124,7 +136,7 @@ export function CloudWorkspaceScreen({ ) const lifecycle = useCallback( - async (action: 'sleep' | 'archive') => { + async (action: 'sleep' | 'archive' | 'restart') => { const plane = await loadCloudControlPlane() if (!plane || !workspace) { return @@ -132,7 +144,9 @@ export function CloudWorkspaceScreen({ clearError() setBusyAction(action) try { - if (action === 'sleep') { + if (action === 'restart') { + await restartCloudWorkspace(plane, workspace.id) + } else if (action === 'sleep') { await sleepCloudWorkspace(plane, workspace.id) } else { await archiveCloudWorkspace(plane, workspace.id) @@ -141,12 +155,17 @@ export function CloudWorkspaceScreen({ } catch (error) { await forgetRevokedCloudSession(error, removal) fail( - action === 'archive' && error instanceof CloudRequestError && error.status === 404 + action === 'restart' && error instanceof CloudRequestError && error.status === 404 ? t( - 'cloud.error.archiveUnavailable', - 'Archiving isn’t available yet. Put it to sleep instead.' + 'cloud.error.restartOwner', + 'Only the workspace’s owner can restart it. Your files are safe.' ) - : attachErrorMessage(error, t) + : action === 'archive' && error instanceof CloudRequestError && error.status === 404 + ? t( + 'cloud.error.archiveUnavailable', + 'Archiving isn’t available yet. Put it to sleep instead.' + ) + : attachErrorMessage(error, t) ) } finally { setBusyAction(null) @@ -157,6 +176,7 @@ export function CloudWorkspaceScreen({ ) if (!workspace) { + const missing = cloudMissingState({ enrollment, isPending, isFetching, isError }) return ( router.back()} /> - {isPending || isFetching || enrollment === undefined ? ( + {missing === 'signin' ? ( + // A share link opened on a phone that isn't connected yet: the list query never runs. + <> + + {t('cloud.workspace.signIn', 'Sign in to Orca Cloud on this phone')} + + { + // Connect on Home, then come straight back to this workspace. + setCloudReturnTo(`/cloud/${sandboxId}`) + router.replace('/') + }} + style={styles.linkButton} + > + {t('cloud.workspace.signInAction', 'Sign in')} + + + ) : missing === 'loading' ? ( ) : ( <> - {t( - 'cloud.workspace.missing', - 'This workspace is gone or you no longer have access.' - )} + {missing === 'unreachable' + ? t( + 'cloud.workspace.unreachable', + 'Couldn’t reach Orca Cloud. Check your connection and try again.' + ) + : t( + 'cloud.workspace.missing', + 'This workspace is gone or you no longer have access.' + )} void lifecycle('sleep')} onArchive={() => void lifecycle('archive')} @@ -322,6 +375,10 @@ export function CloudWorkspaceScreen({ openSession('chat') return } + if (restartable) { + void lifecycle('restart') + return + } setWakeTappedAt(run) void start('open').finally(() => setWakeTappedAt(null)) }} diff --git a/mobile/src/cloud/cloud-control-plane-client.ts b/mobile/src/cloud/cloud-control-plane-client.ts index 29086df890d..33043dc67d0 100644 --- a/mobile/src/cloud/cloud-control-plane-client.ts +++ b/mobile/src/cloud/cloud-control-plane-client.ts @@ -27,6 +27,9 @@ export type CloudWorkspaceStatus = | 'sleeping' | 'archived' | 'failed' + /** Up but not answering (glossary "Not responding"); a restart usually fixes it. */ + | 'unresponsive' + | 'deleting' export type CloudWorkspace = { /** The sandbox row id: stable across sleep, wake and rollover. */ @@ -57,8 +60,8 @@ const SANDBOX_STATUS: Record = { sleeping: 'sleeping', archived: 'archived', failed: 'failed', - unresponsive: 'failed', - destroying: 'stopping' + unresponsive: 'unresponsive', + destroying: 'deleting' } const SandboxViewSchema = z.object({ @@ -200,6 +203,20 @@ export async function sleepCloudWorkspace( ) } +/** "Not responding": restart the sandbox (files kept). Owner route; a teammate gets not_found. */ +export async function restartCloudWorkspace( + plane: CloudControlPlane, + sandboxId: string +): Promise { + await request( + plane, + 'POST', + `/v1/sandboxes/${encodeURIComponent(sandboxId)}/restart`, + z.unknown(), + { body: {}, timeoutMs: 120_000 } + ) +} + export async function archiveCloudWorkspace( plane: CloudControlPlane, sandboxId: string diff --git a/mobile/src/cloud/cloud-return-to.ts b/mobile/src/cloud/cloud-return-to.ts new file mode 100644 index 00000000000..5a61e05c9e7 --- /dev/null +++ b/mobile/src/cloud/cloud-return-to.ts @@ -0,0 +1,17 @@ +// Where to go once this phone is connected to Orca Cloud: a team link opened before connecting +// (e.g. /cloud/) is returned to after "Connect Orca Cloud" on Home succeeds. Memory only, and +// short-lived: a user who gave up on that link and connects later isn't sent back to it. + +const TTL_MS = 10 * 60_000 +let returnTo: { path: string; at: number } | null = null + +export function setCloudReturnTo(path: string, now: number = Date.now()): void { + // Only an in-app cloud route, never an arbitrary destination. + returnTo = /^\/cloud\/[A-Za-z0-9_-]+$/.test(path) ? { path, at: now } : null +} + +export function takeCloudReturnTo(now: number = Date.now()): string | null { + const entry = returnTo + returnTo = null + return entry && now - entry.at <= TTL_MS ? entry.path : null +} diff --git a/mobile/src/cloud/cloud-screen-states.test.ts b/mobile/src/cloud/cloud-screen-states.test.ts new file mode 100644 index 00000000000..34683b21133 --- /dev/null +++ b/mobile/src/cloud/cloud-screen-states.test.ts @@ -0,0 +1,65 @@ +import { describe, expect, it } from 'vitest' +import { setCloudReturnTo, takeCloudReturnTo } from './cloud-return-to' +import { cloudHostGate, cloudMissingState } from './cloud-screen-states' + +const base = { isPending: false, isFetching: false, isError: false } + +describe('cloud workspace screen without its workspace', () => { + it('asks a phone that isn’t connected to sign in, instead of spinning on a query that never runs', () => { + expect(cloudMissingState({ ...base, enrollment: null, isPending: true })).toBe('signin') + }) + + it('spins while connecting or fetching, including a retry after an error', () => { + expect(cloudMissingState({ ...base, enrollment: undefined })).toBe('loading') + expect(cloudMissingState({ ...base, enrollment: {}, isPending: true })).toBe('loading') + expect(cloudMissingState({ ...base, enrollment: {}, isError: true, isFetching: true })).toBe( + 'loading' + ) + }) + + it('says Orca Cloud is unreachable on an error, and gone only when the list loaded without it', () => { + expect(cloudMissingState({ ...base, enrollment: {}, isError: true, isPending: true })).toBe( + 'unreachable' + ) + expect(cloudMissingState({ ...base, enrollment: {} })).toBe('gone') + }) +}) + +describe('cloud host gate', () => { + const known = { enrollment: {}, isPending: false, isError: false } + + it('waits until it knows whether the host is a cloud workspace and what state it is in', () => { + expect(cloudHostGate({ ...known, sandboxId: undefined, status: null })).toBe('wait') + expect(cloudHostGate({ ...known, sandboxId: 'sbx', isPending: true, status: null })).toBe( + 'wait' + ) + }) + + it('shows "asleep" only for an asleep cloud workspace', () => { + expect(cloudHostGate({ ...known, sandboxId: 'sbx', status: 'sleeping' })).toBe('asleep') + // Still going to sleep, or awake: the page handles it. + expect(cloudHostGate({ ...known, sandboxId: 'sbx', status: 'stopping' })).toBe('pass') + expect(cloudHostGate({ ...known, sandboxId: 'sbx', status: 'running' })).toBe('pass') + }) + + it('passes through for desktops, an unconnected phone, or an unreachable registry', () => { + expect(cloudHostGate({ ...known, sandboxId: null, status: null })).toBe('pass') + expect( + cloudHostGate({ ...known, sandboxId: 'sbx', enrollment: null, isPending: true, status: null }) + ).toBe('pass') + expect(cloudHostGate({ ...known, sandboxId: 'sbx', isError: true, status: null })).toBe('pass') + }) +}) + +describe('return after connecting', () => { + it('returns once to an in-app cloud workspace route, never anywhere else', () => { + setCloudReturnTo('/cloud/sbx_abc') + expect(takeCloudReturnTo()).toBe('/cloud/sbx_abc') + expect(takeCloudReturnTo()).toBeNull() + setCloudReturnTo('https://evil.example/cloud/x') + expect(takeCloudReturnTo()).toBeNull() + // Gave up on the link and connected much later: stay on Home. + setCloudReturnTo('/cloud/sbx_abc', 0) + expect(takeCloudReturnTo(11 * 60_000)).toBeNull() + }) +}) diff --git a/mobile/src/cloud/cloud-screen-states.ts b/mobile/src/cloud/cloud-screen-states.ts new file mode 100644 index 00000000000..a52294cbbbb --- /dev/null +++ b/mobile/src/cloud/cloud-screen-states.ts @@ -0,0 +1,52 @@ +import type { CloudWorkspaceStatus } from './cloud-control-plane-client' + +// Which state a cloud screen shows while its workspace isn't in hand. Pure, so each branch is tested. + +export type CloudMissingState = 'signin' | 'loading' | 'unreachable' | 'gone' + +/** + * The workspace screen without its workspace. Not connected (enrollment null) means the list query + * never runs: a share link opened on a fresh phone must ask to sign in, not spin forever. A refetch + * after an error shows the spinner again. + */ +export function cloudMissingState(args: { + enrollment: unknown | null | undefined + isPending: boolean + isFetching: boolean + isError: boolean +}): CloudMissingState { + if (args.enrollment === null) { + return 'signin' + } + if (args.enrollment === undefined || args.isFetching || (args.isPending && !args.isError)) { + return 'loading' + } + return args.isError ? 'unreachable' : 'gone' +} + +export type CloudHostGate = 'wait' | 'pass' | 'asleep' + +/** + * Before a paired host's page loads: `wait` while it isn't known yet whether this host is an asleep + * cloud workspace; `asleep` only for a workspace the registry says is asleep; anything else (not a + * cloud host, not connected, registry unreachable, awake) passes through to the page. + */ +export function cloudHostGate(args: { + /** undefined while the host → workspace lookup runs; null when it's not a cloud workspace. */ + sandboxId: string | null | undefined + enrollment: unknown | null | undefined + isPending: boolean + isError: boolean + status: CloudWorkspaceStatus | null +}): CloudHostGate { + if (args.sandboxId === undefined) { + return 'wait' + } + if (args.sandboxId === null || args.enrollment === null || args.isError) { + return 'pass' + } + if (args.enrollment === undefined || args.isPending) { + return 'wait' + } + return args.status === 'sleeping' ? 'asleep' : 'pass' +} diff --git a/mobile/src/cloud/cloud-workspace-copy.ts b/mobile/src/cloud/cloud-workspace-copy.ts index 7e637d15d41..008d5e72299 100644 --- a/mobile/src/cloud/cloud-workspace-copy.ts +++ b/mobile/src/cloud/cloud-workspace-copy.ts @@ -105,6 +105,10 @@ export function statusSentence( return t('cloud.line.archived', 'Unarchive it on your computer to work in it again.') case 'failed': return t('cloud.line.failed', 'The sandbox couldn’t start. Your files are safe.') + case 'unresponsive': + return t('cloud.line.unresponsive', 'The sandbox isn’t responding. Your files are safe.') + case 'deleting': + return t('cloud.line.deleting', 'This workspace is being deleted.') } } diff --git a/mobile/src/cloud/cloud-workspace-display.ts b/mobile/src/cloud/cloud-workspace-display.ts index 98b86e7364f..f1829026a47 100644 --- a/mobile/src/cloud/cloud-workspace-display.ts +++ b/mobile/src/cloud/cloud-workspace-display.ts @@ -19,6 +19,10 @@ export function cloudStatusLabel(status: CloudWorkspaceStatus, t: Translate): st return t('cloud.status.archived', 'Archived') case 'failed': return t('cloud.status.failed', 'Couldn’t start') + case 'unresponsive': + return t('cloud.status.unresponsive', 'Not responding') + case 'deleting': + return t('cloud.status.deleting', 'Deleting') } } @@ -33,6 +37,11 @@ export function cloudStatusColor(status: CloudWorkspaceStatus): string { return colors.textSecondary case 'failed': return colors.statusRed + case 'unresponsive': + // Glossary: "Not responding" uses the status-warning ink. + return colors.statusAmber + case 'deleting': + return colors.textMuted case 'sleeping': case 'archived': return colors.textMuted @@ -40,7 +49,9 @@ export function cloudStatusColor(status: CloudWorkspaceStatus): string { } export function isCloudStatusTransitional(status: CloudWorkspaceStatus): boolean { - return status === 'creating' || status === 'waking' || status === 'stopping' + return ( + status === 'creating' || status === 'waking' || status === 'stopping' || status === 'deleting' + ) } const hourFormatters = new Map() diff --git a/mobile/src/cloud/cloud-workspace-links.ts b/mobile/src/cloud/cloud-workspace-links.ts index 1477593d3c6..539ec73a50a 100644 --- a/mobile/src/cloud/cloud-workspace-links.ts +++ b/mobile/src/cloud/cloud-workspace-links.ts @@ -123,6 +123,12 @@ export async function cloudWorkspaceHostId(sandboxId: string): Promise { + const entry = Object.entries(await readLinks()).find(([, link]) => link.hostId === hostId) + return entry?.[0] ?? null +} + export async function cloudWorkspaceHostIds(): Promise> { const ids = Object.values(await readLinks()).flatMap((link) => (link.hostId ? [link.hostId] : [])) return new Set(ids) diff --git a/mobile/src/cloud/cloud-workspace-states.test.ts b/mobile/src/cloud/cloud-workspace-states.test.ts new file mode 100644 index 00000000000..715f8e407ff --- /dev/null +++ b/mobile/src/cloud/cloud-workspace-states.test.ts @@ -0,0 +1,41 @@ +import { describe, expect, it } from 'vitest' +import type { Translate } from '../i18n/mobile-i18n' +import { listCloudWorkspaces } from './cloud-control-plane-client' +import { cloudStatusLabel } from './cloud-workspace-display' + +const t: Translate = (_key, fallback) => fallback + +describe('cloud workspace states (glossary)', () => { + it('reads unresponsive as Not responding and destroying as Deleting, never Couldn’t start or Going to sleep', async () => { + const plane = { + baseUrl: 'https://cp.test', + token: () => 'tok', + fetch: async (input: RequestInfo | URL) => + new URL(String(input)).pathname === '/v1/sandboxes' + ? Response.json({ + sandboxes: [ + { + id: 'sbx_a', + workspaceId: 'ws-a', + status: 'unresponsive', + machineSize: 'standard', + createdAt: 1 + }, + { + id: 'sbx_b', + workspaceId: 'ws-b', + status: 'destroying', + machineSize: 'standard', + createdAt: 1 + } + ] + }) + : Response.json({ error: 'not_found' }, { status: 404 }) + } + const { workspaces } = await listCloudWorkspaces(plane) + expect(workspaces.map((w) => [w.status, cloudStatusLabel(w.status, t)])).toEqual([ + ['unresponsive', 'Not responding'], + ['deleting', 'Deleting'] + ]) + }) +}) diff --git a/mobile/src/cloud/use-cloud-workspaces.ts b/mobile/src/cloud/use-cloud-workspaces.ts index d918f99b568..44752c98844 100644 --- a/mobile/src/cloud/use-cloud-workspaces.ts +++ b/mobile/src/cloud/use-cloud-workspaces.ts @@ -24,7 +24,8 @@ import { const TRANSITIONAL: ReadonlySet = new Set([ 'creating', 'waking', - 'stopping' + 'stopping', + 'deleting' ]) export const cloudWorkspacesQueryKey = (sessionId: string | null) => diff --git a/mobile/src/components/HostOfflineBanner.tsx b/mobile/src/components/HostOfflineBanner.tsx index 4ba805bb582..693caea6bfb 100644 --- a/mobile/src/components/HostOfflineBanner.tsx +++ b/mobile/src/components/HostOfflineBanner.tsx @@ -113,7 +113,7 @@ export function HostOfflineBanner({ onPress={onRetry} accessibilityRole="button" > - {t('common.retry', 'Retry')} + {t('common.tryAgain', 'Try again')} ) : null} diff --git a/mobile/src/home/MobileHomeCloudSection.tsx b/mobile/src/home/MobileHomeCloudSection.tsx index ff4aa8d6679..203ea6d2c06 100644 --- a/mobile/src/home/MobileHomeCloudSection.tsx +++ b/mobile/src/home/MobileHomeCloudSection.tsx @@ -1,3 +1,4 @@ +import { useRouter } from 'expo-router' import { ChevronRight, Cloud, Plus, RotateCw } from 'lucide-react-native' import { Fragment, useState } from 'react' import { ActivityIndicator, Pressable, Text, View } from 'react-native' @@ -5,6 +6,7 @@ import { CloudStatusDot } from '../cloud/CloudStatusDot' import { formatReadSnapshotAsOf } from '../cloud/CloudReadSnapshotSection' import type { CloudWorkspace } from '../cloud/cloud-control-plane-client' import { CloudEnrollmentError, enrollCloudDevice } from '../cloud/cloud-device-enrollment' +import { takeCloudReturnTo } from '../cloud/cloud-return-to' import type { CloudEnrollment } from '../cloud/cloud-device-identity' import { cloudRepoLine, cloudStatusLabel } from '../cloud/cloud-workspace-display' import { useCloudWorkspaces } from '../cloud/use-cloud-workspaces' @@ -212,6 +214,7 @@ function CloudConnectRow({ deviceLabel: string }) { const t = useMobileTranslation() + const router = useRouter() const [busy, setBusy] = useState(false) const [error, setError] = useState(null) const connect = async () => { @@ -222,6 +225,11 @@ function CloudConnectRow({ setError(null) try { await enrollCloudDevice({ desktop: desktop.client, desktopName: desktop.name, deviceLabel }) + // Arrived here from a team link opened before connecting: go back to that workspace. + const next = takeCloudReturnTo() + if (next) { + router.push(next) + } } catch (failure) { const kind = failure instanceof CloudEnrollmentError ? failure.failure : 'unreachable' setError( diff --git a/mobile/src/i18n/locales/en.json b/mobile/src/i18n/locales/en.json index a9454bde967..4daadc22b31 100644 --- a/mobile/src/i18n/locales/en.json +++ b/mobile/src/i18n/locales/en.json @@ -5001,13 +5001,15 @@ }, "status": { "waking": "Waking", - "cantConnect": "Can’t connect", "archived": "Archived", "creating": "Starting", "running": "Running", "stopping": "Going to sleep", "sleeping": "Asleep", - "failed": "Couldn’t start" + "failed": "Couldn’t start", + "deleting": "Deleting", + "restarting": "Restarting", + "unresponsive": "Not responding" }, "actions": { "sleep": "Sleep", @@ -5039,18 +5041,23 @@ "createUnknown": "Lost the connection while starting it. It may still appear in your list. Try again to pick it up.", "rateLimited": "Too many new workspaces at once. Wait a minute, then try again.", "create": "Couldn’t start your cloud workspace. Nothing was created, and you weren’t charged.", - "deliver": "The workspace is running, but a prompt didn’t start. Your files are safe." + "deliver": "The workspace is running, but a prompt didn’t start. Your files are safe.", + "restartOwner": "Only the workspace’s owner can restart it. Your files are safe." }, "workspace": { "title": "Cloud workspace", - "missing": "This workspace is gone or you no longer have access." + "missing": "This workspace is gone or you no longer have access.", + "signIn": "Sign in to Orca Cloud on this phone", + "signInAction": "Sign in", + "unreachable": "Couldn’t reach Orca Cloud. Check your connection and try again." }, "action": { "openSession": "Open session", "settingUp": "Starting…", "open": "Open workspace", "wakeOpen": "Wake and open workspace", - "wakeToContinue": "Wake to continue" + "wakeToContinue": "Wake to continue", + "restart": "Restart sandbox" }, "phase": { "delivering": "Starting your agent", @@ -5091,7 +5098,9 @@ "waking": "Starting up. This usually takes about 5 seconds.", "stopping": "Files are kept.", "archived": "Unarchive it on your computer to work in it again.", - "failed": "The sandbox couldn’t start. Your files are safe." + "failed": "The sandbox couldn’t start. Your files are safe.", + "unresponsive": "The sandbox isn’t responding. Your files are safe.", + "deleting": "This workspace is being deleted." }, "home": { "heading": "Cloud", @@ -5200,6 +5209,11 @@ "asleep_other": "{{hours}} sandbox hours so far. Uses no sandbox hours while asleep.", "running_one": "{{hours}} sandbox hour so far. Uses sandbox hours while running.", "running_other": "{{hours}} sandbox hours so far. Uses sandbox hours while running." + }, + "host": { + "asleep": "{{name}} is asleep", + "asleepDetail": "Files are kept. Wake it to keep working.", + "wake": "Wake" } } }