{"record":{"id":"d38fe0afaf642460","repo":"stablyai/orca","slug":"waiting-for-desktop","errorCode":null,"errorMessage":"Waiting for desktop...","messagePattern":"Waiting for desktop\\.\\.\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"mobile/app/h/[hostId]/session/[worktreeId].tsx","lineNumber":1946,"sourceCode":"      setDiffComments([])\n      return\n    }\n    const response = await client.sendRequest('worktree.show', {\n      worktree: `id:${worktreeId}`\n    })\n    if (!response.ok) {\n      return\n    }\n    const result = (response as RpcSuccess).result as {\n      worktree?: { diffComments?: unknown }\n    }\n    setDiffComments(normalizeMobileDiffComments(result.worktree?.diffComments, worktreeId))\n  }, [client, connState, worktreeId, isFloatingWorkspaceRoute])\n\n  const persistDiffComments = useCallback(\n    async (comments: readonly DiffComment[]): Promise<void> => {\n      if (!client || connState !== 'connected') {\n        throw new Error('Waiting for desktop...')\n      }\n      const response = await client.sendRequest('worktree.set', {\n        worktree: `id:${worktreeId}`,\n        diffComments: comments\n      })\n      if (!response.ok) {\n        throw new Error((response as RpcFailure).error.message || 'Failed to save review notes')\n      }\n    },\n    [client, connState, worktreeId]\n  )\n\n  useEffect(() => {\n    void loadDiffComments()\n  }, [loadDiffComments])\n\n  const addDiffCommentForFile = useCallback(\n    async (filePath: string, lineNumber: number, body: string): Promise<boolean> => {","sourceCodeStart":1928,"sourceCodeEnd":1964,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/mobile/app/h/[hostId]/session/[worktreeId].tsx#L1928-L1964","documentation":"Thrown in persistDiffComments() when attempting to save review notes (diff comments) but the client is not connected (client is null or connState !== 'connected'). Diff comments are persisted via the worktree.set RPC, which requires an active connection to the desktop host. This guards against losing edits during a disconnect.","triggerScenarios":"persistDiffComments(comments) is called when connState is 'connecting', 'disconnected', 'error', or client is null. Caused by: the user editing review notes while the connection drops; a reconnect in progress; the session loading before the client initializes; a transient network interruption.","commonSituations":"User on mobile editing review notes when the SSH/remote connection to the desktop host drops; switching networks causing a brief disconnect; the desktop process restarting; connState transitioning during a save attempt.","solutions":["Wait for connState to return to 'connected' before retrying the save.","Queue the comments locally and retry persistDiffComments on reconnection.","Check connState in the UI to disable the save action or show a 'reconnecting' indicator.","If the disconnect persists, verify the remote host is reachable and the session is still active."],"exampleFix":"// before: throws immediately on disconnect\nif (!client || connState !== 'connected') {\n  throw new Error('Waiting for desktop...')\n}\n\n// after: queue and retry on reconnect\nif (!client || connState !== 'connected') {\n  pendingDiffCommentsRef.current = comments\n  return\n}\n// On reconnect, flush pendingDiffCommentsRef.current","handlingStrategy":"retry","validationCode":"function assertConnected(client, connState) {\n  if (!client || connState !== 'connected') {\n    throw new Error('Waiting for desktop...')\n  }\n}","typeGuard":"function isClientReady(client, connState) {\n  return client !== null && client !== undefined && connState === 'connected'\n}","tryCatchPattern":"try {\n  await persistDiffComments(comments)\n} catch (err) {\n  if (err.message === 'Waiting for desktop...') {\n    // Queue locally and retry when connState returns to 'connected'\n    pendingCommentsRef.current = comments\n  } else {\n    throw err\n  }\n}","preventionTips":["Disable the save UI action when connState !== 'connected' to prevent the throw.","Queue unsaved comments locally and flush on reconnection.","Show a connection status indicator so the user knows the state before editing."],"tags":["mobile","rpc","connection-state","review-notes","retry"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}