{"record":{"id":"c5e3200096212b8d","repo":"different-ai/openwork","slug":"t-providers-not-connected","errorCode":null,"errorMessage":"t(\"providers.not_connected\")","messagePattern":"t\\(\"providers\\.not_connected\"\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/app/src/react-app/domains/connections/provider-auth/store.ts","lineNumber":1383,"sourceCode":"      if (!isOpenAiProvider) continue;\n      merged[id] = providerMethods.filter((method) => {\n        if (method.type !== \"oauth\") return true;\n        // Browser mode can't complete the ChatGPT sign-in flows, so only API keys\n        // are offered off-desktop.\n        if (!isDesktopRuntime()) return false;\n        const label = method.label.toLowerCase();\n        const isHeadless = /headless|device/.test(label);\n        return workerType === \"remote\" ? isHeadless : !isHeadless;\n      });\n    }\n\n    return merged;\n  };\n\n  const loadProviderAuthMethods = async (workerType: \"local\" | \"remote\") => {\n    const c = options.client();\n    if (!c) {\n      throw new Error(t(\"providers.not_connected\"));\n    }\n    const methods = unwrap(await c.provider.auth());\n    return buildProviderAuthMethods(\n      methods as Record<string, ProviderAuthMethod[]>,\n      getProviderAuthProviders(),\n      workerType,\n    );\n  };\n\n  async function startProviderAuth(\n    providerId?: string,\n    methodIndex?: number,\n  ): Promise<ProviderOAuthStartResult> {\n    setStateField(\"providerAuthError\", null);\n    const c = options.client();\n    if (!c) {\n      throw new Error(t(\"providers.not_connected\"));\n    }","sourceCodeStart":1365,"sourceCodeEnd":1401,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/app/src/react-app/domains/connections/provider-auth/store.ts#L1365-L1401","documentation":"loadProviderAuthMethods fetches the available provider auth methods from the connected opencode server via c.provider.auth(). If options.client() returns null there is no server connection at all, so the store throws providers.not_connected before any request is made. This is the store's way of saying \"connect to a server first\".","triggerScenarios":"Calling loadProviderAuthMethods (directly or via startProviderOAuth when the providerAuthMethods cache is empty) while options.client() returns null — i.e. the app has no active server/client session.","commonSituations":"App started before the local openwork-server is up; server connection dropped or the session was closed; opening the providers/connections screen before sign-in; client factory (options.client) not wired to a live connection.","solutions":["Start/connect the opencode server (or launch via pnpm world up dev-headless) before loading provider auth methods.","Re-establish the client connection and retry; ensure options.client() resolves to a live client.","Check initialization order so UI screens call this only after the connection is ready.","If the connection was dropped, reconnect the session and re-open the connections panel."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const client = options.client();\nif (!client) {\n  showToast(t(\"providers.not_connected\"));\n  return;\n}\nawait loadProviderAuthMethods(workerType);","typeGuard":"function hasClient<T>(client: T | null | undefined): client is T {\n  return client != null;\n}","tryCatchPattern":"try {\n  await store.loadProviderAuthMethods(\"local\");\n} catch (e) {\n  if (e instanceof Error && /not.?connected/i.test(e.message)) {\n    openConnectDialog();\n  } else throw e;\n}","preventionTips":["Gate provider screens/actions behind connection-ready state.","Show a 'Connect to server' empty state instead of calling the store when client is null.","Re-load auth methods after any reconnect event.","Subscribe to connection status in Zustand and disable provider controls when disconnected."],"tags":["connection","lifecycle","provider-auth"],"backgroundTag":"server-not-connected","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}