{"record":{"id":"9c51c4c42ca5e285","repo":"tinyhumansai/openhuman","slug":"not-running-in-tauri-9c51c4","errorCode":null,"errorMessage":"Not running in Tauri","messagePattern":"Not running in Tauri","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"app/src/utils/tauriCommands/memory.ts","lineNumber":104,"sourceCode":"    isTauri()\n  );\n  if (!isTauri()) {\n    console.debug('[memory] syncMemoryClientToken: exit — skipped (not Tauri)');\n    return;\n  }\n  try {\n    console.debug('[memory] syncMemoryClientToken: payload → memory.init (local-only)');\n    // jwt_token is passed for backward compatibility but ignored by the core.\n    await callCoreRpc<boolean>({ method: 'openhuman.memory_init', params: { jwt_token: token } });\n    console.info('[memory] syncMemoryClientToken: exit — ok');\n  } catch (err) {\n    console.warn('[memory] syncMemoryClientToken: exit — error:', err);\n  }\n}\n\nexport async function memoryListDocuments(namespace?: string): Promise<unknown> {\n  if (!isTauri()) {\n    throw new Error('Not running in Tauri');\n  }\n  const resp = await callCoreRpc<unknown>({\n    method: 'openhuman.memory_list_documents',\n    params: { namespace },\n  });\n  // Unwrap envelope: registry returns { data: { documents: [...] }, meta: {...} }\n  if (resp && typeof resp === 'object' && !Array.isArray(resp) && 'data' in resp) {\n    return (resp as Record<string, unknown>).data;\n  }\n  return resp;\n}\n\nexport async function memoryListNamespaces(): Promise<string[]> {\n  if (!isTauri()) {\n    throw new Error('Not running in Tauri');\n  }\n  const resp = await callCoreRpc<{ data?: { namespaces?: string[] }; namespaces?: string[] }>({\n    method: 'openhuman.memory_list_namespaces',","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/749120085864ce16e0f273c7b86fac7740b39c5b/app/src/utils/tauriCommands/memory.ts#L86-L122","documentation":"memoryListDocuments wraps openhuman.memory_list_documents and unwraps the { data: { documents } } RpcOutcome envelope, but before any of that it runs the isTauri() guard that throws 'Not running in Tauri'. The shared isTauri() (common.ts:30) is stricter than the official flag: window must exist and window.__TAURI_INTERNALS__.invoke must be a function, so it is false in browsers, jsdom tests, and the CEF bootstrap gap (#1472).","triggerScenarios":"A memory/sources screen calling memoryListDocuments(namespace) under the bare Vite dev server; a jsdom test rendering it without '@tauri-apps/api/core' mocks; the first poll of a memory hook landing before the bridge is injected at startup.","commonSituations":"Browser-based UI development (pnpm dev) of memory views; unit tests forgetting Tauri mocks; hooks that start polling on mount regardless of environment.","solutions":["Run inside the Tauri desktop host: pnpm dev:app.","Mock the Tauri core API in tests and stub the memory_list_documents envelope.","Check isTauri() before fetching documents; render an empty/desktop-only state otherwise.","Start memory polling only after the app reports core/IPC readiness."],"exampleFix":"// before\nconst docs = await memoryListDocuments(ns); // throws in browser\n\n// after\nconst docs = isTauri() ? await memoryListDocuments(ns) : undefined;","handlingStrategy":"validation","validationCode":"const docs = isTauri() ? await memoryListDocuments(namespace) : undefined;","typeGuard":"const isDocumentsEnvelope = (v: unknown): v is { documents: unknown[] } =>\n  !!v && typeof v === 'object' && Array.isArray((v as { documents?: unknown[] }).documents);","tryCatchPattern":"try { const docs = await memoryListDocuments(ns); }\ncatch (e) { if (e instanceof Error && e.message === 'Not running in Tauri') return; throw e; }","preventionTips":["Gate memory views on isTauri().","Mock '@tauri-apps/api/core' in tests of document lists.","Don't poll memory endpoints from browser-only builds.","Load after core readiness to avoid the bootstrap gap."],"tags":["tauri","ipc","environment-guard","memory","typescript"],"backgroundTag":"tauri-runtime-not-detected","analyzedSha":"749120085864ce16e0f273c7b86fac7740b39c5b","analyzedAt":"2026-08-17T21:21:45.363Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}