{"record":{"id":"3f5dd318d182ba10","repo":"different-ai/openwork","slug":"electron-eval-relaunch-helper-is-unavailable","errorCode":null,"errorMessage":"Electron eval relaunch helper is unavailable.","messagePattern":"Electron eval relaunch helper is unavailable\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/app/src/app/lib/desktop.ts","lineNumber":535,"sourceCode":"  const result = await invokeElectronHelper(\"__applyBrandAppName\", appName);\n  return result.appName;\n}\n\nexport async function applyBrandIcon(url: string | null): Promise<BrandIconApplyResult> {\n  const apply = typeof window !== \"undefined\" ? window.__OPENWORK_ELECTRON__?.brandIcon?.apply : undefined;\n  if (!apply) return { ok: false, reason: \"bridge-unavailable\" };\n  return apply(url);\n}\n\nexport async function getBrandIconState(): Promise<BrandIconState | null> {\n  const getState = typeof window !== \"undefined\" ? window.__OPENWORK_ELECTRON__?.brandIcon?.getState : undefined;\n  return getState ? getState() : null;\n}\n\nexport async function evalRelaunchDesktopApp(): Promise<EvalRelaunchResult> {\n  const relaunch = typeof window !== \"undefined\" ? window.__OPENWORK_ELECTRON__?.dev?.evalRelaunch : undefined;\n  if (!relaunch) {\n    throw new Error(\"Electron eval relaunch helper is unavailable.\");\n  }\n  return relaunch();\n}\n\nexport type DesktopApplication = {\n  name: string;\n  appPath: string;\n  icon: string | null;\n};\n\nexport async function getDesktopApplicationsForFile(target: string): Promise<DesktopApplication[]> {\n  return invokeElectronHelper(\"__getApplicationsForFile\", target);\n}\n\nexport async function openDesktopWithApp(target: string, appPath: string): Promise<void> {\n  const result = await invokeElectronHelper(\"__openWithApp\", target, appPath);\n  if (typeof result === \"string\" && result.trim()) {\n    throw new Error(result);","sourceCodeStart":517,"sourceCodeEnd":553,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/app/src/app/lib/desktop.ts#L517-L553","documentation":"evalRelaunchDesktopApp uses the dev-only bridge API `window.__OPENWORK_ELECTRON__.dev.evalRelaunch`, which relaunches the app in a controlled way for eval/E2E flows. If that helper is undefined — production builds strip dev APIs, or the app is not the Electron build — the function throws this dedicated message instead of returning a bogus result.","triggerScenarios":"Calling evalRelaunchDesktopApp (e.g. from relaunchAction) when `window.__OPENWORK_ELECTRON__` is undefined, the preload does not expose the `dev.evalRelaunch` namespace, or the desktop app is a production build where the dev-only relaunch helper is omitted.","commonSituations":"Running an eval/E2E test suite against a packaged production app that lacks the dev bridge; running the web build locally where no bridge exists at all; an Electron preload updated so dev APIs moved or were renamed; invoking relaunch from the UI in a store/distribution build instead of the dev build.","solutions":["Use the development Electron build that exposes `dev.evalRelaunch` for eval/test runs.","In production flows call the stable `relaunchDesktopApp()` (shell.relaunch) instead of the eval helper.","Guard the caller: check `window.__OPENWORK_ELECTRON__?.dev?.evalRelaunch` first and fall back to the standard relaunch or surface 'not supported in this build'.","In tests, polyfill the dev bridge: `window.__OPENWORK_ELECTRON__.dev = { evalRelaunch: async () => ({ ... }) }`."],"exampleFix":"// before\nawait evalRelaunchDesktopApp();\n\n// after\nif (window.__OPENWORK_ELECTRON__?.dev?.evalRelaunch) {\n  await evalRelaunchDesktopApp();\n} else {\n  await relaunchDesktopApp();\n}","handlingStrategy":"fallback","validationCode":"const hasEvalRelaunch = typeof window !== \"undefined\" && typeof window.__OPENWORK_ELECTRON__?.dev?.evalRelaunch === \"function\";","typeGuard":"function supportsEvalRelaunch(w: Window): boolean {\n  return typeof w.__OPENWORK_ELECTRON__?.dev?.evalRelaunch === \"function\";\n}","tryCatchPattern":"try {\n  await evalRelaunchDesktopApp();\n} catch (err) {\n  if (err instanceof Error && err.message.includes(\"eval relaunch helper is unavailable\")) {\n    await relaunchDesktopApp(); // production-safe path\n  } else { throw err; }\n}","preventionTips":["Only use evalRelaunch in dev/E2E builds; detect build mode before calling.","Stub window.__OPENWORK_ELECTRON__.dev.evalRelaunch in test harnesses.","Always provide the production relaunchDesktopApp() as the fallback flow.","Re-check dev API shape after every preload script change."],"tags":["electron","dev-only-api","relaunch","eval-testing"],"backgroundTag":"electron-dev-api-unavailable","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}