{"record":{"id":"cf1aff724fb234df","repo":"stablyai/orca","slug":"failed-to-send-notes","errorCode":null,"errorMessage":"Failed to send notes","messagePattern":"Failed to send notes","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mobile/app/h/[hostId]/session/[worktreeId].tsx","lineNumber":3725,"sourceCode":"            const next = [...prev, createdTerminal]\n            terminalsRef.current = next\n            return next\n          })\n          subscribeToTerminal(createdHandle)\n          if (options?.initialPrompt?.trim()) {\n            void client\n              .sendRequest(\n                'terminal.send',\n                buildTerminalSendParams({\n                  terminal: createdHandle,\n                  text: options.initialPrompt,\n                  enter: options.enter !== false,\n                  deviceToken: deviceTokenRef.current\n                })\n              )\n              .then((sendResponse) => {\n                if (!sendResponse.ok) {\n                  throw new Error(\n                    (sendResponse as RpcFailure).error.message || 'Failed to send notes'\n                  )\n                }\n                const result = (sendResponse as RpcSuccess).result as {\n                  send?: { accepted?: boolean }\n                }\n                if (result.send?.accepted === false) {\n                  throw new Error('Terminal input is locked by another client.')\n                }\n                triggerSuccess()\n                showToast(options.successToast ?? 'Notes sent')\n                options.onPromptSent?.()\n              })\n              .catch((err) => {\n                triggerError()\n                showToast(\n                  options.errorToast ??\n                    (err instanceof Error ? err.message : \"Couldn't send notes\"),","sourceCodeStart":3707,"sourceCodeEnd":3743,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/mobile/app/h/[hostId]/session/[worktreeId].tsx#L3707-L3743","documentation":"Thrown in the terminal.send promise chain when sending notes/prompt to a newly created terminal fails at the RPC level (ok: false) and the failure has no error.message. This is the fallback string when the server-side rejection lacks a descriptive message. The terminal was created successfully but sending the prompt text to it was rejected.","triggerScenarios":"client.sendRequest('terminal.send', {...}) returns ok:false with error.message empty/undefined. Caused by: the terminal handle becoming invalid between create and send; the device token being rejected; a server-side validation failure with no message; the terminal process exiting before the send.","commonSituations":"A quick command or prompt send to a terminal that exited immediately after creation; a device token mismatch between mobile and desktop; a version skew in the terminal.send params schema; the terminal being locked or disposed server-side.","solutions":["Check the desktop host logs for the terminal.send rejection reason.","Verify the deviceToken is current and matches the session's token.","If the terminal exited between create and send, consider retrying the send or recreating the terminal.","Log the full failure object (code, details) when error.message is empty."],"exampleFix":"// before: empty message gives generic 'Failed to send notes'\nthrow new Error(\n  (sendResponse as RpcFailure).error.message || 'Failed to send notes'\n)\n\n// after: include error code\nconst failure = sendResponse as RpcFailure\nthrow new Error(\n  failure.error.message ||\n  `Failed to send notes (code: ${failure.error.code ?? 'unknown'})`\n)","handlingStrategy":"try-catch","validationCode":"function buildSendErrorMessage(sendResponse) {\n  if (sendResponse.ok) return null\n  const failure = sendResponse as RpcFailure\n  return failure.error.message || `Failed to send notes (code: ${failure.error.code ?? 'unknown'})`\n}","typeGuard":"function isTerminalSendAccepted(response) {\n  if (!response.ok) return false\n  const result = (response as RpcSuccess).result as { send?: { accepted?: boolean } }\n  return result?.send?.accepted !== false\n}","tryCatchPattern":"// Already handled via .catch in the source — extend it:\n.catch((err) => {\n  triggerError()\n  if (err.message === 'Failed to send notes') {\n    // RPC failed with no message — check host logs\n    showToast('Send failed — the desktop host rejected the request', 1800)\n  } else {\n    showToast(err.message, 1800)\n  }\n})","preventionTips":["Verify the deviceToken is current before sending to a newly created terminal.","Include the RPC error code in the fallback message.","Ensure the desktop host returns descriptive error messages for terminal.send rejections."],"tags":["mobile","rpc","terminal","prompt-send","server-error"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}