Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.
TypeScript adeagent-ideai-agentsautomationbotclaude-codecodexghosttygrok-bothermes-agentmobile-appmuseopenclawopencodeorchestrationpiruntimeterminalworktreesyc-backed
import { act, create } from 'react-test-renderer'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { BRIDGE_PROTOCOL_VERSION } from '../mobile-web-shell/bridge/bridge-envelope'
import type { ForceReconnect, RpcClientContextValue } from './rpc-client-context-contract'
const page = vi.hoisted(() => ({ read: (): RpcClientContextValue | null => null }))
// Forward lazily to the .web context; awaiting a mock of its reciprocal hook import deadlocks.
vi.mock('./client-context', () => ({ useRpcClientContext: () => page.read() }))
import { createShellPageClient } from '../mobile-web-shell/bridge/page-bootstrap'
import { RpcClientProvider, useRpcClientContext } from './client-context.web'
import { useForceReconnect } from './host-client-hooks'
page.read = useRpcClientContext
const INIT = {
v: BRIDGE_PROTOCOL_VERSION,
type: 'init',
sessionId: 'session-a',
buildId: 'build-a',
connection: {
state: 'reconnecting',
reconnectAttempt: 4,
lastConnectedAt: 1700,
lastInboundAt: 1800,
generation: 5
},
grants: { rpc: { maxPendingRequests: 64, maxSubscriptions: 32 }, native: [] }
}
afterEach(() => {
Reflect.deleteProperty(globalThis, 'orcaBridge')
})
describe('useForceReconnect on the page', () => {
it('answers null through the real hook, which is what every Retry reads', () => {
const channel: {
postMessage: (json: string) => void
onmessage: ((e: { data: string }) => void) | null
} = {
postMessage: () => {},
onmessage: null
}
Object.defineProperty(globalThis, 'orcaBridge', { value: channel, configurable: true })
const client = createShellPageClient()
if (client === null) {
throw new Error('no channel installed')
}
channel.onmessage?.({ data: JSON.stringify(INIT) })
const read: { value: ForceReconnect | undefined } = { value: undefined }
function Probe(): null {
read.value = useForceReconnect()
return null
}
act(() => {
create(
<RpcClientProvider client={client}>
<Probe />
</RpcClientProvider>
)
})
expect(read.value).toBeNull()
})
})