{"record":{"id":"fd5406af191a22e2","repo":"different-ai/openwork","slug":"agent-diagnostics-require-a-connected-workspace","errorCode":null,"errorMessage":"Agent diagnostics require a connected workspace.","messagePattern":"Agent diagnostics require a connected workspace\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/app/src/react-app/shell/settings-route.tsx","lineNumber":2169,"sourceCode":"    cloudSession.baseUrl,\n    cloudSession.isSignedIn,\n    cloudSession.user?.id,\n    diagnosticsClient,\n    diagnosticsWorkspaceType,\n    runtimeWorkspaceId,\n    selectedWorkspaceEndpoint?.token,\n    token,\n  ]);\n  const runAgentContextDiagnostics = useCallback(async () => {\n    const client = selectedWorkspaceEndpoint?.client ?? openworkClient;\n    const workspaceId = runtimeWorkspaceId?.trim() ?? \"\";\n    if (\n      !client\n      || !workspaceId\n      || !selectedWorkspace\n      || !isAgentContextDiagnosticsWorkspaceAllowed(selectedWorkspace)\n    ) {\n      throw new Error(\"Agent diagnostics require a connected workspace.\");\n    }\n    const observations = await collectAgentContextDiagnosticObservations({\n      organizationConnections: orgMcpConnections.connections,\n      organizationConnectionsProbe,\n      workspaceType: selectedWorkspace.workspaceType,\n    });\n    return client.runAgentContextDiagnostics(workspaceId, observations);\n  }, [\n    openworkClient,\n    organizationConnectionsProbe,\n    orgMcpConnections.connections,\n    runtimeWorkspaceId,\n    selectedWorkspace,\n    selectedWorkspaceEndpoint,\n  ]);\n  const routeOpenworkStatus = openworkClient ? \"connected\" : \"disconnected\";\n  const notFoundRouteError = !loading && routeWorkspaceId && !selectedWorkspace\n    ? \"Workspace was not found. Select a new workspace from the sidebar.\"","sourceCodeStart":2151,"sourceCodeEnd":2187,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/app/src/react-app/shell/settings-route.tsx#L2151-L2187","documentation":"The agent-context diagnostics collector requires an authenticated client, a selected workspaceId, a selected workspace record, and that the workspace passes isAgentContextDiagnosticsWorkspaceAllowed (e.g., a connected workspace type eligible for diagnostics). Any missing precondition aborts before collectAgentContextDiagnosticObservations.","triggerScenarios":"Opening/refreshing the agent diagnostics panel while no workspace is selected, the OpenWork client is null (server disconnected), or the selected workspace's type is not allowed for agent-context diagnostics (e.g., disconnected or unsupported workspace kind).","commonSituations":"Landing on Settings before choosing a workspace; server dropped so `client` became null; selecting a workspace type excluded from diagnostics allow-list.","solutions":["Select a connected workspace in Settings before opening agent diagnostics.","Reconnect the OpenWork server so a client instance exists.","Verify the selected workspace passes isAgentContextDiagnosticsWorkspaceAllowed (check its workspaceType); switch to an allowed workspace."],"exampleFix":"// before\nconst observations = await collectAgentContextDiagnosticObservations({...});\n// after\nif (!client || !workspaceId || !selectedWorkspace) return null;\nconst observations = await collectAgentContextDiagnosticObservations({...});","handlingStrategy":"validation","validationCode":"const ready = Boolean(client && workspaceId && selectedWorkspace && isAgentContextDiagnosticsWorkspaceAllowed(selectedWorkspace));\nif (!ready) return null; // render 'select a workspace' state instead of running diagnostics","typeGuard":"function diagnosticsReady(ws: WorkspaceInfo | null, c: unknown, id: string | null)\n  : ws is WorkspaceInfo {\n  return c !== null && typeof id === \"string\" && ws !== null\n    && isAgentContextDiagnosticsWorkspaceAllowed(ws);\n}","tryCatchPattern":"try {\n  await runAgentDiagnostics();\n} catch (e) {\n  if (e instanceof Error && e.message === \"Agent diagnostics require a connected workspace.\") {\n    setDiagnosticsUiState(\"needs-workspace\");\n  } else throw e;\n}","preventionTips":["Gate the diagnostics panel on canInspect like conditions (client && selectedWorkspaceId && allowed).","Re-check client liveness before each diagnostics run.","Restrict the workspace selector to diagnostics-allowed types.","Handle server disconnects by resetting selection state."],"tags":["diagnostics","workspace-selection","precondition"],"backgroundTag":"workspace-not-connected","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}