{"record":{"id":"e3cec681c708e9d9","repo":"different-ai/openwork","slug":"settings-environment-apply-blocked-active-tasks-e3cec6","errorCode":null,"errorMessage":"settings.environment.apply_blocked_active_tasks","messagePattern":"settings\\.environment\\.apply_blocked_active_tasks","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"apps/app/src/react-app/shell/settings-route.tsx","lineNumber":2212,"sourceCode":"        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);\n    }\n    await engineStart(selectedWorkspaceRoot, {\n      preferSidecar: true,","sourceCodeStart":2194,"sourceCodeEnd":2230,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/app/src/react-app/shell/settings-route.tsx#L2194-L2230","documentation":"Before applying environment changes the app restarts the local server, which would kill running sessions. If any sessions in activeReloadBlockingSessions are still active, the apply is blocked and this i18n message is thrown to protect in-flight agent tasks.","triggerScenarios":"Clicking 'Apply environment changes' on desktop while at least one session appears in activeReloadBlockingSessions (an active task/session that cannot survive a server reload).","commonSituations":"Editing environment variables while an agent session is streaming; long-running automation triggered during apply; stale session list showing finished sessions as active.","solutions":["Wait for or stop/cancel the active sessions listed, then retry applying environment changes.","Refresh the session list if activeReloadBlockingSessions is stale and no tasks are actually running.","Schedule the environment change for when no sessions are active."],"exampleFix":"// before\nif (activeReloadBlockingSessions.length > 0) {\n  throw new Error(t(\"settings.environment.apply_blocked_active_tasks\"));\n}\n// after\nif (activeReloadBlockingSessions.length > 0) {\n  await Promise.all(activeReloadBlockingSessions.map((s) => stopSession(s.id)));\n}","handlingStrategy":"validation","validationCode":"if (activeReloadBlockingSessions.length > 0) {\n  confirmDialog(t(\"settings.environment.apply_blocked_active_tasks\"), {\n    action: () => Promise.all(activeReloadBlockingSessions.map((s) => stopSession(s.id)))\n      .then(() => handleApplyEnvironmentChanges()),\n  });\n  return;\n}","typeGuard":"const hasBlockingSessions = (s: Session[]) => s.length > 0; // narrow before allowing apply","tryCatchPattern":"try {\n  await handleApplyEnvironmentChanges();\n} catch (e) {\n  if (e instanceof Error && e.message === t(\"settings.environment.apply_blocked_active_tasks\")) {\n    promptStopActiveSessionsThenRetry();\n  } else throw e;\n}","preventionTips":["Show active blocking sessions on the environment settings screen.","Refresh session liveness before applying (drop stale entries).","Offer one-click stop-and-apply flow.","Warn users before starting long sessions that block environment applies."],"tags":["environment","active-sessions","blocked-operation"],"backgroundTag":"operation-blocked-active-sessions","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}