{"record":{"id":"4a57aa65c0bc3f58","repo":"stablyai/orca","slug":"unable-to-load-files","errorCode":null,"errorMessage":"Unable to load files","messagePattern":"Unable to load files","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mobile/src/files/MobileFileExplorerPanel.tsx","lineNumber":142,"sourceCode":"            })\n            if (legacy.ok) {\n              if (\n                !isCurrentDirectoryLoad(\n                  directoryLoadRevisionsRef.current,\n                  scopeRef.current,\n                  loadToken\n                )\n              ) {\n                return\n              }\n              const legacyResult = (legacy as RpcSuccess).result as LegacyFilesListResult\n              setDirectoryCache(directoryCacheFromFileList(legacyResult.files))\n              // Why: the capped list silently omits files past the cap — keep\n              // the legacy explorer's \"Showing first 5000\" note.\n              setLegacyListTruncated(legacyResult.truncated)\n              return\n            }\n            throw new Error(\n              legacy.error?.message || response.error?.message || 'Unable to load files'\n            )\n          }\n          throw new Error(response.error?.message || 'Unable to load files')\n        }\n        if (\n          !isCurrentDirectoryLoad(directoryLoadRevisionsRef.current, scopeRef.current, loadToken)\n        ) {\n          return\n        }\n        const entries = (response as RpcSuccess).result as MobileDirEntry[]\n        if (rootLoad) {\n          setLegacyListTruncated(false)\n        }\n        setDirectoryCache((prev) => ({\n          ...prev,\n          [relativePath]: { entries }\n        }))","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/mobile/src/files/MobileFileExplorerPanel.tsx#L124-L160","documentation":"Thrown by MobileFileExplorerPanel.loadDirectory when files.readDir failed with a method-unavailable error on a root load, the legacy files.list fallback was attempted, and the legacy call ALSO failed (legacy.ok === false) with no usable error message. This is the legacy-fallback exhaustion path — neither the modern nor the legacy directory-listing RPC worked.","triggerScenarios":"At root relativePath, client.sendRequest('files.readDir', ...) returns method_not_found / 'not available to mobile clients', then client.sendRequest('files.list', ...) also returns {ok:false}. Reached only when isMobileMethodUnavailableError matched on the first error AND rootLoad is true.","commonSituations":"The paired desktop is in a degraded state where both RPC methods reject (e.g., worktree unmounted, host mid-shutdown); the host build is so old that files.list also has a problem; the worktreeId is invalid and both RPCs refuse it.","solutions":["Verify the host connection is still 'connected' (connState) and the worktreeId still exists via worktree.show before retrying loadDirectory.","Use forceReconnect to re-establish the host client, then trigger a root reload.","Check the desktop host logs — both RPCs failing usually indicates a host-side worktree or filesystem problem rather than a client issue.","Surface the underlying error code to the user instead of the generic tail so support can diagnose."],"exampleFix":"// before\nthrow new Error(\n  legacy.error?.message || response.error?.message || 'Unable to load files'\n)\n\n// after — keep the codes for diagnostics\nconst code = legacy.error?.code ?? response.error?.code\nthrow new Error(\n  legacy.error?.message || response.error?.message || `Unable to load files${code ? ` (${code})` : ''}`\n)","handlingStrategy":"fallback","validationCode":"// Confirm the host is connected and the worktree exists before reload\nif (!client || connState !== 'connected') return\nconst exists = await client.sendRequest('worktree.show', { worktree: `id:${worktreeId}` })\nif (!exists.ok || !(exists as any).result?.worktree) return","typeGuard":"function isFileListUnavailableError(err: unknown): boolean {\n  return err instanceof Error && err.message === 'Unable to load files'\n}","tryCatchPattern":"try {\n  await loadDirectory('')\n} catch (err) {\n  if (isFileListUnavailableError(err)) {\n    setError('Could not load files. Reconnecting...')\n    await forceReconnect()\n    await loadDirectory('')\n    return\n  }\n  throw err\n}","preventionTips":["Surface the underlying error code (response.error?.code) so support can distinguish 'not_found' from 'permission_denied'.","Keep the cached tree visible on root-load failure so users can navigate while retrying in the background.","Probe host capabilities once and cache whether files.readDir is supported, to avoid the legacy fallback round-trip on every load."],"tags":["rpc","files","fallback","legacy-compat","react-native"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}