{"record":{"id":"5d0a9d6c5c10d284","repo":"stablyai/orca","slug":"response-error-message-5d0a9d","errorCode":null,"errorMessage":"response.error.message","messagePattern":"response\\.error\\.message","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mobile/src/tasks/setup-hook-trust.ts","lineNumber":50,"sourceCode":"  const approvedAt = args.approvedAt ?? Date.now()\n  const existing = args.trust[args.repoId]\n  const nextRepo = args.alwaysTrust\n    ? { ...existing, all: { approvedAt } }\n    : { ...existing, setup: { contentHash: args.contentHash, approvedAt } }\n  return { ...args.trust, [args.repoId]: nextRepo }\n}\n\nexport async function persistSetupHookTrustApproval(args: {\n  client: RpcClient\n  trust: PersistedTrustedOrcaHooks\n  repoId: string\n  contentHash: string\n  alwaysTrust: boolean\n}): Promise<PersistedTrustedOrcaHooks> {\n  const next = trustedOrcaHooksWithSetupApproval(args)\n  const response = await args.client.sendRequest('ui.set', { trustedOrcaHooks: next })\n  if (!response.ok) {\n    throw new Error(response.error.message)\n  }\n  return next\n}\n\nexport function normalizeSetupHookTrust(\n  setupTrust: SetupHookTrust | null | undefined\n): SetupHookTrust | null {\n  if (!setupTrust?.contentHash || !setupTrust.scriptContent) {\n    return null\n  }\n  return setupTrust\n}\n","sourceCodeStart":32,"sourceCodeEnd":63,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/mobile/src/tasks/setup-hook-trust.ts#L32-L63","documentation":"The ui.set RPC returned an RpcFailure (response.ok === false) while persisting the setup-hook trust approval. The ui.set method writes the trustedOrcaHooks map into the desktop's persistent UI state. A failure here means the host's settings store rejected the write or the transport broke.","triggerScenarios":"The desktop's settings store is locked or unwritable (permissions, disk full); the WebSocket dropped between the user tapping 'Trust' and the write landing; the host process is restarting; pairing revoked mid-call ('unauthorized').","commonSituations":"Host disk full or settings file locked by another process; relay disconnect during a settings write; user revoked pairing on the desktop while approving on mobile; host app in the middle of an update/restart.","solutions":["Catch and keep the in-memory trust approval (the next = trustedOrcaHooksWithSetupApproval) so the session still works, then retry the persist.","If response.error.code === 'unauthorized', route to re-pair instead of retrying.","Show a non-blocking toast 'Trust saved locally, will sync on reconnect' so the user is not blocked.","Retry the ui.set call on the next 'connected' state change."],"exampleFix":"// before\nconst response = await args.client.sendRequest('ui.set', { trustedOrcaHooks: next })\nif (!response.ok) {\n  throw new Error(response.error.message)\n}\nreturn next\n\n// after — keep the session working, retry persist in the background\nconst response = await args.client.sendRequest('ui.set', { trustedOrcaHooks: next })\nif (!response.ok && response.error.code !== 'unauthorized') {\n  scheduleTrustPersistRetry(args.client, next)\n}\nreturn next","handlingStrategy":"retry","validationCode":"if (client.getState() !== 'connected') {\n  // Defer the persist until reconnect; keep in-memory trust\n}","typeGuard":"function isRpcFailure(r: RpcResponse): r is RpcFailure {\n  return !r.ok\n}","tryCatchPattern":"try {\n  await persistSetupHookTrustApproval({ client, trust, repoId, contentHash, alwaysTrust })\n} catch (e) {\n  // Keep the in-memory approval; retry on reconnect\n  scheduleTrustPersistRetry(client, next)\n}","preventionTips":["Keep the computed trust map (next) in memory even if persist fails — the session should still work.","Retry ui.set on the next 'connected' state change.","Route 'unauthorized' to re-pair, not to a retry."],"tags":["rpc","ui-state","settings","mobile","network","setup-hooks"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}