{"record":{"id":"aea86807588548bd","repo":"stablyai/orca","slug":"created-terminal-response-was-invalid-aea868","errorCode":null,"errorMessage":"Created terminal response was invalid","messagePattern":"Created terminal response was invalid","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mobile/src/session/pr-ai-triage-launch.ts","lineNumber":29,"sourceCode":"// on mobile, so this createTerminal+send pair is the launch mechanism. Kept free of\n// react-native imports so it stays unit-testable in the node test environment.\nexport async function createTerminalAndSendPrompt(\n  client: Pick<RpcClient, 'sendRequest'>,\n  worktreeId: string,\n  prompt: string\n): Promise<void> {\n  const created = await client.sendRequest('session.tabs.createTerminal', {\n    worktree: `id:${worktreeId}`,\n    activate: false,\n    select: true,\n    navigation: 'caller'\n  })\n  if (!created.ok) {\n    throw new Error(created.error?.message || 'Failed to create terminal')\n  }\n  const terminalTab = readMobileReviewCreatedTerminal(created.result)\n  if (!terminalTab) {\n    throw new Error('Created terminal response was invalid')\n  }\n  const sent = await client.sendRequest('terminal.send', {\n    terminal: terminalTab.terminal,\n    text: prompt,\n    enter: true\n  })\n  if (!sent.ok) {\n    throw new Error(sent.error?.message || 'Failed to send prompt')\n  }\n  if (!readMobileReviewTerminalSendAccepted(sent.result)) {\n    throw new Error('Terminal input is locked')\n  }\n}\n","sourceCodeStart":11,"sourceCodeEnd":43,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/mobile/src/session/pr-ai-triage-launch.ts#L11-L43","documentation":"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.","triggerScenarios":"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.","commonSituations":"Client newer than host (or vice versa) where the create-terminal result schema changed; host returned a non-terminal tab type; malformed relay serialization.","solutions":["Update both client and host to matching versions (remote wire compat).","Capture the raw created.result and compare to the expected schema.","Report with the host version.","Fall back to opening a terminal manually."],"exampleFix":"// before\nconst terminalTab = readMobileReviewCreatedTerminal(created.result)\nif (!terminalTab) {\n  throw new Error('Created terminal response was invalid')\n}\n// after - log the shape for diagnostics\nconst terminalTab = readMobileReviewCreatedTerminal(created.result)\nif (!terminalTab) {\n  console.warn('[triage] unexpected createTerminal result', created.result)\n  throw new Error('Created terminal response was invalid (host/client version mismatch)')\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function readMobileReviewCreatedTerminal(value: unknown): MobileReviewTerminalTab | null {\n  if (!isRecord(value) || !isRecord(value.tab)) return null\n  return readMobileReviewTerminalTabs({ tabs: [value.tab] })[0] ?? null\n}","tryCatchPattern":"const terminalTab = readMobileReviewCreatedTerminal(created.result)\nif (!terminalTab) {\n  openManualTerminalSheet() // degrade instead of failing the whole launch\n  return\n}","preventionTips":["Keep paired client/host on compatible wire versions.","Unit-test the reader against the host payload fixture.","Log unexpected payloads to catch schema drift early."],"tags":["rpc","terminal","schema","version-mismatch","mobile"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}