different-ai/openwork · error

settings.environment.apply_unavailable

settings.environment.apply_unavailable

Error message

t("settings.environment.apply_unavailable")

What it means

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.

Source

Thrown at apps/app/src/react-app/shell/session-route.tsx:644

    workspace: selectedWorkspace,
    endpointForWorkspace,
    activeReloadBlockingSessions,
    onError: setRouteError,
    refreshRouteState,
  });

  const environmentRuntimeKey = useMemo(
    () => buildOpenworkEnvRuntimeKey({
      baseUrl: client?.baseUrl ?? null,
      pid: openworkServerHostInfoState?.pid ?? null,
      port: openworkServerHostInfoState?.port ?? null,
    }),
    [client?.baseUrl, openworkServerHostInfoState?.pid, openworkServerHostInfoState?.port],
  );

  const handleApplyEnvironmentChanges = useCallback(async () => {
    if (!isDesktopRuntime()) {
      throw new Error(t("settings.environment.apply_unavailable"));
    }
    if (activeReloadBlockingSessions.length > 0) {
      throw new Error(t("settings.environment.apply_blocked_active_tasks"));
    }
    if (!selectedWorkspaceRoot) {
      throw new Error(t("settings.environment.apply_no_local_workspace"));
    }
    const reloaded = await reloadWorkspaceEngineFromUi();
    if (!reloaded) {
      throw new Error(t("app.error_connect_first"));
    }
  }, [activeReloadBlockingSessions.length, reloadWorkspaceEngineFromUi, selectedWorkspaceRoot]);

  const shareWorkspaceState = useShareWorkspaceState({
    workspaces,
    openworkServerHostInfo: openworkServerHostInfoState,
    openworkServerSettings,
    engineInfo: routeEngineInfo,

View on GitHub (pinned to 2b7df46e8a)

Solutions

  1. Use the desktop app to apply environment changes
  2. On remote/server runtimes, restart the server manually then reload
  3. Update pending changes so they take effect on next manual restart instead of auto-apply

Example fix

// before
await handleApplyEnvironmentChanges(); // web runtime
// after
if (isDesktopRuntime()) await handleApplyEnvironmentChanges();
Defensive patterns

Strategy: validation

Validate before calling

if (!isDesktopRuntime()) {
  showToast(t("settings.environment.apply_unavailable"));
  return;
}
await handleApplyEnvironmentChanges();

Try / catch

try {
  await handleApplyEnvironmentChanges();
} catch (e) {
  if ((e as Error).message.includes("apply_unavailable")) showDesktopOnlyNotice();
  else throw e;
}

Prevention

When it happens

Trigger: Calling handleApplyEnvironmentChanges while isDesktopRuntime() is false — e.g. using the web/headless build or a remote cloud workspace and clicking Apply environment changes.

Common situations: 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.

Related errors


AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01). Data as JSON: /api/errors/7ea670bda36ab0bf. Report an issue: GitHub.