stablyai/orca · error · Error

Created terminal response was invalid

Error message

Created terminal response was invalid

What it means

Thrown when `session.tabs.createTerminal` succeeded (ok:true) but the result does not look like a terminal tab - `readMobileReviewCreatedTerminal` returned null. That reader requires result.tab to be a record and the tab to have type:'terminal' plus non-empty id and terminal. So the host returned a success envelope whose payload does not match the expected shape.

Source

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

// 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)

Solutions

  1. Update both client and host to matching versions (remote wire compat).
  2. Capture the raw created.result and compare to the expected schema.
  3. Report with the host version.
  4. Fall back to opening a terminal manually.

Example fix

// before
const terminalTab = readMobileReviewCreatedTerminal(created.result)
if (!terminalTab) {
  throw new Error('Created terminal response was invalid')
}
// after - log the shape for diagnostics
const terminalTab = readMobileReviewCreatedTerminal(created.result)
if (!terminalTab) {
  console.warn('[triage] unexpected createTerminal result', created.result)
  throw new Error('Created terminal response was invalid (host/client version mismatch)')
}
Defensive patterns

Strategy: type-guard

Type guard

function readMobileReviewCreatedTerminal(value: unknown): MobileReviewTerminalTab | null {
  if (!isRecord(value) || !isRecord(value.tab)) return null
  return readMobileReviewTerminalTabs({ tabs: [value.tab] })[0] ?? null
}

Try / catch

const terminalTab = readMobileReviewCreatedTerminal(created.result)
if (!terminalTab) {
  openManualTerminalSheet() // degrade instead of failing the whole launch
  return
}

Prevention

When it happens

Trigger: Host version returns a different create-terminal payload (missing tab, tab.type not 'terminal', or no terminal handle). Codec drift / version mismatch between paired client and host; or malformed relay serialization.

Common situations: Client newer than host (or vice versa) where the create-terminal result schema changed; host returned a non-terminal tab type; malformed relay serialization.

Related errors


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