stablyai/orca · error

Failed to create terminal

Error message

Failed to create terminal

What it means

Thrown by the PR AI triage launcher when `session.tabs.createTerminal` returns a failure. This is step one of the create-terminal-then-send-prompt launch used by 'Fix checks with AI' / 'Resolve conflicts with AI'. The host's error.message is preferred; the literal string is the fallback when the host gave no message.

Solutions

  1. Retry after reconnecting.
  2. Verify the worktree still exists on the host.
  3. Check the host terminal count / quota.
  4. Update client and host to compatible versions.

Example fix

// before
if (!created.ok) {
  throw new Error(created.error?.message || 'Failed to create terminal')
}
// after - carry the host error code so callers can branch
if (!created.ok) {
  throw new RpcMethodError('session.tabs.createTerminal', created.error)
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (!client || connState !== 'connected') throw new Error('Waiting for desktop...')

Type guard

function isRpcFailure(r: RpcResponse): r is RpcFailure {
  return r.ok === false
}

Try / catch

try {
  await createTerminalAndSendPrompt(client, worktreeId, prompt)
} catch (err) {
  setTriageError(err instanceof Error ? err.message : 'Could not start AI triage')
}

Prevention

When it happens

Trigger: The host refuses to create a terminal in the target worktree - worktree missing/disposed, terminal quota reached, the worktree id no longer resolves; or a transport/relay failure on the one-shot.

Common situations: The worktree was deleted on the host while the mobile review screen was open; host terminal limit hit; relay cutover mid-launch; version skew where the host does not accept navigation:'caller'.

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/91ea3a70252db00a. Report an issue: GitHub.

Appendix: source

Thrown at mobile/src/session/pr-ai-triage-launch.ts:25

// Pure launch path for the PR triage actions ("Fix checks with AI" / "Resolve
// conflicts with AI"). Reuses the same two RPCs the diff-review send flow uses —
// session.tabs.createTerminal then terminal.send — so the prompt is dropped into a
// fresh agent terminal in the worktree. There is no higher-level agent-composer RPC
// on mobile, so this createTerminal+send pair is the launch mechanism. Kept free of
// react-native imports so it stays unit-testable in the node test environment.
export async function createTerminalAndSendPrompt(
  client: Pick<RpcClient, 'sendRequest'>,
  worktreeId: string,
  prompt: string
): Promise<void> {
  const created = await client.sendRequest('session.tabs.createTerminal', {
    worktree: `id:${worktreeId}`,
    activate: false,
    select: true,
    navigation: 'caller'
  })
  if (!created.ok) {
    throw new Error(created.error?.message || 'Failed to create terminal')
  }
  const terminalTab = readMobileReviewCreatedTerminal(created.result)
  if (!terminalTab) {
    throw new Error('Created terminal response was invalid')
  }
  const sent = await client.sendRequest('terminal.send', {
    terminal: terminalTab.terminal,
    text: prompt,
    enter: true
  })
  if (!sent.ok) {
    throw new Error(sent.error?.message || 'Failed to send prompt')
  }
  if (!readMobileReviewTerminalSendAccepted(sent.result)) {
    throw new Error('Terminal input is locked')
  }
}

View on GitHub (pinned to 1136503c6a)