{"record":{"id":"2ef18e895fcbec30","repo":"different-ai/openwork","slug":"settings-environment-apply-unavailable-2ef18e","errorCode":null,"errorMessage":"settings.environment.apply_unavailable","messagePattern":"settings\\.environment\\.apply_unavailable","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"apps/app/src/react-app/shell/settings-route.tsx","lineNumber":2209,"sourceCode":"      notifyAlert({\n        kind: \"system\",\n        title: notFoundRouteError,\n        dedupeKey: \"workspace-not-found\",\n      });\n    }\n  }, [notFoundRouteError]);\n  const routeOpenworkCapabilities: OpenworkServerCapabilities | null = openworkClient\n    ? ROUTE_OPENWORK_CAPABILITIES\n    : null;\n  const environmentRuntimeKey = buildOpenworkEnvRuntimeKey({\n    baseUrl: openworkServerSnapshot.openworkServerBaseUrl || openworkServerSnapshot.openworkServerUrl,\n    pid: openworkServerSnapshot.openworkServerHostInfo?.pid ?? null,\n    port: openworkServerSnapshot.openworkServerHostInfo?.port ?? null,\n  });\n\n  const handleApplyEnvironmentChanges = async () => {\n    if (!isDesktopRuntime()) {\n      throw new Error(t(\"settings.environment.apply_unavailable\"));\n    }\n    if (activeReloadBlockingSessions.length > 0) {\n      throw new Error(t(\"settings.environment.apply_blocked_active_tasks\"));\n    }\n    if (!selectedWorkspaceRoot) {\n      throw new Error(t(\"settings.environment.apply_no_local_workspace\"));\n    }\n    const workspacePaths = Array.from(\n      new Set(\n        workspaces.flatMap((workspace) => {\n          const path = workspace.workspaceType !== \"remote\" ? workspace.path?.trim() ?? \"\" : \"\";\n          return path ? [path] : [];\n        }),\n      ),\n    );\n    const workspacePathSet = new Set(workspacePaths);\n    if (!workspacePathSet.has(selectedWorkspaceRoot)) {\n      workspacePaths.unshift(selectedWorkspaceRoot);","sourceCodeStart":2191,"sourceCodeEnd":2227,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/app/src/react-app/shell/settings-route.tsx#L2191-L2227","documentation":"handleApplyEnvironmentChanges only supports applying environment changes in the desktop runtime, where the app can mutate the local environment and reload the server. In the web runtime the i18n key settings.environment.apply_unavailable is thrown to signal the operation is not supported there.","triggerScenarios":"Clicking 'Apply environment changes' in Settings while the app runs in the browser (isDesktopRuntime() === false).","commonSituations":"Using the web/headless deployment and expecting desktop-only environment mutation; testing the settings UI without the Electron shell.","solutions":["Use the OpenWork desktop app to apply environment changes.","In web deployments, hide/disable the apply-environment control instead of invoking it.","Set environment variables directly on the web server host and restart it."],"exampleFix":"// before\nconst handleApplyEnvironmentChanges = async () => {\n  if (!isDesktopRuntime()) throw new Error(t(\"settings.environment.apply_unavailable\"));\n// after\nconst handleApplyEnvironmentChanges = async () => {\n  if (!isDesktopRuntime()) { toast(t(\"settings.environment.apply_unavailable\")); return; }","handlingStrategy":"validation","validationCode":"if (!isDesktopRuntime()) {\n  showNotice(t(\"settings.environment.apply_unavailable\"));\n  return; // do not call handleApplyEnvironmentChanges\n}","typeGuard":"const isDesktop = (): boolean => isDesktopRuntime(); // narrow runtime before enabling apply UI","tryCatchPattern":"try {\n  await handleApplyEnvironmentChanges();\n} catch (e) {\n  if (e instanceof Error && e.message === t(\"settings.environment.apply_unavailable\")) {\n    // desktop-only: hide the control in web builds\n  } else throw e;\n}","preventionTips":["Render the apply-environment control only when isDesktopRuntime() is true.","Document that environment mutation is desktop-only.","Add a runtime check in tests covering the web path.","Prefer disabling UI over throwing from handlers."],"tags":["desktop-only","environment","unsupported-runtime"],"backgroundTag":"desktop-only-feature","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}