{"record":{"id":"4be0bfb1b29b6dab","repo":"different-ai/openwork","slug":"settings-environment-apply-blocked-active-tasks","errorCode":"settings.environment.apply_blocked_active_tasks","errorMessage":"t(\"settings.environment.apply_blocked_active_tasks\")","messagePattern":"t\\(\"settings\\.environment\\.apply_blocked_active_tasks\"\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"apps/app/src/react-app/shell/session-route.tsx","lineNumber":647,"sourceCode":"    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,\n    exportWorkspaceBusy: false,\n    openLink: (url) => platform.openLink(url),\n    workspaceLabel,","sourceCodeStart":629,"sourceCodeEnd":665,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/app/src/react-app/shell/session-route.tsx#L629-L665","documentation":"handleApplyEnvironmentChanges (session-route.tsx:642) refuses to apply environment variable changes while sessions are still running. activeReloadBlockingSessions lists sessions whose tasks would be disrupted by reloading the workspace engine, so the UI throws this localized error instead of silently restarting under active work. It is a deliberate guard, not a malfunction.","triggerScenarios":"Clicking 'Apply' on the Environment settings panel while activeReloadBlockingSessions.length > 0 — i.e. one or more sessions have running agent tasks that block an engine reload.","commonSituations":"A user edits env vars in Settings while a long-running coding task is executing in another session/tab; the apply is blocked until those tasks finish or are stopped. Common with background agents, scheduled automations, or a stuck session that never finishes.","solutions":["Stop or wait for the active sessions listed as blocking reload, then click Apply again","Open each blocking session and cancel its running task if the new env vars are urgent","Restart the app after stopping tasks so the environment is picked up on startup"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (activeReloadBlockingSessions.length > 0) {\n  // surface a notice instead of calling apply\n  notify(\"Stop active tasks before applying environment changes.\");\n  return;\n}\nawait handleApplyEnvironmentChanges();","typeGuard":null,"tryCatchPattern":"try {\n  await handleApplyEnvironmentChanges();\n} catch (e) {\n  if (String(e.message).includes(\"apply_blocked_active_tasks\")) {\n    showBlockingSessionsDialog(activeReloadBlockingSessions);\n  }\n}","preventionTips":["Check activeReloadBlockingSessions before showing the Apply button enabled state","Prompt users to stop running tasks before editing environment variables","Show which sessions are blocking directly in the settings panel"],"tags":["ui","settings","environment","concurrency"],"backgroundTag":"environment-apply-blocked-by-active-tasks","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}