{"record":{"id":"c13fda82cf8567ac","repo":"different-ai/openwork","slug":"app-error-connect-first-c13fda","errorCode":"app.error_connect_first","errorMessage":"t(\"app.error_connect_first\")","messagePattern":"t\\(\"app\\.error_connect_first\"\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/app/src/react-app/shell/session-route.tsx","lineNumber":654,"sourceCode":"      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,\n  });\n\n\n  const remoteWorkspaceConnectionEditor = useRemoteWorkspaceConnectionEditor({\n    workspaces,\n    client,\n    onSaved: handleRemoteWorkspaceConnectionSaved,","sourceCodeStart":636,"sourceCodeEnd":672,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/app/src/react-app/shell/session-route.tsx#L636-L672","documentation":"After preconditions pass, the handler calls reloadWorkspaceEngineFromUi(); a falsy return means the workspace engine could not be reloaded, typically because the app is not connected to the OpenWork/opencode server. The UI then throws this localized 'connect first' error rather than proceeding silently disconnected.","triggerScenarios":"Clicking 'Apply' in Environment settings while reloadWorkspaceEngineFromUi() resolves false — the server/engine client is disconnected, crashed, or not yet started.","commonSituations":"The local openwork-server process exited; user restarted the app offline; connection was lost mid-session (server crashed or port changed); applying env vars right after startup before the engine connects.","solutions":["Reconnect the server (Account/Settings → reconnect, or restart the desktop app)","Check that the local openwork-server process is running and the port matches the saved config","Retry the environment apply after the connection indicator shows connected"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const connected = await checkServerConnection();\nif (!connected) {\n  notify(\"Reconnect the OpenWork server before applying changes.\");\n  return;\n}\nawait handleApplyEnvironmentChanges();","typeGuard":null,"tryCatchPattern":"try {\n  await handleApplyEnvironmentChanges();\n} catch (e) {\n  if (String(e.message).includes(\"error_connect_first\")) {\n    await reconnectServer();\n    await handleApplyEnvironmentChanges();\n  }\n}","preventionTips":["Surface server connection status near the Apply button","Auto-reconnect with backoff before allowing settings mutations","Monitor the openwork-server process health"],"tags":["ui","connection","server","environment"],"backgroundTag":"server-not-connected","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}