@@ -200,7 +207,8 @@ export function CloudWakingOverlay({
) : (
@@ -220,7 +228,16 @@ export function CloudWakingOverlay({
{formatElapsedTime(seconds * 1000)}
+ ) : null}
{passThrough && pendingInput > 0 ? (
{t(
'orcaCloudWorkspace.overlay.pendingKeys',
- '{{count}} keys waiting · go to the terminal when it’s up',
+ '{{count}} keys waiting · they go to the terminal when it’s up',
{
count: pendingInput,
- defaultValue_one: '{{count}} key waiting · goes to the terminal when it’s up'
+ defaultValue_one:
+ '{{count}} key waiting · it goes to the terminal when it’s up'
}
)}
diff --git a/src/renderer/src/components/orca-cloud/CloudWorkspaceSurfaces.test.tsx b/src/renderer/src/components/orca-cloud/CloudWorkspaceSurfaces.test.tsx
index 2e00d3de756..67eea21a55c 100644
--- a/src/renderer/src/components/orca-cloud/CloudWorkspaceSurfaces.test.tsx
+++ b/src/renderer/src/components/orca-cloud/CloudWorkspaceSurfaces.test.tsx
@@ -150,6 +150,52 @@ describe('Orca Cloud surfaces', () => {
expect(queryByRole('button', { name: 'Try again' })).not.toBeNull()
})
+ it('type-through: slow at 10 s with the reassurance, Connecting… once up, keys waiting in plural', () => {
+ vi.useFakeTimers()
+ vi.setSystemTime(T0)
+ const wake = {
+ workspaceId: 'ws',
+ phase: 'waking' as const,
+ source: 'open' as const,
+ startedAt: T0 - 9_000,
+ at: T0
+ }
+ const props = {
+ workspaceName: 'w',
+ autoFocus: false,
+ typeThrough: true,
+ onRetry: noop,
+ onRestart: noop,
+ onDismiss: noop
+ }
+ const { container, queryByRole, rerender } = render(
+
+ )
+ expect(container.textContent).not.toContain('Taking longer')
+ expect(container.textContent).toContain('1 key waiting · it goes to the terminal when it’s up')
+ rerender(
+
+ )
+ expect(container.textContent).toContain(
+ 'Taking longer than usual. Your files and chats are safe.'
+ )
+ expect(container.textContent).toContain(
+ '12 keys waiting · they go to the terminal when it’s up'
+ )
+ // Still the pill (no skeleton cover), and recovery only once stuck.
+ expect(container.querySelector('[data-cloud-waking-overlay]')?.className).toContain(
+ 'justify-end'
+ )
+ expect(queryByRole('button', { name: 'Try again' })).toBeNull()
+ rerender(
+
+ )
+ expect(container.textContent).toMatch(/Connecting…\s*4s/)
+ })
+
it('a failed wake is a dismissible alert whose primary action is Try again', () => {
const onRetry = vi.fn()
const onDismiss = vi.fn()
diff --git a/src/renderer/src/components/orca-cloud/OrcaCloudWorkspaceSurface.tsx b/src/renderer/src/components/orca-cloud/OrcaCloudWorkspaceSurface.tsx
index 7591dd821a0..f1ac20f0aa2 100644
--- a/src/renderer/src/components/orca-cloud/OrcaCloudWorkspaceSurface.tsx
+++ b/src/renderer/src/components/orca-cloud/OrcaCloudWorkspaceSurface.tsx
@@ -25,6 +25,7 @@ import { CloudWorkspaceOfflineView } from './offline/CloudWorkspaceOfflineView'
import { useCloudOfflineData } from './offline/use-cloud-offline-data'
import { useCloudWorkspaceView } from './use-cloud-workspace-view'
import { useWakeInput, useWakeInputNotices } from './use-wake-input'
+import { useWakeAttachHold } from './use-wake-attach-hold'
import { clearWakeInput } from '@/components/terminal-pane/input/wake-input-buffer'
import {
runRestartCloudWorkspace,
@@ -223,13 +224,17 @@ function CloudSurface({ workspaceId }: { workspaceId: string }): React.JSX.Eleme
const t = useTranslate()
const view = useCloudWorkspaceView(workspaceId)
const name = useAppStore((state) => findWorktreeById(state, workspaceId)?.displayName ?? null)
- const now = useNow(1_000, view.wake !== undefined)
+ // Ready means the server answers; the pill stays ("Connecting…") until the pane in front has
+ // re-attached and can take keys.
+ const attachHold = useWakeAttachHold(workspaceId, view.wake)
+ const shownWake = attachHold ?? view.wake
+ const now = useNow(1_000, shownWake !== undefined)
// Typing is accepted while a wake is in flight, so the terminal stays visible and typeable.
const wakeInput = useWakeInput(workspaceId)
useWakeInputNotices(workspaceId)
const overlay = useWakeOverlay(
- view.wake,
- Math.max(now, view.wake?.at ?? 0),
+ shownWake,
+ Math.max(now, shownWake?.at ?? 0),
t('orcaCloudWorkspace.overlay.stalled', 'Orca Cloud stopped responding while waking.'),
wakeInput.pending > 0
)
diff --git a/src/renderer/src/components/orca-cloud/OrcaCloudWorkspaceWake.fixture.tsx b/src/renderer/src/components/orca-cloud/OrcaCloudWorkspaceWake.fixture.tsx
new file mode 100644
index 00000000000..2149e3e0294
--- /dev/null
+++ b/src/renderer/src/components/orca-cloud/OrcaCloudWorkspaceWake.fixture.tsx
@@ -0,0 +1,89 @@
+// Waking in type-through mode: the terminal stays visible and typeable under a small pill.
+// (A sibling of OrcaCloudWorkspace.fixture.tsx, which is at its size limit.)
+import React from 'react'
+import { defineFixture } from '../../component-fixtures/component-fixture'
+import type { CloudWakeProgressEvent } from '../../../../shared/hosted-sandbox/cloud-workspace-api'
+import { CloudWakingOverlay } from './CloudWakingOverlay'
+
+const noop = (): void => {}
+
+const wake = (over: Partial
= {}): CloudWakeProgressEvent => ({
+ workspaceId: 'ws',
+ phase: 'waking',
+ source: 'open',
+ startedAt: Date.now() - 3_200,
+ at: Date.now(),
+ ...over
+})
+
+function Pane({ children }: { children: React.ReactNode }): React.JSX.Element {
+ return (
+
+ {children}
+
+ )
+}
+
+// Started `ms` before render (not module load), so the pill reads its exact elapsed time.
+const startedAgo = (
+ ms: number,
+ over: Partial = {}
+): CloudWakeProgressEvent => wake({ startedAt: Date.now() - ms, at: Date.now(), ...over })
+
+// Type-through: the terminal stays visible and typeable under a small pill.
+function TypeThrough({
+ value,
+ pendingInput = 0
+}: {
+ value: CloudWakeProgressEvent
+ pendingInput?: number
+}): React.JSX.Element {
+ return (
+
+
+
Last login: Mon Nov 9 20:41 on ttys004
+
+ ~/fix-auth-redirect $ git status
+
+
+
+
+ )
+}
+
+export const wakingTypeThrough = defineFixture({
+ width: 640,
+ render: () =>
+})
+
+export const wakingTypeThroughPending = defineFixture({
+ width: 640,
+ render: () =>
+})
+
+export const wakingTypeThroughSlow = defineFixture({
+ width: 640,
+ render: () =>
+})
+
+// The sandbox is up and the pane in front is re-attaching: the clock still counts from the start.
+export const wakingConnecting = defineFixture({
+ width: 640,
+ render: () =>
+})
+
+// Woken on intent (hover) 3 s before the click: the pill opens already counting.
+export const wakingFromPredictive = defineFixture({
+ width: 640,
+ render: () =>
+})
diff --git a/src/renderer/src/components/orca-cloud/use-wake-attach-hold.test.tsx b/src/renderer/src/components/orca-cloud/use-wake-attach-hold.test.tsx
new file mode 100644
index 00000000000..bec789a0e50
--- /dev/null
+++ b/src/renderer/src/components/orca-cloud/use-wake-attach-hold.test.tsx
@@ -0,0 +1,108 @@
+// @vitest-environment happy-dom
+
+import { act, cleanup, renderHook } from '@testing-library/react'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import type { CloudWakeProgressEvent } from '../../../../shared/hosted-sandbox/cloud-workspace-api'
+import {
+ isActiveWakePaneAttached,
+ registerWakePane,
+ resetWakePanesForTests
+} from '@/components/terminal-pane/input/wake-pane-attach'
+import {
+ WAKE_ATTACH_HOLD_MAX_MS,
+ WAKE_ATTACH_POLL_MS,
+ useWakeAttachHold
+} from './use-wake-attach-hold'
+
+const T0 = 1_800_000_000_000
+const waking: CloudWakeProgressEvent = {
+ workspaceId: 'ws',
+ phase: 'waking',
+ source: 'open',
+ startedAt: T0 - 5_000,
+ at: T0
+}
+const start: { wake: CloudWakeProgressEvent | undefined } = { wake: waking }
+
+beforeEach(() => {
+ vi.useFakeTimers()
+ vi.setSystemTime(T0)
+ resetWakePanesForTests()
+})
+afterEach(() => {
+ vi.useRealTimers()
+ cleanup()
+})
+
+describe('wake pane registry', () => {
+ it('answers for the pane in front only, null when none is known, and keeps a remount’s entry', () => {
+ expect(isActiveWakePaneAttached('ws')).toBeNull()
+ let frontReady = false
+ const offBack = registerWakePane('ws', 'back', { isReady: () => true, isActive: () => false })
+ expect(isActiveWakePaneAttached('ws')).toBeNull()
+ const offFront = registerWakePane('ws', 'front', {
+ isReady: () => frontReady,
+ isActive: () => true
+ })
+ expect(isActiveWakePaneAttached('ws')).toBe(false)
+ frontReady = true
+ expect(isActiveWakePaneAttached('ws')).toBe(true)
+ // A remount registers again under the same leaf; the old session's removal leaves it alone.
+ registerWakePane('ws', 'front', { isReady: () => false, isActive: () => true })
+ offFront()
+ expect(isActiveWakePaneAttached('ws')).toBe(false)
+ offBack()
+ })
+})
+
+describe('useWakeAttachHold', () => {
+ it('holds a ready wake as Connecting… until the pane in front re-attaches, keeping its start', () => {
+ let attached: boolean | null = false
+ const { result, rerender } = renderHook(
+ ({ wake }: { wake: CloudWakeProgressEvent | undefined }) =>
+ useWakeAttachHold('ws', wake, () => attached),
+ { initialProps: start }
+ )
+ expect(result.current).toBeUndefined()
+ rerender({ wake: { ...waking, phase: 'ready', at: T0 + 1_000 } })
+ expect(result.current).toMatchObject({ phase: 'connecting', startedAt: waking.startedAt })
+ // The store drops the settled wake; the hold stays.
+ rerender({ wake: undefined })
+ act(() => vi.advanceTimersByTime(WAKE_ATTACH_POLL_MS * 5))
+ expect(result.current?.phase).toBe('connecting')
+ attached = true
+ act(() => vi.advanceTimersByTime(WAKE_ATTACH_POLL_MS))
+ expect(result.current).toBeUndefined()
+ })
+
+ it('does not hold when the pane is already attached or none is known, nor after a failure', () => {
+ let attached: boolean | null = true
+ const { result, rerender } = renderHook(
+ ({ wake }: { wake: CloudWakeProgressEvent | undefined }) =>
+ useWakeAttachHold('ws', wake, () => attached),
+ { initialProps: start }
+ )
+ rerender({ wake: { ...waking, phase: 'ready' } })
+ expect(result.current).toBeUndefined()
+ attached = null
+ rerender({ wake: { ...waking, startedAt: T0 } })
+ rerender({ wake: { ...waking, startedAt: T0, phase: 'ready' } })
+ expect(result.current).toBeUndefined()
+ attached = false
+ rerender({ wake: { ...waking, startedAt: T0 + 1 } })
+ rerender({ wake: { ...waking, startedAt: T0 + 1, phase: 'failed' } })
+ expect(result.current).toBeUndefined()
+ })
+
+ it('gives up on a pane that never re-attaches', () => {
+ const { result, rerender } = renderHook(
+ ({ wake }: { wake: CloudWakeProgressEvent | undefined }) =>
+ useWakeAttachHold('ws', wake, () => false),
+ { initialProps: start }
+ )
+ rerender({ wake: { ...waking, phase: 'ready' } })
+ expect(result.current?.phase).toBe('connecting')
+ act(() => vi.advanceTimersByTime(WAKE_ATTACH_HOLD_MAX_MS + WAKE_ATTACH_POLL_MS))
+ expect(result.current).toBeUndefined()
+ })
+})
diff --git a/src/renderer/src/components/orca-cloud/use-wake-attach-hold.ts b/src/renderer/src/components/orca-cloud/use-wake-attach-hold.ts
new file mode 100644
index 00000000000..15240a338ed
--- /dev/null
+++ b/src/renderer/src/components/orca-cloud/use-wake-attach-hold.ts
@@ -0,0 +1,71 @@
+import { useEffect, useState } from 'react'
+import { isActiveWakePaneAttached } from '@/components/terminal-pane/input/wake-pane-attach'
+import { installWindowVisibilityInterval } from '@/lib/window-visibility-interval'
+import type { CloudWakeProgressEvent } from '../../../../shared/hosted-sandbox/cloud-workspace-api'
+
+/** How often the hold checks the pane in front while it waits. */
+export const WAKE_ATTACH_POLL_MS = 100
+/** A pane that never re-attaches (closed, broken) stops holding the pill after this. */
+export const WAKE_ATTACH_HOLD_MAX_MS = 8_000
+
+type Track = {
+ /** The last in-flight report of the current wake: what the pill showed before ready. */
+ last: CloudWakeProgressEvent | undefined
+ /** The wake shown as still connecting while the pane in front re-attaches. */
+ held: CloudWakeProgressEvent | undefined
+}
+
+/**
+ * A wake reports ready once the server answers; the pane in front re-attaches to its terminal a
+ * moment later. Until it has, this returns the wake as still `connecting` (same start time and
+ * source, so the pill keeps counting from the wake's start), then `undefined` hands back to the
+ * store's wake. Bounded, so a pane that never attaches can't hold the pill forever.
+ */
+export function useWakeAttachHold(
+ workspaceId: string,
+ wake: CloudWakeProgressEvent | undefined,
+ isAttached: (workspaceId: string) => boolean | null = isActiveWakePaneAttached
+): CloudWakeProgressEvent | undefined {
+ const [track, setTrack] = useState