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 { describe, expect, it } from 'vitest'
import { readySession, run } from './mobile-web-shell-session-test-fixtures'
import { shellPageBackClaimed } from './shell-page-back-claim'
import type { MobileWebShellStep } from './mobile-web-shell-session-contract'
// Exercise every document reset: stale Back claims must never route a press to a page that no longer holds it.
describe('the page claiming the device Back key', () => {
function claimed(): MobileWebShellStep {
return run(
readySession().session,
{ type: 'page-ready' },
{ type: 'page-back-claim', claimed: true }
)
}
it('records the claim and gives it back when the page lets go', () => {
const held = claimed()
expect(shellPageBackClaimed(held.session)).toBe(true)
expect(
shellPageBackClaimed(run(held.session, { type: 'page-back-claim', claimed: false }).session)
).toBe(false)
})
it('drops it when a replacement document starts inside this mount', () => {
expect(shellPageBackClaimed(run(claimed().session, { type: 'document-started' }).session)).toBe(
false
)
})
it('drops it when the view is remounted under a new session id', () => {
const remounted = run(claimed().session, { type: 'remounted', sessionId: 'session-two' })
expect(shellPageBackClaimed(remounted.session)).toBe(false)
})
it('drops it when the document asks for a session again, so the page has to claim again', () => {
const reasked = run(claimed().session, { type: 'page-ready' })
expect(shellPageBackClaimed(reasked.session)).toBe(false)
})
it('drops it when a page fault takes the generation off screen', () => {
const failed = run(claimed().session, { type: 'shell-failed', reason: 'document-load-failed' })
expect(failed.session.state.kind).not.toBe('ready')
expect(shellPageBackClaimed(failed.session)).toBe(false)
})
it('records nothing from a page whose generation is no longer on screen', () => {
const failed = run(claimed().session, { type: 'shell-failed', reason: 'isolation-unavailable' })
const late = run(failed.session, { type: 'page-back-claim', claimed: true })
expect(shellPageBackClaimed(late.session)).toBe(false)
})
})