{"record":{"id":"b213ecfacf73e2d0","repo":"stablyai/orca","slug":"response-error-message-b213ec","errorCode":null,"errorMessage":"${response.error.message}","messagePattern":"\\$\\{response\\.error\\.message\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"mobile/src/components/NewWorktreeModal.tsx","lineNumber":413,"sourceCode":"    })()\n    return () => {\n      stale = true\n    }\n  }, [visible, client, hostId])\n\n  useEffect(() => {\n    if (!visible || !client || !selectedRepoConnectionId) {\n      return\n    }\n    let stale = false\n    void client\n      .sendRequest('ssh.getState', { targetId: selectedRepoConnectionId })\n      .then((response) => {\n        if (stale) {\n          return\n        }\n        if (!response.ok) {\n          throw new Error(response.error.message)\n        }\n        const state = (response as RpcSuccess).result as { state?: SshConnectionState | null }\n        setSshState(\n          state.state ?? {\n            targetId: selectedRepoConnectionId,\n            status: 'disconnected',\n            error: null,\n            reconnectAttempt: 0\n          }\n        )\n      })\n      .catch((err) => {\n        if (!stale) {\n          setSshState({\n            targetId: selectedRepoConnectionId,\n            status: 'error',\n            error: err instanceof Error ? err.message : 'Failed to read SSH connection state.',\n            reconnectAttempt: 0","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/mobile/src/components/NewWorktreeModal.tsx#L395-L431","documentation":"Inside the NewWorktreeModal, a useEffect fires `ssh.getState` for the selected repo connection to read the current SSH connection state when the modal becomes visible. If the RPC returns ok=false, it throws the host's error.message; the chained .catch() maps that into an sshState with status 'error' and the thrown message as the error field.","triggerScenarios":"ssh.getState fails — the SSH target was deleted, the host's SSH subsystem errored, the connection id is unknown to the host, or the host predates the ssh.getState method.","commonSituations":"Selecting an SSH-backed repo whose target was removed server-side, a host restart that lost SSH state, an older host without ssh.* methods, or a transient relay error.","solutions":["Verify the SSH target still exists on the host (re-open repo settings).","Upgrade the host to support ssh.getState.","Let the modal's error state guide the user; the catch already sets status 'error'.","Retry by closing/reopening the modal (the effect re-fires on visible toggle)."],"exampleFix":"// before\nif (!response.ok) {\n  throw new Error(response.error.message)\n}\n\n// after — treat missing-method as disconnected rather than error\nif (!response.ok) {\n  if ((response as RpcFailure).error.code === 'METHOD_NOT_FOUND') {\n    setSshState({ targetId: selectedRepoConnectionId, status: 'disconnected', error: null, reconnectAttempt: 0 })\n    return\n  }\n  throw new Error((response as RpcFailure).error.message)\n}","handlingStrategy":"try-catch","validationCode":"// Skip the probe if the host likely lacks ssh.* methods\nconst caps = await client.sendRequest('status.get').catch(() => null)\nconst supportsSsh = (caps as any)?.result?.capabilities?.includes('ssh')\nif (!supportsSsh) { setSshState({ targetId: selectedRepoConnectionId, status: 'disconnected', error: null, reconnectAttempt: 0 }); return }","typeGuard":"function isSshStateSuccess(r: RpcSuccess | RpcFailure): r is RpcSuccess & { result: { state?: SshConnectionState | null } } {\n  return r.ok\n}","tryCatchPattern":".then((response) => {\n  if (stale) return\n  if (!response.ok) throw new Error((response as RpcFailure).error.message)\n  // ...\n}).catch((err) => {\n  if (!stale) setSshState({ targetId: selectedRepoConnectionId, status: 'error', error: err instanceof Error ? err.message : 'Failed to read SSH connection state.', reconnectAttempt: 0 })\n})","preventionTips":["Use the stale flag on every async to avoid setState after unmount.","Treat METHOD_NOT_FOUND as 'disconnected' rather than 'error' for older hosts.","Re-run the effect on visible toggle to recover from transient failures."],"tags":["mobile","rpc","ssh","new-worktree-modal","fallback-message"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}