{"record":{"id":"b9b1659c94be46c1","repo":"tinyhumansai/openhuman","slug":"not-running-in-tauri-b9b165","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/conscious.ts","lineNumber":19,"sourceCode":"/**\n * Conscious loop commands.\n */\n// `safeInvoke` (aliased to `invoke`) replaces bare\n// `@tauri-apps/api/core::invoke` so the CEF `window.ipc.postMessage`\n// synchronous throw (Sentry TAURI-REACT-7 / TAURI-REACT-6) lands as a\n// rejected Promise instead of escaping to `onunhandledrejection`.\nimport { safeInvoke as invoke, isTauri } from './common';\n\n/**\n * Trigger a conscious loop run manually.\n */\nexport async function consciousLoopRun(\n  authToken: string,\n  backendUrl: string,\n  model?: string\n): Promise<void> {\n  if (!isTauri()) {\n    throw new Error('Not running in Tauri');\n  }\n  await invoke('conscious_loop_run', { authToken, backendUrl, model });\n}\n","sourceCodeStart":1,"sourceCodeEnd":23,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/a221052e0df5b1f7598fceba7329fd1af95d6699/app/src/utils/tauriCommands/conscious.ts#L1-L23","documentation":"consciousLoopRun manually triggers a conscious-loop run by invoking the `conscious_loop_run` Tauri command directly (via safeInvoke) with authToken/backendUrl/model — unlike the core-RPC wrappers, this is a shell command, not an openhuman.* JSON-RPC method. The guard throws when isTauri() is false because Tauri commands cannot be invoked outside the webview shell; the file's header comment notes the intent is a rejected Promise rather than an escape to onunhandledrejection. safeInvoke additionally classifies CEF bridge failures as IpcUnavailableError, but the guard here fires before invoke is reached.","triggerScenarios":"Clicking a 'run conscious loop now' action while the UI runs under `pnpm dev`; invoking the helper from a Vitest test without mocking @tauri-apps/api/core; the action firing during the CEF bootstrap gap.","commonSituations":"Manual-trigger buttons developed/tested in browser mode; auth-token-bearing actions attempted outside the shell where no Tauri command registry exists.","solutions":["Run the desktop dev host (`pnpm dev:app`) to exercise the conscious loop trigger.","Gate the button/action on isTauri() and hide or disable it in browser mode.","Catch the rejection and report 'available in the desktop app' instead of a raw error.","In tests, mock the conscious module or @tauri-apps/api/core invoke."],"exampleFix":"// before\nawait consciousLoopRun(authToken, backendUrl, model);\n\n// after\nif (!isTauri()) {\n  showToast('Conscious loop runs inside the desktop app');\n  return;\n}\nawait consciousLoopRun(authToken, backendUrl, model);","handlingStrategy":"validation","validationCode":"import { isTauri } from './common';\n\nif (!isTauri()) {\n  showToast('Conscious loop runs inside the desktop app');\n  return;\n}\nawait consciousLoopRun(authToken, backendUrl, model);","typeGuard":"function isNotRunningInTauriError(err: unknown): err is Error {\n  return err instanceof Error && err.message === 'Not running in Tauri';\n}","tryCatchPattern":"try {\n  await consciousLoopRun(authToken, backendUrl, model);\n} catch (err) {\n  if (err instanceof Error && err.message === 'Not running in Tauri') return;\n  if (err instanceof IpcUnavailableError) return; // CEF bridge gap\n  throw err;\n}","preventionTips":["Hide manual-trigger actions outside the desktop shell.","Remember this wrapper is a direct Tauri command (conscious_loop_run), not core JSON-RPC — it still needs isTauri().","Also handle IpcUnavailableError from safeInvoke for the CEF bridge-gap variant."],"tags":["tauri","ipc","environment-guard","conscious-loop","manual-action"],"backgroundTag":null,"analyzedSha":"a221052e0df5b1f7598fceba7329fd1af95d6699","analyzedAt":"2026-08-16T12:47:06.542Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}