Skip to content

πŸ™Œ OpenHands: AI-Driven Development

feat: enable LLM provider connections on cloud (#16757)

Juan Pedro Michelini Jorge3469b769c981
diff --git a/__tests__/api/cloud/provider-connections-service.test.ts b/__tests__/api/cloud/provider-connections-service.test.ts
new file mode 100644
index 0000000000..d2a2bced06
--- /dev/null
+++ b/__tests__/api/cloud/provider-connections-service.test.ts
@@ -0,0 +1,140 @@
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import {
+ __resetActiveStoreForTests,
+ setActiveSelection,
+ setRegisteredBackends,
+} from "#/api/backend-registry/active-store";
+import type { Backend } from "#/api/backend-registry/types";
+import ProviderConnectionsService from "#/api/provider-connections-service/provider-connections-service.api";
+import {
+ getFetchCall,
+ getJsonBody,
+ mockJsonResponse,
+} from "./fetch-test-utils";
+
+const cloudBackend: Backend = {
+ id: "prod",
+ name: "Production",
+ host: "https://app.all-hands.dev",
+ apiKey: "bearer-token",
+ kind: "cloud",
+};
+
+const ORG_ID = "org-1";
+const BASE = `https://app.all-hands.dev/api/organizations/${ORG_ID}/provider-connections`;
+const originalFetch = global.fetch;
+const fetchMock = vi.fn();
+
+const connection = {
+ id: "conn-1",
+ display_name: "My OpenAI",
+ provider: "openai",
+ base_url: null,
+ created_at: 1,
+ updated_at: 2,
+ api_key_set: true,
+};
+
+beforeEach(() => {
+ window.localStorage.clear();
+ __resetActiveStoreForTests();
+ setRegisteredBackends([cloudBackend]);
+ fetchMock.mockReset();
+ fetchMock.mockResolvedValue(mockJsonResponse({}));
+ global.fetch = fetchMock as typeof fetch;
+});
+
+afterEach(() => {
+ window.localStorage.clear();
+ __resetActiveStoreForTests();
+ fetchMock.mockReset();
+ global.fetch = originalFetch;
+});
+
+// With an org bound, provider-connection CRUD goes through the org-gated routes
+// so the server enforces EDIT_ORG_SETTINGS / VIEW_ORG_SETTINGS.
+describe("ProviderConnectionsService against a cloud org", () => {
+ beforeEach(() => {
+ setActiveSelection({ backendId: cloudBackend.id, orgId: ORG_ID });
+ });
+
+ it("lists connections and unwraps the { connections } envelope", async () => {
+ fetchMock.mockResolvedValueOnce(
+ mockJsonResponse({ connections: [connection] }),
+ );
+
+ const res = await ProviderConnectionsService.list();
+
+ const [url, init] = getFetchCall(fetchMock);
+ expect(url).toBe(BASE);
+ expect(init).toMatchObject({
+ method: "GET",
+ headers: { Authorization: "Bearer bearer-token" },
+ });
+ expect(res).toEqual([connection]);
+ });
+
+ it("returns [] when the org has no connections", async () => {
+ fetchMock.mockResolvedValueOnce(mockJsonResponse({ connections: [] }));
+
+ const res = await ProviderConnectionsService.list();
+
+ expect(res).toEqual([]);
+ });
+
+ it("creates a connection via POST with the request body", async () => {
+ fetchMock.mockResolvedValueOnce(mockJsonResponse(connection));
+
+ const request = {
+ display_name: "My OpenAI",
+ provider: "openai",
+ api_key: "sk-123",
+ base_url: null,
+ };
+ const res = await ProviderConnectionsService.create(request);
+
+ const [url, init] = getFetchCall(fetchMock);
+ expect(url).toBe(BASE);
+ expect(init).toMatchObject({ method: "POST" });
+ expect(getJsonBody(init)).toEqual(request);
+ expect(res).toEqual(connection);
+ });
+
+ it("updates a connection via PATCH at the id-scoped path", async () => {
+ fetchMock.mockResolvedValueOnce(mockJsonResponse(connection));
+
+ const res = await ProviderConnectionsService.update("conn-1", {
+ display_name: "Renamed",
+ });
+
+ const [url, init] = getFetchCall(fetchMock);
+ expect(url).toBe(`${BASE}/conn-1`);
+ expect(init).toMatchObject({ method: "PATCH" });
+ expect(getJsonBody(init)).toEqual({ display_name: "Renamed" });
+ expect(res).toEqual(connection);
+ });
+
+ it("url-encodes the id when deleting", async () => {
+ fetchMock.mockResolvedValueOnce(mockJsonResponse(connection));
+
+ await ProviderConnectionsService.delete("a b/c");
+
+ const [url, init] = getFetchCall(fetchMock);
+ expect(url).toBe(`${BASE}/a%20b%2Fc`);
+ expect(init).toMatchObject({ method: "DELETE" });
+ });
+});
+
+// Without an org bound (legacy API keys), the org-scoped route is unaddressable.
+describe("ProviderConnectionsService on a cloud backend with no org", () => {
+ beforeEach(() => {
+ setActiveSelection({ backendId: cloudBackend.id });
+ });
+
+ it("throws rather than firing an unaddressable request", async () => {
+ await expect(ProviderConnectionsService.list()).rejects.toThrow(
+ /organization-bound/i,
+ );
+ expect(fetchMock).not.toHaveBeenCalled();
+ });
+});
diff --git a/__tests__/routes/llm-settings.test.tsx b/__tests__/routes/llm-settings.test.tsx
index e56ca03c22..4c84200d05 100644
--- a/__tests__/routes/llm-settings.test.tsx
+++ b/__tests__/routes/llm-settings.test.tsx
@@ -6,6 +6,7 @@ import {
waitFor,
within,
} from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
import { MemoryRouter } from "react-router";
import { beforeEach, describe, expect, it, vi } from "vitest";
// Import the named export LlmSettingsScreen directly for testing the form component.
@@ -414,6 +415,42 @@ describe("LlmSettingsScreen - provider connection selector", () => {
expect(screen.queryByTestId("base-url-input")).not.toBeInTheDocument();
});
+ it("updates form state when a linked provider connection is changed to None", async () => {
+ const user = userEvent.setup();
+ let latestValues: Record<string, string | boolean> = {};
+
+ vi.spyOn(activeBackendContext, "useActiveBackend").mockReturnValue({
+ backend: mockLocalBackend,
+ } as ReturnType<typeof activeBackendContext.useActiveBackend>);
+ vi.spyOn(ProviderConnectionsService, "list").mockResolvedValue([
+ connection,
+ ]);
+
+ renderLlmSettingsScreen({
+ embedded: true,
+ hideSaveButton: true,
+ showProviderConnection: true,
+ initialValueOverrides: {
+ "llm.model": "openai/gpt-4o",
+ "llm.provider_connection_id": "conn-1",
+ },
+ onSaveControlChange: (control) => {
+ latestValues = control.values;
+ },
+ });
+
+ await screen.findByTestId("llm-settings-screen");
+ const selector = await screen.findByTestId("llm-provider-connection-input");
+ expect(selector).toHaveValue("My OpenAI");
+
+ await user.click(selector);
+ await user.click(await screen.findByText("SETTINGS$MCP_AUTH_MODE_NONE"));
+
+ await waitFor(() => {
+ expect(latestValues["llm.provider_connection_id"]).toBe("");
+ });
+ });
+
it("still renders the selector for an orphaned link when no connections load", async () => {
// Regression: a profile linked to a since-deleted connection would hide the
// API key / base URL inputs while also hiding the selector, leaving no way
diff --git a/src/api/cloud/provider-connections-service.api.ts b/src/api/cloud/provider-connections-service.api.ts
new file mode 100644
index 0000000000..5afccd2785
--- /dev/null
+++ b/src/api/cloud/provider-connections-service.api.ts
@@ -0,0 +1,99 @@
+import type {
+ ProviderConnection,
+ CreateProviderConnectionRequest,
+ UpdateProviderConnectionRequest,
+} from "../provider-connections-service/provider-connections-service.api";
+import { getActiveBackend } from "../backend-registry/active-store";
+import type { Backend } from "../backend-registry/types";
+import { callCloudProxy } from "./proxy";
+
+/**
+ * Cloud provider-connections service.
+ *
+ * Provider-connection CRUD is routed to the org-scoped endpoints
+ * `/api/organizations/{orgId}/provider-connections`, which enforce
+ * `EDIT_ORG_SETTINGS` server-side (listing requires `VIEW_ORG_SETTINGS`) β€” so a
+ * member's mutation is rejected with 403 even on a direct API call, not just
+ * hidden in the UI. This mirrors the cloud LLM-profile service.
+ *
+ * Unlike the local agent-server (which returns a bare array), the org list
+ * route wraps results as `{ connections: [...] }`; this service unwraps that so
+ * callers see the same `ProviderConnection[]` shape on both backends. Individual
+ * mutations return a bare `ProviderConnection` on both backends. Neither route
+ * exposes the stored key; each item carries `api_key_set` instead.
+ *
+ * Cloud has no unbound-org fallback here: provider connections are inherently
+ * org-scoped, so an org must be bound. A cloud backend without an org id is a
+ * programming error rather than a legacy-key case.
+ */
+
+interface CloudProviderConnectionListResponse {
+ connections: ProviderConnection[];
+}
+
+/** Resolve the backend + org-scoped base path for the active cloud backend. */
+function cloudProviderConnectionsTarget(): { backend: Backend; base: string } {
+ const { backend, orgId } = getActiveBackend();
+ if (backend.kind !== "cloud") {
+ throw new Error(
+ "Cloud provider-connections call requires a cloud backend.",
+ );
+ }
+ if (!orgId) {
+ throw new Error(
+ "Cloud provider connections require an organization-bound backend.",
+ );
+ }
+ return {
+ backend,
+ base: `/api/organizations/${encodeURIComponent(orgId)}/provider-connections`,
+ };
+}
+
+export async function fetchCloudProviderConnections(): Promise<
+ ProviderConnection[]
+> {
+ const { backend, base } = cloudProviderConnectionsTarget();
+ const result = await callCloudProxy<CloudProviderConnectionListResponse>({
+ backend,
+ method: "GET",
+ path: base,
+ });
+ return result.connections ?? [];
+}
+
+export async function createCloudProviderConnection(
+ request: CreateProviderConnectionRequest,
+): Promise<ProviderConnection> {
+ const { backend, base } = cloudProviderConnectionsTarget();
+ return callCloudProxy<ProviderConnection>({
+ backend,
+ method: "POST",
+ path: base,
+ body: request,
+ });
+}
+
+export async function updateCloudProviderConnection(
+ id: string,
+ request: UpdateProviderConnectionRequest,
+): Promise<ProviderConnection> {
+ const { backend, base } = cloudProviderConnectionsTarget();
+ return callCloudProxy<ProviderConnection>({
+ backend,
+ method: "PATCH",
+ path: `${base}/${encodeURIComponent(id)}`,
+ body: request,
+ });
+}
+
+export async function deleteCloudProviderConnection(
+ id: string,
+): Promise<ProviderConnection> {
+ const { backend, base } = cloudProviderConnectionsTarget();
+ return callCloudProxy<ProviderConnection>({
+ backend,
+ method: "DELETE",
+ path: `${base}/${encodeURIComponent(id)}`,
+ });
+}
diff --git a/src/api/provider-connections-service/provider-connections-service.api.ts b/src/api/provider-connections-service/provider-connections-service.api.ts
index 6126ff3695..b238210e36 100644
--- a/src/api/provider-connections-service/provider-connections-service.api.ts
+++ b/src/api/provider-connections-service/provider-connections-service.api.ts
@@ -1,22 +1,37 @@
/**
- * ProviderConnectionsService is a thin wrapper over the local agent-server's
- * `/api/llm/provider-connections` CRUD endpoints. A provider connection is a
- * shared `api_key` + optional `base_url` that one or more LLM profiles
- * reference by id; the agent-server resolves the credential into a runnable LLM
- * at profile-load time, so this service only manages the stored connections.
+ * ProviderConnectionsService is the single entry point for provider-connection
+ * CRUD, routing per active backend so callers (hooks, the settings manager)
+ * stay backend-agnostic. A provider connection is a shared `api_key` + optional
+ * `base_url` that one or more LLM profiles reference by id; the backend resolves
+ * the credential into a runnable LLM at profile-load time, so this service only
+ * manages the stored connections.
*
- * These endpoints exist only on the agent-server (local backend). Cloud has no
- * equivalent yet, so callers must gate usage on `backend.kind === "local"`.
+ * - local agent-server: the `/api/llm/provider-connections` CRUD endpoints via
+ * the generic `AgentServerClient` verb helpers (the same approach
+ * `LLMBalanceService` uses; there is no generated client for these routes in
+ * `@openhands/typescript-client` yet);
+ * - cloud app-server: `src/api/cloud/provider-connections-service.api.ts` (the
+ * org-gated `/api/organizations/{orgId}/provider-connections` routes) via the
+ * org-scoped cloud proxy.
*
- * There is no generated client for these routes in `@openhands/typescript-client`
- * yet, so requests go through the generic `AgentServerClient` verb helpers β€”
- * the same approach `LLMBalanceService` uses.
+ * This mirrors how `ProfilesService` branches to the cloud profile service.
*/
import { AgentServerClient } from "@openhands/typescript-client/clients";
import { getAgentServerClientOptions } from "../agent-server-client-options";
+import { getActiveBackend } from "../backend-registry/active-store";
+import {
+ fetchCloudProviderConnections,
+ createCloudProviderConnection,
+ updateCloudProviderConnection,
+ deleteCloudProviderConnection,
+} from "../cloud/provider-connections-service.api";
const PROVIDER_CONNECTIONS_PATH = "/api/llm/provider-connections";
+function isCloudBackend(): boolean {
+ return getActiveBackend().backend.kind === "cloud";
+}
+
export interface ProviderConnection {
id: string;
display_name: string;
@@ -54,6 +69,7 @@ function createClient(): AgentServerClient {
class ProviderConnectionsService {
static async list(): Promise<ProviderConnection[]> {
+ if (isCloudBackend()) return fetchCloudProviderConnections();
const client = createClient();
try {
return await client.get<ProviderConnection[]>(PROVIDER_CONNECTIONS_PATH, {
@@ -67,6 +83,7 @@ class ProviderConnectionsService {
static async create(
request: CreateProviderConnectionRequest,
): Promise<ProviderConnection> {
+ if (isCloudBackend()) return createCloudProviderConnection(request);
const client = createClient();
try {
return await client.post<ProviderConnection>(
@@ -83,6 +100,7 @@ class ProviderConnectionsService {
id: string,
request: UpdateProviderConnectionRequest,
): Promise<ProviderConnection> {
+ if (isCloudBackend()) return updateCloudProviderConnection(id, request);
const client = createClient();
try {
return await client.patch<ProviderConnection>(
@@ -96,6 +114,7 @@ class ProviderConnectionsService {
}
static async delete(id: string): Promise<ProviderConnection> {
+ if (isCloudBackend()) return deleteCloudProviderConnection(id);
const client = createClient();
try {
return await client.delete<ProviderConnection>(
diff --git a/src/components/features/settings/llm-profiles/llm-profiles-manager.tsx b/src/components/features/settings/llm-profiles/llm-profiles-manager.tsx
index 28f617190f..f60ef5ca9b 100644
--- a/src/components/features/settings/llm-profiles/llm-profiles-manager.tsx
+++ b/src/components/features/settings/llm-profiles/llm-profiles-manager.tsx
@@ -37,9 +37,12 @@ export function LlmProfilesManager({
// Cloud members are view-only; only owners/admins (and all local users) may
// add, edit, rename, duplicate, delete, or activate profiles.
const canManage = useCanManageOrgProfiles();
- // Provider connections exist only on the local agent-server.
- const { backend } = useActiveBackend();
- const isLocal = backend.kind === "local";
+ // Provider connections exist on the local agent-server and on cloud when an
+ // org is bound (the org-scoped CRUD routes). A cloud backend without an org
+ // (legacy API keys) cannot address them, so the manager stays hidden there.
+ const { backend, orgId } = useActiveBackend();
+ const supportsConnections =
+ backend.kind === "local" || (backend.kind === "cloud" && !!orgId);
const {
data: connections,
isLoading: isLoadingConnections,
@@ -155,7 +158,7 @@ export function LlmProfilesManager({
/>
</div>
- {isLocal && canManage ? (
+ {supportsConnections && canManage ? (
<ProviderConnectionsManager
connections={connectionList}
linkedCountById={linkedCountById}
diff --git a/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx b/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx
index f7a1607063..293f6e3edb 100644
--- a/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx
+++ b/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx
@@ -109,9 +109,12 @@ export function LlmSettingsLocalView() {
const agentSchemaRef = useRef(agentSchema);
agentSchemaRef.current = agentSchema;
- // Provider connections are a local agent-server feature.
- const { backend } = useActiveBackend();
- const isLocal = backend.kind === "local";
+ // Provider connections are available on the local agent-server and on cloud
+ // when an org is bound (the org-scoped CRUD routes). A cloud backend without
+ // an org (legacy API keys) cannot address them.
+ const { backend, orgId } = useActiveBackend();
+ const supportsConnections =
+ backend.kind === "local" || (backend.kind === "cloud" && !!orgId);
const [viewMode, setViewMode] = useState<ViewMode>("list");
const [profileName, setProfileName] = useState("");
@@ -290,7 +293,7 @@ export function LlmSettingsLocalView() {
// A profile linked to a provider connection sources its credential from the
// connection, so it never carries an inline api_key / base_url. The form
// value is the source of truth: empty (or absent) means "not linked".
- const connectionId = isLocal
+ const connectionId = supportsConnections
? String(saveControl.values[LLM_PROVIDER_CONNECTION_KEY] ?? "").trim()
: "";
@@ -309,15 +312,15 @@ export function LlmSettingsLocalView() {
} else {
llmConfig.auth_type = LLM_AUTH_TYPE_API_KEY;
llmConfig.subscription_vendor = null;
- // Clear any prior link so unlinking sticks (only relevant on local; on
- // cloud the field stays untouched below).
- if (isLocal) llmConfig.provider_connection_id = null;
+ // Clear any prior link so unlinking sticks. Only relevant where provider
+ // connections exist; otherwise the field stays untouched below.
+ if (supportsConnections) llmConfig.provider_connection_id = null;
// On cloud the OpenHands provider is backed by a server-minted LLM key,
// so the profile must not carry an inline api_key / base_url β€” let the
// backend attach its own credential when the profile is saved.
const isCloudOpenHandsProvider =
- !isLocal &&
+ backend.kind === "cloud" &&
isOpenHandsProviderModel(
typeof llmConfig.model === "string" ? llmConfig.model : "",
);
@@ -424,10 +427,11 @@ export function LlmSettingsLocalView() {
}, [
saveControl,
isNameValid,
- isLocal,
+ supportsConnections,
profileName,
viewMode,
editingProfile,
+ backend.kind,
profilesData?.active_profile,
saveProfile,
activateProfile,
@@ -508,7 +512,7 @@ export function LlmSettingsLocalView() {
[LLM_SUBSCRIPTION_VENDOR_KEY]: OPENAI_SUBSCRIPTION_VENDOR,
}
}
- showProviderConnection={isLocal}
+ showProviderConnection={supportsConnections}
onSaveControlChange={handleSaveControlChange}
/>
diff --git a/src/components/features/settings/llm-profiles/profiles-body.tsx b/src/components/features/settings/llm-profiles/profiles-body.tsx
index 2fdfd94fa0..f4e5805ea3 100644
--- a/src/components/features/settings/llm-profiles/profiles-body.tsx
+++ b/src/components/features/settings/llm-profiles/profiles-body.tsx
@@ -20,8 +20,8 @@ interface ProfilesBodyProps {
/**
* Display name per provider-connection id. When non-empty, profiles are
* grouped under their connection's name so models sharing a provider are
- * visually clustered. Empty (the default, and always on cloud) renders a flat
- * list identical to before.
+ * visually clustered. Empty (the default, e.g. a cloud backend with no org
+ * bound) renders a flat list identical to before.
*/
connectionNamesById?: Record<string, string>;
onActivate: (name: string) => void;
@@ -150,7 +150,7 @@ export function ProfilesBody({
}
// Group only when there is at least one linked connection to show; otherwise
- // (every profile today, and always on cloud) render the flat list unchanged.
+ // (no profile links to a connection) render the flat list unchanged.
const hasLinkedProfiles = profiles.some((p) => p.provider_connection_id);
if (!hasLinkedProfiles) {
return <div className={listClassName}>{profiles.map(renderRow)}</div>;
diff --git a/src/components/features/settings/llm-profiles/provider-connection-modal.tsx b/src/components/features/settings/llm-profiles/provider-connection-modal.tsx
index 5f8847b6b7..c3dd674ae2 100644
--- a/src/components/features/settings/llm-profiles/provider-connection-modal.tsx
+++ b/src/components/features/settings/llm-profiles/provider-connection-modal.tsx
@@ -79,8 +79,16 @@ export function ProviderConnectionModal({
Boolean(provider?.trim()) &&
(!isCreate || Boolean(trimmedKey));
- const verifiedProviders = providers.filter((candidate) => candidate.verified);
- const unverifiedProviders = providers.filter(
+ const selectedProviderMissing = Boolean(
+ provider && !providers.some((candidate) => candidate.name === provider),
+ );
+ const providerOptions = selectedProviderMissing
+ ? [...providers, { name: provider ?? DEFAULT_PROVIDER, verified: false }]
+ : providers;
+ const verifiedProviders = providerOptions.filter(
+ (candidate) => candidate.verified,
+ );
+ const unverifiedProviders = providerOptions.filter(
(candidate) => !candidate.verified,
);
@@ -181,39 +189,52 @@ export function ProviderConnectionModal({
onChange={setDisplayName}
required
/>
- {isCreate ? (
- <fieldset className="flex flex-col gap-2.5 w-full">
- <label className="text-sm">
- {t(I18nKey.SETTINGS$PROVIDER_CONNECTION_PROVIDER)}
- </label>
- <Autocomplete
- data-testid="provider-connection-provider-input"
- isRequired
- isVirtualized={false}
- name="provider-connection-provider-input"
- aria-label={t(I18nKey.SETTINGS$PROVIDER_CONNECTION_PROVIDER)}
- isClearable={false}
- selectedKey={provider}
- onSelectionChange={(key) => setProvider(key?.toString() ?? null)}
- classNames={{
- popoverContent:
- "bg-content1 rounded-xl border border-[var(--oh-border)]",
- selectorButton: heroUiAutocompleteSelectorButtonClassName,
- }}
- selectorButtonProps={{ disableRipple: true }}
- inputProps={{
- classNames: {
- inputWrapper: formControlSettingsFieldClassName,
- },
- }}
+ <fieldset className="flex flex-col gap-2.5 w-full">
+ <label className="text-sm">
+ {t(I18nKey.SETTINGS$PROVIDER_CONNECTION_PROVIDER)}
+ </label>
+ <Autocomplete
+ data-testid="provider-connection-provider-input"
+ isRequired
+ isVirtualized={false}
+ name="provider-connection-provider-input"
+ aria-label={t(I18nKey.SETTINGS$PROVIDER_CONNECTION_PROVIDER)}
+ isClearable={false}
+ selectedKey={provider}
+ onSelectionChange={(key) => setProvider(key?.toString() ?? null)}
+ classNames={{
+ popoverContent:
+ "bg-content1 rounded-xl border border-[var(--oh-border)]",
+ selectorButton: heroUiAutocompleteSelectorButtonClassName,
+ }}
+ selectorButtonProps={{ disableRipple: true }}
+ inputProps={{
+ classNames: {
+ inputWrapper: formControlSettingsFieldClassName,
+ },
+ }}
+ >
+ <AutocompleteSection
+ title={t(I18nKey.MODEL_SELECTOR$VERIFIED)}
+ classNames={{ heading: "text-[var(--oh-muted)]" }}
>
+ {verifiedProviders.map((candidate) => (
+ <AutocompleteItem
+ data-testid={`provider-item-${candidate.name}`}
+ key={candidate.name}
+ textValue={mapProvider(candidate.name)}
+ >
+ {mapProvider(candidate.name)}
+ </AutocompleteItem>
+ ))}
+ </AutocompleteSection>
+ {unverifiedProviders.length > 0 ? (
<AutocompleteSection
- title={t(I18nKey.MODEL_SELECTOR$VERIFIED)}
+ title={t(I18nKey.MODEL_SELECTOR$OTHERS)}
classNames={{ heading: "text-[var(--oh-muted)]" }}
>
- {verifiedProviders.map((candidate) => (
+ {unverifiedProviders.map((candidate) => (
<AutocompleteItem
- data-testid={`provider-item-${candidate.name}`}
key={candidate.name}
textValue={mapProvider(candidate.name)}
>
@@ -221,33 +242,9 @@ export function ProviderConnectionModal({
</AutocompleteItem>
))}
</AutocompleteSection>
- {unverifiedProviders.length > 0 ? (
- <AutocompleteSection
- title={t(I18nKey.MODEL_SELECTOR$OTHERS)}
- classNames={{ heading: "text-[var(--oh-muted)]" }}
- >
- {unverifiedProviders.map((candidate) => (
- <AutocompleteItem
- key={candidate.name}
- textValue={mapProvider(candidate.name)}
- >
- {mapProvider(candidate.name)}
- </AutocompleteItem>
- ))}
- </AutocompleteSection>
- ) : null}
- </Autocomplete>
- </fieldset>
- ) : (
- <SettingsInput
- testId="provider-connection-provider-input"
- label={t(I18nKey.SETTINGS$PROVIDER_CONNECTION_PROVIDER)}
- type="text"
- className="w-full"
- value={provider ?? ""}
- onChange={setProvider}
- />
- )}
+ ) : null}
+ </Autocomplete>
+ </fieldset>
<SettingsInput
testId="provider-connection-api-key-input"
label={t(I18nKey.SETTINGS_FORM$API_KEY)}
diff --git a/src/components/features/settings/llm-profiles/provider-connections-manager.test.tsx b/src/components/features/settings/llm-profiles/provider-connections-manager.test.tsx
index a43c1e4568..e90c363e60 100644
--- a/src/components/features/settings/llm-profiles/provider-connections-manager.test.tsx
+++ b/src/components/features/settings/llm-profiles/provider-connections-manager.test.tsx
@@ -151,6 +151,31 @@ describe("ProviderConnectionsManager", () => {
expect(screen.getByText("openai")).toBeInTheDocument();
});
+ it("shows supported providers in the edit-connection selector", async () => {
+ const user = userEvent.setup();
+
+ renderWith(
+ <ProviderConnectionsManager
+ connections={[connection]}
+ linkedCountById={{}}
+ isLoading={false}
+ loadError={null}
+ />,
+ );
+
+ await user.click(screen.getByTestId("provider-connection-edit"));
+
+ const providerSelector = screen.getByRole("combobox", {
+ name: /provider/i,
+ });
+ expect(providerSelector).toHaveValue("OpenAI");
+
+ await user.click(providerSelector);
+
+ expect(screen.getByText("Anthropic")).toBeInTheDocument();
+ expect(screen.getByText("OpenHands")).toBeInTheDocument();
+ });
+
it("surfaces the server message when deleting a referenced connection fails", async () => {
const conflict = Object.assign(new Error("HTTP 409"), {
response: {
diff --git a/src/components/features/settings/sdk-settings/sdk-section-page.tsx b/src/components/features/settings/sdk-settings/sdk-section-page.tsx
index deba5f62eb..b829ef0519 100644
--- a/src/components/features/settings/sdk-settings/sdk-section-page.tsx
+++ b/src/components/features/settings/sdk-settings/sdk-section-page.tsx
@@ -526,7 +526,8 @@ export function SdkSectionPage({
const handleFieldChange = React.useCallback(
(fieldKey: string, nextValue: string | boolean) => {
- const sourceKey = fieldKeyToSource.get(fieldKey);
+ const sourceKey =
+ fieldKeyToSource.get(fieldKey) ?? resolvedSources[0]?.settingsSource;
if (!sourceKey) return;
setValuesBySource((prev) => ({
...prev,
@@ -562,7 +563,7 @@ export function SdkSectionPage({
};
});
},
- [fieldKeyToSource],
+ [fieldKeyToSource, resolvedSources],
);
const handleError = React.useCallback(
diff --git a/src/hooks/query/use-provider-connections.ts b/src/hooks/query/use-provider-connections.ts
index 9fa3bad165..a852b183fb 100644
--- a/src/hooks/query/use-provider-connections.ts
+++ b/src/hooks/query/use-provider-connections.ts
@@ -9,19 +9,24 @@ import {
export { PROVIDER_CONNECTIONS_QUERY_KEYS };
/**
- * Provider connections live only on the local agent-server. On cloud backends
- * the query stays disabled and returns no data, so the connections UI hides
- * itself rather than firing a request that would 404.
+ * Provider connections are available on the local agent-server
+ * (`/api/llm/provider-connections`) and on cloud when an org is bound
+ * (`/api/organizations/{orgId}/provider-connections`). The query is disabled
+ * only for a cloud backend without an org (legacy API keys), where the
+ * org-scoped route cannot be addressed β€” there it returns no data so the
+ * connections UI hides itself rather than firing an unaddressable request.
*/
export function useProviderConnections() {
- const { backend } = useActiveBackend();
+ const { backend, orgId } = useActiveBackend();
const isLocal = backend.kind === "local";
+ const isCloudWithOrg = backend.kind === "cloud" && !!orgId;
+ const enabled = isLocal || isCloudWithOrg;
return useQuery({
- queryKey: [...PROVIDER_CONNECTIONS_QUERY_KEYS.all, backend.id],
+ queryKey: [...PROVIDER_CONNECTIONS_QUERY_KEYS.all, backend.id, orgId],
queryFn: ProviderConnectionsService.list,
...CONFIG_CACHE_OPTIONS,
- enabled: isLocal,
+ enabled,
meta: { disableToast: true },
});
}