{"record":{"id":"7ea670bda36ab0bf","repo":"different-ai/openwork","slug":"settings-environment-apply-unavailable","errorCode":"settings.environment.apply_unavailable","errorMessage":"t(\"settings.environment.apply_unavailable\")","messagePattern":"t\\(\"settings\\.environment\\.apply_unavailable\"\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/app/src/react-app/shell/session-route.tsx","lineNumber":644,"sourceCode":"    workspace: selectedWorkspace,\n    endpointForWorkspace,\n    activeReloadBlockingSessions,\n    onError: setRouteError,\n    refreshRouteState,\n  });\n\n  const environmentRuntimeKey = useMemo(\n    () => buildOpenworkEnvRuntimeKey({\n      baseUrl: client?.baseUrl ?? null,\n      pid: openworkServerHostInfoState?.pid ?? null,\n      port: openworkServerHostInfoState?.port ?? null,\n    }),\n    [client?.baseUrl, openworkServerHostInfoState?.pid, openworkServerHostInfoState?.port],\n  );\n\n  const handleApplyEnvironmentChanges = useCallback(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 reloaded = await reloadWorkspaceEngineFromUi();\n    if (!reloaded) {\n      throw new Error(t(\"app.error_connect_first\"));\n    }\n  }, [activeReloadBlockingSessions.length, reloadWorkspaceEngineFromUi, selectedWorkspaceRoot]);\n\n  const shareWorkspaceState = useShareWorkspaceState({\n    workspaces,\n    openworkServerHostInfo: openworkServerHostInfoState,\n    openworkServerSettings,\n    engineInfo: routeEngineInfo,","sourceCodeStart":626,"sourceCodeEnd":662,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/app/src/react-app/shell/session-route.tsx#L626-L662","documentation":"handleApplyEnvironmentChanges in SessionRoute applies pending environment variable changes and reloads sessions, but only on a desktop runtime (local process restart is required). On non-desktop runtimes (web/remote) it throws the localized \"settings.environment.apply_unavailable\" because the apply flow cannot restart a server it does not own.","triggerScenarios":"Calling handleApplyEnvironmentChanges while isDesktopRuntime() is false — e.g. using the web/headless build or a remote cloud workspace and clicking Apply environment changes.","commonSituations":"Running the browser build of OpenWork and trying to apply env changes; cloud workspace where restart must happen server-side; desktop detection misfiring in dev builds.","solutions":["Use the desktop app to apply environment changes","On remote/server runtimes, restart the server manually then reload","Update pending changes so they take effect on next manual restart instead of auto-apply"],"exampleFix":"// before\nawait handleApplyEnvironmentChanges(); // web runtime\n// after\nif (isDesktopRuntime()) await handleApplyEnvironmentChanges();","handlingStrategy":"validation","validationCode":"if (!isDesktopRuntime()) {\n  showToast(t(\"settings.environment.apply_unavailable\"));\n  return;\n}\nawait handleApplyEnvironmentChanges();","typeGuard":null,"tryCatchPattern":"try {\n  await handleApplyEnvironmentChanges();\n} catch (e) {\n  if ((e as Error).message.includes(\"apply_unavailable\")) showDesktopOnlyNotice();\n  else throw e;\n}","preventionTips":["Hide/disable the Apply button on non-desktop runtimes","Check isDesktopRuntime() before offering apply flows","Document that env apply requires a local desktop server restart"],"tags":["environment-variables","desktop-runtime","unsupported-operation"],"backgroundTag":"unsupported-runtime-operation","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}