{"record":{"id":"16d71f0ac191a869","repo":"stablyai/orca","slug":"choose-another-active-server-in-advanced-before-re","errorCode":null,"errorMessage":"Choose another Active Server in Advanced before removing this server.","messagePattern":"Choose another Active Server in Advanced before removing this server\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/ipc/runtime-environment-connectivity-handlers.ts","lineNumber":88,"sourceCode":"  ipcMain.handle(\n    'runtimeEnvironments:verifyAndAddFromPairingCode',\n    async (_event, args: { name: string; pairingCode: string; allowLoopback?: boolean }) => {\n      const result = await verifyAndAddRuntimeEnvironmentFromPairingCode(getUserDataPath(), args)\n      if (result.ok) {\n        manuallyDisconnectedEnvironmentIds.delete(result.environment.id)\n      }\n      return result\n    }\n  )\n  ipcMain.handle('runtimeEnvironments:resolve', (_event, args: { selector: string }) =>\n    redactRuntimeEnvironment(resolveEnvironment(getUserDataPath(), args.selector))\n  )\n  ipcMain.handle(\n    'runtimeEnvironments:remove',\n    (_event, args: { selector: string }): { removed: PublicKnownRuntimeEnvironment } => {\n      const environment = resolveEnvironment(getUserDataPath(), args.selector)\n      if (store.getSettings().activeRuntimeEnvironmentId === environment.id) {\n        throw new Error('Choose another Active Server in Advanced before removing this server.')\n      }\n      const removed = removeEnvironment(getUserDataPath(), args.selector)\n      manuallyDisconnectedEnvironmentIds.delete(removed.id)\n      invalidateTransport(removed.id)\n      closeLegacySelectorTransport(args.selector, removed.id)\n      return { removed: redactRuntimeEnvironment(removed) }\n    }\n  )\n  ipcMain.handle(\n    'runtimeEnvironments:disconnect',\n    (_event, args: { selector: string }): { disconnected: PublicKnownRuntimeEnvironment } => {\n      const environment = resolveEnvironment(getUserDataPath(), args.selector)\n      manuallyDisconnectedEnvironmentIds.add(environment.id)\n      invalidateTransport(environment.id)\n      closeLegacySelectorTransport(args.selector, environment.id)\n      return { disconnected: redactRuntimeEnvironment(environment) }\n    }\n  )","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/ipc/runtime-environment-connectivity-handlers.ts#L70-L106","documentation":"Thrown by the runtimeEnvironments:remove handler when the environment being removed is currently selected as the Active Server (store.getSettings().activeRuntimeEnvironmentId === environment.id). Removing it would leave the app pointed at a non-existent server, so the user must first switch the Active Server preference to another environment (or to null) in Advanced settings.","triggerScenarios":"User opens server management, selects the currently-active server, and clicks Remove without first changing the Active Server dropdown. The guard blocks the removal to prevent an invalid active preference.","commonSituations":"Cleaning up old/test servers while one of them is still the active target; reorganizing servers after a migration; forgetting that the active server is the one being deleted.","solutions":["Before calling remove, set the Active Server preference to another environment via settings:set-active-runtime-environment-preference (or to null).","In the UI, disable Remove for the active server, or auto-offer to switch active first.","After removal, confirm the new active server connects before continuing.","If only one server exists, set the preference to null before removing it."],"exampleFix":"// before\nawait ipc.invoke('runtimeEnvironments:remove', { selector })\n\n// after\nif (activeId === envToRemove.id) {\n  await ipc.invoke('settings:set-active-runtime-environment-preference', {\n    environmentId: fallbackEnvId ?? null,\n  })\n}\nawait ipc.invoke('runtimeEnvironments:remove', { selector })","handlingStrategy":"validation","validationCode":"const settings = await ipc.invoke('settings:get')\nif (settings.activeRuntimeEnvironmentId === envToRemove.id) {\n  await ipc.invoke('settings:set-active-runtime-environment-preference', {\n    environmentId: fallbackId ?? null,\n  })\n}\nawait ipc.invoke('runtimeEnvironments:remove', { selector })","typeGuard":"function isActiveServer(envId: string, activeId: string | null | undefined): boolean {\n  return activeId === envId\n}","tryCatchPattern":"try {\n  await ipc.invoke('runtimeEnvironments:remove', { selector })\n} catch (e) {\n  if (/Active Server/i.test((e as Error).message)) {\n    promptSwitchActiveServer(envToRemove)\n  } else throw e\n}","preventionTips":["Disable Remove for the active server, or offer to switch first.","When only one server exists, set the preference to null before removing it.","Confirm the new active server connects after the switch."],"tags":["ipc","runtime-environment","settings","active-server","guard"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}