🙌 OpenHands: AI-Driven Development
Re-apply backend status dots, replace error page with manage modal, allow editing backends (#249)
Robert Brennan28cb423506ac
diff --git a/AGENTS.md b/AGENTS.mdindex 518c8a50c0..7533d9e7c8 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -162,3 +162,7 @@- `npm run build` remains the standalone app build (`react-router build`), while `npm run build:lib` runs `vite build` in library mode plus `tsc -p tsconfig.lib.json` to emit `.d.ts` files into `dist/`.- The library build relies on `vite.config.ts` with `BUILD_LIB=true`, preserved modules in `dist/`, and package `exports` entries that map root/subpaths to `dist/**/*.js` plus matching declaration files.- Declaration emit needs `src/library-env.d.ts` and the narrowed `tsconfig.lib.json`; broad `src/**/*.tsx` declaration builds pulled in route-only files and missed `?react`/window globals.++- Backend dropdown connectivity indicator: `useBackendsHealth` (`src/hooks/query/use-backends-health.ts`) polls each registered backend every 10s. Local agent-server backends are probed via `ServerClient.getServerInfo()` (`/server_info`); cloud SaaS backends are probed via `getCurrentCloudApiKey()` (`/api/keys/current` through the bundled `/api/cloud-proxy`). Verdicts are surfaced as a colored dot rendered through `DropdownOption.prefix` (added to `src/ui/dropdown/types.ts`); the trigger reads its prefix from the live `options` array (not downshift's frozen `selectedItem`) so the indicator updates without remounting. The same dot is also rendered in each row of `ManageBackendsModal`. Tests live in `__tests__/hooks/query/use-backends-health.test.tsx`, the `connection indicator` block of `__tests__/components/backends/backend-selector.test.tsx`, and `__tests__/components/backends/manage-backends-modal.test.tsx`.++- Manage Backends modal: `src/components/features/backends/manage-backends-modal.tsx` lets users edit (host/name/api-key/kind) and remove existing backends, plus add new ones inline via a "+ Add Backend" footer button that opens a `BackendFormModal`. Both the dropdown footer's "Add backend" and the manage modal's "+ Add Backend" reuse `BackendFormModal` (see `backend-form-modal.tsx`), with `mode="add"` or `mode="edit"`; `AddBackendModal` is now a thin compatibility wrapper for `BackendFormModal mode="add"`. The modal is also auto-rendered (with a no-op `onClose`) by `src/root.tsx` when the active backend is unreachable, replacing the old full-screen `MissingAgentServerNotice` onboarding screen.diff --git a/__tests__/components/backends/backend-selector.test.tsx b/__tests__/components/backends/backend-selector.test.tsxindex 2f63870a97..7af00f344b 100644--- a/__tests__/components/backends/backend-selector.test.tsx+++ b/__tests__/components/backends/backend-selector.test.tsx@@ -28,6 +28,7 @@ import {getCloudOrganizationMe,getCurrentCloudApiKey,} from "#/api/cloud/organization-service.api";+import { createServerClient } from "#/api/typescript-client";import { displayErrorToast } from "#/utils/custom-toast-handlers";vi.mock("#/api/cloud/organization-service.api", () => ({@@ -37,6 +38,10 @@ vi.mock("#/api/cloud/organization-service.api", () => ({getCurrentCloudApiKey: vi.fn(),}));+vi.mock("#/api/typescript-client", () => ({+ createServerClient: vi.fn(),+}));+vi.mock("#/utils/custom-toast-handlers", () => ({displayErrorToast: vi.fn(),}));@@ -95,6 +100,16 @@ beforeEach(() => {orgId: null,isLegacyKey: true,});+ // Default the local-server health probe to "connected" so the+ // existing label-focused tests aren't surprised by a red indicator;+ // tests that assert on the disconnected state override this.+ vi.mocked(createServerClient).mockReset();+ vi.mocked(createServerClient).mockReturnValue({+ getServerInfo: vi.fn().mockResolvedValue({ version: "1.18.0" }),+ // The dropdown only invokes getServerInfo on the returned client;+ // the rest of the ServerClient surface is unused here, so a+ // partial cast is sufficient.+ } as unknown as ReturnType<typeof createServerClient>);vi.mocked(displayErrorToast).mockReset();});@@ -803,4 +818,54 @@ describe("BackendSelector", () => {expect(input.value).toBe("Local 1");expect(screen.queryByTestId("home")).not.toBeInTheDocument();});++ describe("connection indicator", () => {+ it("renders one status dot per option, green when the probe succeeds", async () => {+ vi.mocked(createServerClient).mockReturnValue({+ getServerInfo: vi.fn().mockResolvedValue({ version: "1.18.0" }),+ } as unknown as ReturnType<typeof createServerClient>);++ renderWithProviders(+ <TestSeed+ onMount={(ctx) => {+ ctx.addBackend({+ name: "Local 1",+ host: "http://localhost:9000",+ apiKey: "k",+ kind: "local",+ });+ }}+ >+ <BackendSelector />+ </TestSeed>,+ );++ await openDropdown();++ // One dot for the seeded default row + one for "Local 1".+ const dots = await screen.findAllByTestId("backend-status-dot");+ expect(dots.length).toBeGreaterThanOrEqual(2);++ await waitFor(() => {+ const connected = screen+ .getAllByTestId("backend-status-dot")+ .filter((el) => el.getAttribute("data-status") === "connected");+ expect(connected.length).toBeGreaterThanOrEqual(2);+ });+ });++ it("flips the status dot to red when the local probe fails", async () => {+ vi.mocked(createServerClient).mockReturnValue({+ getServerInfo: vi.fn().mockRejectedValue(new Error("ECONNREFUSED")),+ } as unknown as ReturnType<typeof createServerClient>);++ renderWithProviders(<BackendSelector />);++ await waitFor(() => {+ const wrapper = screen.getByTestId("backend-selector");+ const dot = within(wrapper).getByTestId("backend-status-dot");+ expect(dot.getAttribute("data-status")).toBe("disconnected");+ });+ });+ });});diff --git a/__tests__/components/backends/manage-backends-modal.test.tsx b/__tests__/components/backends/manage-backends-modal.test.tsxnew file mode 100644index 0000000000..b8692944b8--- /dev/null+++ b/__tests__/components/backends/manage-backends-modal.test.tsx@@ -0,0 +1,133 @@+import React from "react";+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import { render, screen, waitFor } from "@testing-library/react";+import userEvent from "@testing-library/user-event";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";++import { __resetActiveStoreForTests } from "#/api/backend-registry/active-store";+import {+ ActiveBackendProvider,+ useActiveBackendContext,+} from "#/contexts/active-backend-context";+import { ManageBackendsModal } from "#/components/features/backends/manage-backends-modal";++vi.mock("#/api/typescript-client", () => ({+ createServerClient: vi.fn(() => ({+ getServerInfo: vi.fn().mockResolvedValue({ version: "1.18.0" }),+ })),+}));++vi.mock("#/api/cloud/organization-service.api", () => ({+ getCurrentCloudApiKey: vi.fn().mockResolvedValue({+ orgId: null,+ isLegacyKey: true,+ }),+}));++function renderWithProviders(ui: React.ReactElement) {+ const queryClient = new QueryClient({+ defaultOptions: { queries: { retry: false } },+ });+ return render(+ <QueryClientProvider client={queryClient}>+ <ActiveBackendProvider>{ui}</ActiveBackendProvider>+ </QueryClientProvider>,+ );+}++function TestSeed({+ onMount,+ children,+}: {+ onMount: (ctx: ReturnType<typeof useActiveBackendContext>) => void;+ children: React.ReactNode;+}) {+ const ctx = useActiveBackendContext();+ React.useEffect(() => {+ onMount(ctx);+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, []);+ return children as React.ReactElement;+}++beforeEach(() => {+ window.localStorage.clear();+ __resetActiveStoreForTests();+});++afterEach(() => {+ window.localStorage.clear();+ __resetActiveStoreForTests();+});++describe("ManageBackendsModal", () => {+ it("renders a status dot in each row", async () => {+ renderWithProviders(<ManageBackendsModal onClose={vi.fn()} />);++ expect(+ await screen.findByTestId("manage-backends-modal"),+ ).toBeInTheDocument();++ // The seeded default Local backend row is present and has a status+ // indicator alongside its name + host.+ const dots = await screen.findAllByTestId("backend-status-dot");+ expect(dots.length).toBeGreaterThanOrEqual(1);+ });++ it("opens the add-backend form when '+ Add backend' is clicked", async () => {+ const user = userEvent.setup();+ renderWithProviders(<ManageBackendsModal onClose={vi.fn()} />);++ await user.click(screen.getByTestId("manage-backends-add"));++ expect(+ await screen.findByTestId("add-backend-modal"),+ ).toBeInTheDocument();+ });++ it("opens an edit form pre-filled with the row's backend, and persists changes via updateBackend", async () => {+ const user = userEvent.setup();++ let backendId = "";+ renderWithProviders(+ <TestSeed+ onMount={(ctx) => {+ backendId = ctx.addBackend({+ name: "Acme Local",+ host: "http://localhost:9000",+ apiKey: "old-key",+ kind: "local",+ }).id;+ }}+ >+ <ManageBackendsModal onClose={vi.fn()} />+ </TestSeed>,+ );++ await user.click(+ await screen.findByTestId("manage-backends-edit-Acme Local"),+ );++ await screen.findByTestId("edit-backend-modal");+ const nameInput = screen.getByTestId("edit-backend-name") as HTMLInputElement;+ expect(nameInput.value).toBe("Acme Local");++ // Update the host and save.+ const hostInput = screen.getByTestId("edit-backend-host") as HTMLInputElement;+ await user.clear(hostInput);+ await user.type(hostInput, "http://localhost:9999");++ await user.click(screen.getByTestId("edit-backend-submit"));++ await waitFor(() => {+ expect(+ screen.queryByTestId("edit-backend-modal"),+ ).not.toBeInTheDocument();+ });++ // The list now reflects the new host and the original id is preserved.+ const row = screen.getByTestId("manage-backends-row-Acme Local");+ expect(row.textContent).toContain("http://localhost:9999");+ expect(backendId).not.toBe("");+ });+});diff --git a/__tests__/hooks/query/use-backends-health.test.tsx b/__tests__/hooks/query/use-backends-health.test.tsxnew file mode 100644index 0000000000..cf16705966--- /dev/null+++ b/__tests__/hooks/query/use-backends-health.test.tsx@@ -0,0 +1,131 @@+import React from "react";+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import { renderHook, waitFor } from "@testing-library/react";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import { DEFAULT_LOCAL_BACKEND_ID } from "#/api/backend-registry/default-backend";+import type { Backend } from "#/api/backend-registry/types";+import { useBackendsHealth } from "#/hooks/query/use-backends-health";++const getServerInfoMock = vi.fn();+const getCurrentCloudApiKeyMock = vi.fn();++vi.mock("#/api/typescript-client", () => ({+ createServerClient: () => ({ getServerInfo: getServerInfoMock }),+}));++vi.mock("#/api/cloud/organization-service.api", () => ({+ getCurrentCloudApiKey: (...args: unknown[]) =>+ getCurrentCloudApiKeyMock(...args),+}));++const localBackend: Backend = {+ id: DEFAULT_LOCAL_BACKEND_ID,+ name: "Local",+ host: "http://localhost:18000",+ apiKey: "",+ kind: "local",+};++const cloudBackend: Backend = {+ id: "cloud-1",+ name: "Production",+ host: "https://app.all-hands.dev",+ apiKey: "bearer",+ kind: "cloud",+};++function wrapper({ children }: { children: React.ReactNode }) {+ const client = new QueryClient({+ defaultOptions: { queries: { retry: false } },+ });+ return (+ <QueryClientProvider client={client}>{children}</QueryClientProvider>+ );+}++beforeEach(() => {+ getServerInfoMock.mockReset();+ getCurrentCloudApiKeyMock.mockReset();+});++afterEach(() => {+ vi.useRealTimers();+});++describe("useBackendsHealth", () => {+ it("probes local backends via getServerInfo and reports connected", async () => {+ getServerInfoMock.mockResolvedValue({ version: "1.18.0" });++ const { result } = renderHook(() => useBackendsHealth([localBackend]), {+ wrapper,+ });++ await waitFor(() =>+ expect(result.current[localBackend.id].isConnected).toBe(true),+ );+ expect(getServerInfoMock).toHaveBeenCalled();+ expect(getCurrentCloudApiKeyMock).not.toHaveBeenCalled();+ });++ it("reports disconnected when the local probe throws", async () => {+ getServerInfoMock.mockRejectedValue(new Error("ECONNREFUSED"));++ const { result } = renderHook(() => useBackendsHealth([localBackend]), {+ wrapper,+ });++ await waitFor(() =>+ expect(result.current[localBackend.id].isConnected).toBe(false),+ );+ });++ it("probes cloud backends via getCurrentCloudApiKey", async () => {+ getCurrentCloudApiKeyMock.mockResolvedValue({+ orgId: "org-1",+ isLegacyKey: false,+ });++ const { result } = renderHook(() => useBackendsHealth([cloudBackend]), {+ wrapper,+ });++ await waitFor(() =>+ expect(result.current[cloudBackend.id].isConnected).toBe(true),+ );+ expect(getCurrentCloudApiKeyMock).toHaveBeenCalledWith(cloudBackend);+ expect(getServerInfoMock).not.toHaveBeenCalled();+ });++ it("reports disconnected when the cloud probe throws", async () => {+ getCurrentCloudApiKeyMock.mockRejectedValue(new Error("401"));++ const { result } = renderHook(() => useBackendsHealth([cloudBackend]), {+ wrapper,+ });++ await waitFor(() =>+ expect(result.current[cloudBackend.id].isConnected).toBe(false),+ );+ });++ it("reports null while the first probe is still in flight", async () => {+ let resolveProbe!: () => void;+ getServerInfoMock.mockImplementation(+ () =>+ new Promise<unknown>((resolve) => {+ resolveProbe = () => resolve({ version: "1.18.0" });+ }),+ );++ const { result } = renderHook(() => useBackendsHealth([localBackend]), {+ wrapper,+ });++ expect(result.current[localBackend.id].isConnected).toBeNull();++ resolveProbe();+ await waitFor(() =>+ expect(result.current[localBackend.id].isConnected).toBe(true),+ );+ });+});diff --git a/__tests__/root.test.tsx b/__tests__/root.test.tsxindex 0d1a82151d..c8beb8c419 100644--- a/__tests__/root.test.tsx+++ b/__tests__/root.test.tsx@@ -1,38 +1,22 @@import { render, screen, waitFor } from "@testing-library/react";import { QueryClient, QueryClientProvider } from "@tanstack/react-query";import { createRoutesStub } from "react-router";-import { describe, expect, it, vi } from "vitest";+import { beforeEach, describe, expect, it, vi } from "vitest";import { http, HttpResponse } from "msw";import App from "#/root";import { server } from "#/mocks/node";+import { __resetActiveStoreForTests } from "#/api/backend-registry/active-store";+import { ActiveBackendProvider } from "#/contexts/active-backend-context";const TRANSLATIONS: Record<string, string> = {- "SETTINGS$AGENT_SERVER_ONBOARDING_EYEBROW": "Get started",- "SETTINGS$AGENT_SERVER_ONBOARDING_TITLE": "Connect to your agent server",- "SETTINGS$AGENT_SERVER_ONBOARDING_DESCRIPTION":- "Agent Canvas needs an agent server before it can load conversations, tools, and settings. Start or choose a compatible server, then connect it here.",- "SETTINGS$AGENT_SERVER_UNAVAILABLE_STATUS_TITLE":- "We couldn't reach the configured server",- "SETTINGS$AGENT_SERVER_UNAVAILABLE_STATUS_MESSAGE":- "Check the URL, confirm the server is running, and try again. You can also point Agent Canvas at a different deployment.",- "SETTINGS$AGENT_SERVER_OPEN_SETTINGS_PAGE": "Open full settings page",- "SETTINGS$AGENT_SERVER_SETUP_GUIDE_HINT":- "If you need help starting or upgrading the server, see the",- "SETTINGS$AGENT_SERVER_SETUP_GUIDE_LINK": "setup instructions",- "SETTINGS$AGENT_SERVER_DETAILS_LABEL": "Details: {{details}}",- "SETTINGS$AGENT_SERVER_CONNECTION_DETAILS_TITLE": "Connection details",- "SETTINGS$AGENT_SERVER_CONNECTION_DETAILS_DESCRIPTION":- "Paste the agent server URL and optional session API key that Agent Canvas should use.",- "SETTINGS$AGENT_SERVER_URL": "Agent server URL",- "SETTINGS$AGENT_SERVER_URL_PLACEHOLDER": "https://agent.example.com",- "SETTINGS$AGENT_SERVER_API_KEY": "Session API key",- "SETTINGS$AGENT_SERVER_API_KEY_PLACEHOLDER":- "Enter the X-Session-API-Key value",- "SETTINGS$AGENT_SERVER_BROWSER_ONLY_NOTE":- "Saved only in this browser. Deployment defaults stay available until you override them here.",- "SETTINGS$AGENT_SERVER_RETRY_CONNECTION": "Retry connection",- "SETTINGS$SAVE_AND_RECONNECT": "Save and reconnect",- "COMMON$OPTIONAL": "Optional",+ "BACKEND$MANAGE_TITLE": "Manage backends",+ "BACKEND$MANAGE_EMPTY": "No backends yet.",+ "BACKEND$ADD": "+ Add Backend",+ "BACKEND$KIND_LOCAL": "Local",+ "BACKEND$KIND_CLOUD": "Cloud",+ "BACKEND$EDIT": "Edit",+ "BACKEND$REMOVE": "Remove",+ "HOME$DONE": "Done",};vi.mock("react-i18next", () => ({@@ -70,12 +54,18 @@ const renderApp = (initialEntries: string[] = ["/"]) =>})}>- {children}+ <ActiveBackendProvider>{children}</ActiveBackendProvider></QueryClientProvider>),});describe("App root agent-server availability guard", () => {+ beforeEach(() => {+ window.localStorage.clear();+ __resetActiveStoreForTests();+ });++it("renders the routed page even when the connected server reports an old version", async () => {server.use(http.get("/server_info", () =>@@ -108,7 +98,7 @@ describe("App root agent-server availability guard", () => {});});- it("shows the onboarding flow when the backend is unreachable", async () => {+ it("shows the manage-backends modal when the backend is unreachable", async () => {let serverInfoRequests = 0;server.use(@@ -126,13 +116,15 @@ describe("App root agent-server availability guard", () => {).toBeInTheDocument();});+ // The onboarding placeholder now hosts the Manage Backends modal+ // directly so the user can edit/add a backend immediately. The+ // modal additionally probes /server_info per registered backend+ // for its status dot + version label, so the request count is+ // bounded but greater than the single config probe.expect(- screen.getByRole("heading", { name: /connect to your agent server/i }),+ screen.getByTestId("manage-backends-modal"),).toBeInTheDocument();- expect(- screen.getByRole("link", { name: /setup instructions/i }),- ).toHaveAttribute("href", "https://github.com/OpenHands/agent-canvas");- expect(serverInfoRequests).toBe(1);+ expect(serverInfoRequests).toBeGreaterThanOrEqual(1);expect(screen.queryByTestId("app-outlet")).not.toBeInTheDocument();});diff --git a/src/components/features/backends/add-backend-modal.tsx b/src/components/features/backends/add-backend-modal.tsxindex a08a781be3..ecacf96963 100644--- a/src/components/features/backends/add-backend-modal.tsx+++ b/src/components/features/backends/add-backend-modal.tsx@@ -1,183 +1,9 @@-import React from "react";-import { useTranslation } from "react-i18next";-import { ModalBackdrop } from "#/components/shared/modals/modal-backdrop";-import { BrandButton } from "#/components/features/settings/brand-button";-import { SettingsInput } from "#/components/features/settings/settings-input";-import { useActiveBackendContext } from "#/contexts/active-backend-context";-import { I18nKey } from "#/i18n/declaration";-import type { BackendKind } from "#/api/backend-registry/types";+import { BackendFormModal } from "./backend-form-modal";interface AddBackendModalProps {onClose: () => void;}-function inferKindFromHost(host: string): BackendKind {- const trimmed = host.trim().toLowerCase();- if (trimmed.includes("all-hands.dev") || trimmed.includes("openhands.dev")) {- return "cloud";- }- return "local";-}--function normalizeHost(host: string): string {- const trimmed = host.trim().replace(/\/+$/, "");- if (!trimmed) return "";- if (/^https?:\/\//i.test(trimmed)) return trimmed;- return `https://${trimmed}`;-}-export function AddBackendModal({ onClose }: AddBackendModalProps) {- const { t } = useTranslation("openhands");- const { addBackend } = useActiveBackendContext();-- const [name, setName] = React.useState("");- const [host, setHost] = React.useState("");- const [apiKey, setApiKey] = React.useState("");- const [kind, setKind] = React.useState<BackendKind>("cloud");- const [touchedKind, setTouchedKind] = React.useState(false);-- React.useEffect(() => {- if (!touchedKind && host) {- setKind(inferKindFromHost(host));- }- }, [host, touchedKind]);-- const canSubmit =- name.trim().length > 0 &&- host.trim().length > 0 &&- (kind === "local" || apiKey.trim().length > 0);-- const onSubmit = (event: React.FormEvent<HTMLFormElement>) => {- event.preventDefault();- if (!canSubmit) return;-- addBackend({- name: name.trim(),- host: normalizeHost(host),- apiKey: apiKey.trim(),- kind,- });-- // Adding a backend is a pure save — we do NOT auto-switch the active- // selection. The user picks the new backend from the dropdown when- // they're ready. Auto-switching would write `(backendId, null)` for a- // cloud backend, which the dropdown can't render once orgs load and- // therefore drifts from the API layer.- onClose();- };-- return (- <ModalBackdrop- onClose={onClose}- closeOnEscape={false}- aria-label={t(I18nKey.BACKEND$ADD_TITLE)}- >- <form- data-testid="add-backend-modal"- onSubmit={onSubmit}- className="bg-base-secondary p-6 rounded-xl flex flex-col gap-4 border border-tertiary"- style={{ width: "480px" }}- >- <div className="flex flex-col gap-1">- <h3 className="text-xl font-bold">{t(I18nKey.BACKEND$ADD_TITLE)}</h3>- <p className="text-xs text-gray-400">- {t(I18nKey.BACKEND$ADD_SUBTITLE)}- </p>- </div>-- <SettingsInput- testId="add-backend-name"- name="add-backend-name"- type="text"- label={t(I18nKey.BACKEND$NAME_LABEL)}- value={name}- onChange={setName}- placeholder="Production"- className="w-full"- />-- <SettingsInput- testId="add-backend-host"- name="add-backend-host"- type="text"- label={t(I18nKey.BACKEND$HOST_LABEL)}- value={host}- onChange={setHost}- placeholder="https://app.all-hands.dev"- className="w-full"- />-- <SettingsInput- testId="add-backend-api-key"- name="add-backend-api-key"- type="password"- label={t(I18nKey.BACKEND$KEY_LABEL)}- value={apiKey}- onChange={setApiKey}- placeholder=""- className="w-full"- />-- <fieldset className="flex flex-col">- <legend className="text-sm mb-3">- {t(I18nKey.BACKEND$KIND_LABEL)}- </legend>- <div className="flex gap-6">- <label className="flex items-center gap-2 text-sm">- <input- type="radio"- name="add-backend-kind"- checked={kind === "local"}- onChange={() => {- setKind("local");- setTouchedKind(true);- }}- data-testid="add-backend-kind-local"- />- {t(I18nKey.BACKEND$KIND_LOCAL)}- </label>- <label className="flex items-center gap-2 text-sm">- <input- type="radio"- name="add-backend-kind"- checked={kind === "cloud"}- onChange={() => {- setKind("cloud");- setTouchedKind(true);- }}- data-testid="add-backend-kind-cloud"- />- {t(I18nKey.BACKEND$KIND_CLOUD)}- </label>- </div>- <p className="text-xs text-gray-400 mt-3">- {kind === "cloud"- ? t(I18nKey.BACKEND$KEY_HELPER_CLOUD)- : t(I18nKey.BACKEND$KEY_HELPER_LOCAL)}- </p>- </fieldset>-- <div className="grid grid-cols-2 gap-2 mt-2 w-full">- <BrandButton- type="submit"- variant="primary"- isDisabled={!canSubmit}- testId="add-backend-submit"- className="w-full text-center"- >- {t(I18nKey.BACKEND$SAVE)}- </BrandButton>- <BrandButton- type="button"- variant="secondary"- onClick={onClose}- testId="add-backend-cancel"- className="w-full text-center"- >- {t(I18nKey.BUTTON$CANCEL)}- </BrandButton>- </div>- </form>- </ModalBackdrop>- );+ return <BackendFormModal mode="add" onClose={onClose} />;}diff --git a/src/components/features/backends/backend-form-modal.tsx b/src/components/features/backends/backend-form-modal.tsxnew file mode 100644index 0000000000..0fb5411930--- /dev/null+++ b/src/components/features/backends/backend-form-modal.tsx@@ -0,0 +1,215 @@+import React from "react";+import { useTranslation } from "react-i18next";+import { ModalBackdrop } from "#/components/shared/modals/modal-backdrop";+import { BrandButton } from "#/components/features/settings/brand-button";+import { SettingsInput } from "#/components/features/settings/settings-input";+import { useActiveBackendContext } from "#/contexts/active-backend-context";+import { I18nKey } from "#/i18n/declaration";+import type { Backend, BackendKind } from "#/api/backend-registry/types";++export type BackendFormMode = "add" | "edit";++interface BackendFormModalProps {+ mode: BackendFormMode;+ /** Required when `mode === "edit"`. */+ backend?: Backend;+ onClose: () => void;+}++function inferKindFromHost(host: string): BackendKind {+ const trimmed = host.trim().toLowerCase();+ if (trimmed.includes("all-hands.dev") || trimmed.includes("openhands.dev")) {+ return "cloud";+ }+ return "local";+}++function normalizeHost(host: string): string {+ const trimmed = host.trim().replace(/\/+$/, "");+ if (!trimmed) return "";+ if (/^https?:\/\//i.test(trimmed)) return trimmed;+ return `https://${trimmed}`;+}++/**+ * Single form used for both adding a new backend and editing an+ * existing one. The shape of `Backend` is identical in both cases — the+ * only difference is whether we call `addBackend` or `updateBackend`.+ */+export function BackendFormModal({+ mode,+ backend,+ onClose,+}: BackendFormModalProps) {+ const { t } = useTranslation("openhands");+ const { addBackend, updateBackend } = useActiveBackendContext();++ const initialKind: BackendKind =+ backend?.kind ?? (mode === "edit" ? "local" : "cloud");++ const [name, setName] = React.useState(backend?.name ?? "");+ const [host, setHost] = React.useState(backend?.host ?? "");+ const [apiKey, setApiKey] = React.useState(backend?.apiKey ?? "");+ const [kind, setKind] = React.useState<BackendKind>(initialKind);+ // In add mode, infer the kind from the host; in edit mode, the user+ // already chose one, so don't re-infer over their choice.+ const [touchedKind, setTouchedKind] = React.useState(mode === "edit");++ React.useEffect(() => {+ if (!touchedKind && host) {+ setKind(inferKindFromHost(host));+ }+ }, [host, touchedKind]);++ const canSubmit =+ name.trim().length > 0 &&+ host.trim().length > 0 &&+ (kind === "local" || apiKey.trim().length > 0);++ const onSubmit = (event: React.FormEvent<HTMLFormElement>) => {+ event.preventDefault();+ if (!canSubmit) return;++ const payload = {+ name: name.trim(),+ host: normalizeHost(host),+ apiKey: apiKey.trim(),+ kind,+ };++ if (mode === "edit" && backend) {+ updateBackend(backend.id, payload);+ } else {+ // Adding a backend is a pure save — we do NOT auto-switch the+ // active selection. The user picks the new backend from the+ // dropdown when they're ready. Auto-switching would write+ // `(backendId, null)` for a cloud backend, which the dropdown+ // can't render once orgs load and therefore drifts from the API+ // layer.+ addBackend(payload);+ }++ onClose();+ };++ const titleKey =+ mode === "edit" ? I18nKey.BACKEND$EDIT_TITLE : I18nKey.BACKEND$ADD_TITLE;+ const testIdRoot = mode === "edit" ? "edit-backend" : "add-backend";++ return (+ <ModalBackdrop+ onClose={onClose}+ closeOnEscape={false}+ aria-label={t(titleKey)}+ >+ <form+ data-testid={`${testIdRoot}-modal`}+ onSubmit={onSubmit}+ className="bg-base-secondary p-6 rounded-xl flex flex-col gap-4 border border-tertiary"+ style={{ width: "480px" }}+ >+ <div className="flex flex-col gap-1">+ <h3 className="text-xl font-bold">{t(titleKey)}</h3>+ {mode === "add" ? (+ <p className="text-xs text-gray-400">+ {t(I18nKey.BACKEND$ADD_SUBTITLE)}+ </p>+ ) : null}+ </div>++ <SettingsInput+ testId={`${testIdRoot}-name`}+ name={`${testIdRoot}-name`}+ type="text"+ label={t(I18nKey.BACKEND$NAME_LABEL)}+ value={name}+ onChange={setName}+ placeholder="Production"+ className="w-full"+ />++ <SettingsInput+ testId={`${testIdRoot}-host`}+ name={`${testIdRoot}-host`}+ type="text"+ label={t(I18nKey.BACKEND$HOST_LABEL)}+ value={host}+ onChange={setHost}+ placeholder="https://app.all-hands.dev"+ className="w-full"+ />++ <SettingsInput+ testId={`${testIdRoot}-api-key`}+ name={`${testIdRoot}-api-key`}+ type="password"+ label={t(I18nKey.BACKEND$KEY_LABEL)}+ value={apiKey}+ onChange={setApiKey}+ placeholder=""+ className="w-full"+ />++ <fieldset className="flex flex-col">+ <legend className="text-sm mb-3">+ {t(I18nKey.BACKEND$KIND_LABEL)}+ </legend>+ <div className="flex gap-6">+ <label className="flex items-center gap-2 text-sm">+ <input+ type="radio"+ name={`${testIdRoot}-kind`}+ checked={kind === "local"}+ onChange={() => {+ setKind("local");+ setTouchedKind(true);+ }}+ data-testid={`${testIdRoot}-kind-local`}+ />+ {t(I18nKey.BACKEND$KIND_LOCAL)}+ </label>+ <label className="flex items-center gap-2 text-sm">+ <input+ type="radio"+ name={`${testIdRoot}-kind`}+ checked={kind === "cloud"}+ onChange={() => {+ setKind("cloud");+ setTouchedKind(true);+ }}+ data-testid={`${testIdRoot}-kind-cloud`}+ />+ {t(I18nKey.BACKEND$KIND_CLOUD)}+ </label>+ </div>+ <p className="text-xs text-gray-400 mt-3">+ {kind === "cloud"+ ? t(I18nKey.BACKEND$KEY_HELPER_CLOUD)+ : t(I18nKey.BACKEND$KEY_HELPER_LOCAL)}+ </p>+ </fieldset>++ <div className="grid grid-cols-2 gap-2 mt-2 w-full">+ <BrandButton+ type="submit"+ variant="primary"+ isDisabled={!canSubmit}+ testId={`${testIdRoot}-submit`}+ className="w-full text-center"+ >+ {t(I18nKey.BACKEND$SAVE)}+ </BrandButton>+ <BrandButton+ type="button"+ variant="secondary"+ onClick={onClose}+ testId={`${testIdRoot}-cancel`}+ className="w-full text-center"+ >+ {t(I18nKey.BUTTON$CANCEL)}+ </BrandButton>+ </div>+ </form>+ </ModalBackdrop>+ );+}diff --git a/src/components/features/backends/backend-selector.tsx b/src/components/features/backends/backend-selector.tsxindex 8b11767f8d..c258c1e416 100644--- a/src/components/features/backends/backend-selector.tsx+++ b/src/components/features/backends/backend-selector.tsx@@ -8,6 +8,10 @@ import { DropdownOption } from "#/ui/dropdown/types";import { useActiveBackendContext } from "#/contexts/active-backend-context";import { useAllCloudOrganizations } from "#/hooks/query/use-cloud-organizations";import { useCloudCurrentUserId } from "#/hooks/query/use-cloud-current-user-id";+import {+ useBackendsHealth,+ type BackendHealth,+} from "#/hooks/query/use-backends-health";import { useSwitchCloudOrganization } from "#/hooks/mutation/use-switch-cloud-organization";import { I18nKey } from "#/i18n/declaration";import type { Backend } from "#/api/backend-registry/types";@@ -19,6 +23,7 @@ import {import { displayErrorToast } from "#/utils/custom-toast-handlers";import { retrieveAxiosErrorMessage } from "#/utils/retrieve-axios-error-message";import { AddBackendModal } from "./add-backend-modal";+import { BackendStatusDot } from "./backend-status-dot";import { ManageBackendsModal } from "./manage-backends-modal";const VALUE_SEPARATOR = "::";@@ -35,11 +40,16 @@ function parseOptionValue(value: string): {return { backendId, orgId: orgId ?? null };}+function buildStatusPrefix(health: BackendHealth | undefined) {+ return <BackendStatusDot isConnected={health?.isConnected ?? null} />;+}+function buildOptions(registered: Backend[],personalWorkspaceLabel: string,cloudOrgs: ReturnType<typeof useAllCloudOrganizations>,currentUserIds: ReturnType<typeof useCloudCurrentUserId>,+ healthByBackendId: Record<string, BackendHealth>,): DropdownOption[] {const options: DropdownOption[] = [];@@ -47,13 +57,22 @@ function buildOptions(const clouds = registered.filter((b) => b.kind === "cloud");for (const b of locals) {- options.push({ value: makeOptionValue(b.id, null), label: b.name });+ options.push({+ value: makeOptionValue(b.id, null),+ label: b.name,+ prefix: buildStatusPrefix(healthByBackendId[b.id]),+ });}for (const b of clouds) {const entry = cloudOrgs[b.id];+ const prefix = buildStatusPrefix(healthByBackendId[b.id]);if (!entry || entry.orgs.length === 0) {- options.push({ value: makeOptionValue(b.id, null), label: b.name });+ options.push({+ value: makeOptionValue(b.id, null),+ label: b.name,+ prefix,+ });} else {// Personal-workspace rule (per the SaaS contract): the org whose// id matches the calling user's id is the user's personal@@ -67,6 +86,9 @@ function buildOptions(options.push({value: makeOptionValue(b.id, org.id),label: `${b.name} – ${orgLabel}`,+ // All org rows for the same cloud backend share that backend's+ // single connectivity verdict — there is no per-org probe.+ prefix,});}}@@ -87,6 +109,8 @@ export function BackendSelector({const { backends, active, setActive } = useActiveBackendContext();const cloudOrgs = useAllCloudOrganizations();const currentUserIds = useCloudCurrentUserId();+ // Probe each registered backend every 10s.+ const healthByBackendId = useBackendsHealth(backends);const { mutateAsync: switchOrg, isPending: isSwitching } =useSwitchCloudOrganization();const navigate = useNavigate();@@ -105,8 +129,20 @@ export function BackendSelector({const options = React.useMemo(() =>- buildOptions(backends, personalWorkspaceLabel, cloudOrgs, currentUserIds),- [backends, personalWorkspaceLabel, cloudOrgs, currentUserIds],+ buildOptions(+ backends,+ personalWorkspaceLabel,+ cloudOrgs,+ currentUserIds,+ healthByBackendId,+ ),+ [+ backends,+ personalWorkspaceLabel,+ cloudOrgs,+ currentUserIds,+ healthByBackendId,+ ],);const activeValue = makeOptionValue(active.backend.id, active.orgId);@@ -216,7 +252,11 @@ export function BackendSelector({testId="backend-selector"key={`${activeValue}-${activeOption?.label ?? ""}`}defaultValue={- activeOption ?? { value: activeValue, label: active.backend.name }+ activeOption ?? {+ value: activeValue,+ label: active.backend.name,+ prefix: buildStatusPrefix(healthByBackendId[active.backend.id]),+ }}footer={addBackendFooter}openUpward={openUpward}diff --git a/src/components/features/backends/backend-status-dot.tsx b/src/components/features/backends/backend-status-dot.tsxnew file mode 100644index 0000000000..65bdfe4be8--- /dev/null+++ b/src/components/features/backends/backend-status-dot.tsx@@ -0,0 +1,51 @@+import React from "react";+import { cn } from "#/utils/utils";++interface BackendStatusDotProps {+ /** `null` while the first probe is in flight. */+ isConnected: boolean | null;+ className?: string;+}++/**+ * Small colored dot that reflects backend reachability:+ * - green when connected+ * - red when disconnected+ * - dim gray while the first probe is in flight+ */+export function BackendStatusDot({+ isConnected,+ className,+}: BackendStatusDotProps) {+ let color: string;+ let label: string;+ let status: string;+ if (isConnected === true) {+ color = "bg-green-500";+ label = "Connected";+ status = "connected";+ } else if (isConnected === false) {+ color = "bg-red-500";+ label = "Disconnected";+ status = "disconnected";+ } else {+ color = "bg-neutral-500";+ label = "Checking connection";+ status = "checking";+ }++ return (+ <span+ data-testid="backend-status-dot"+ data-status={status}+ aria-label={label}+ title={label}+ role="status"+ className={cn(+ "inline-block w-2 h-2 rounded-full shrink-0",+ color,+ className,+ )}+ />+ );+}diff --git a/src/components/features/backends/manage-backends-modal.tsx b/src/components/features/backends/manage-backends-modal.tsxindex 5dc2b3688e..c7988457db 100644--- a/src/components/features/backends/manage-backends-modal.tsx+++ b/src/components/features/backends/manage-backends-modal.tsx@@ -1,6 +1,7 @@import React from "react";import { useTranslation } from "react-i18next";import { useQuery } from "@tanstack/react-query";+import { Plus } from "lucide-react";import { type Backend } from "#/api/backend-registry/types";import { createServerClient } from "#/api/typescript-client";@@ -8,9 +9,15 @@ import { BrandButton } from "#/components/features/settings/brand-button";import { ConfirmationModal } from "#/components/shared/modals/confirmation-modal";import { ModalBackdrop } from "#/components/shared/modals/modal-backdrop";import { useActiveBackendContext } from "#/contexts/active-backend-context";+import {+ useBackendsHealth,+ type BackendHealth,+} from "#/hooks/query/use-backends-health";import CloseIcon from "#/icons/close.svg?react";import { I18nKey } from "#/i18n/declaration";import { cn } from "#/utils/utils";+import { BackendFormModal } from "./backend-form-modal";+import { BackendStatusDot } from "./backend-status-dot";function BackendVersion({ backend }: { backend: Backend }) {const { t } = useTranslation("openhands");@@ -50,11 +57,65 @@ interface PendingRemoval {name: string;}+interface BackendRowProps {+ backend: Backend;+ health: BackendHealth | undefined;+ onEdit: () => void;+ onRemove: () => void;+}++function BackendRow({ backend, health, onEdit, onRemove }: BackendRowProps) {+ const { t } = useTranslation("openhands");++ return (+ <li+ className="flex items-center gap-3 px-5 py-3 border-b border-[#363840] last:border-b-0"+ data-testid={`manage-backends-row-${backend.name}`}+ >+ <BackendStatusDot isConnected={health?.isConnected ?? null} />+ <div className="flex flex-col min-w-0 flex-1">+ <span className="text-sm text-white truncate">{backend.name}</span>+ <span className="text-xs text-[#A3A3A3] truncate">{backend.host}</span>+ <BackendVersion backend={backend} />+ </div>+ <span className="px-2 py-1 rounded-full text-[11px] uppercase tracking-wide text-[#D6D6D6] bg-[#1F1F1F] border border-[#4B4E57]">+ {backend.kind === "cloud"+ ? t(I18nKey.BACKEND$KIND_CLOUD)+ : t(I18nKey.BACKEND$KIND_LOCAL)}+ </span>+ <button+ type="button"+ onClick={onEdit}+ aria-label={t(I18nKey.BACKEND$EDIT)}+ data-testid={`manage-backends-edit-${backend.name}`}+ className="px-2 py-1 rounded text-xs text-[#D6D6D6] hover:bg-[#5C5D62] hover:text-white cursor-pointer"+ >+ {t(I18nKey.BACKEND$EDIT)}+ </button>+ <button+ type="button"+ onClick={onRemove}+ aria-label={t(I18nKey.BACKEND$REMOVE)}+ data-testid={`manage-backends-remove-${backend.name}`}+ className="flex items-center gap-1 px-2 py-1 rounded text-xs text-[#D6D6D6] hover:bg-[#5C5D62] hover:text-white cursor-pointer"+ >+ <CloseIcon width={12} height={12} />+ <span>{t(I18nKey.BACKEND$REMOVE)}</span>+ </button>+ </li>+ );+}+export function ManageBackendsModal({ onClose }: ManageBackendsModalProps) {const { t } = useTranslation("openhands");const { backends, removeBackend } = useActiveBackendContext();+ const healthByBackendId = useBackendsHealth(backends);const [pendingRemoval, setPendingRemoval] =React.useState<PendingRemoval | null>(null);+ const [editingBackend, setEditingBackend] = React.useState<Backend | null>(+ null,+ );+ const [showAddForm, setShowAddForm] = React.useState(false);const handleConfirmRemoval = () => {if (!pendingRemoval) return;@@ -72,7 +133,7 @@ export function ManageBackendsModal({ onClose }: ManageBackendsModalProps) {data-testid="manage-backends-modal"className={cn("flex flex-col bg-[#26282D] border border-[#727987] rounded-xl",- "w-[560px] max-w-[90vw] max-h-[70vh]",+ "w-[640px] max-w-[90vw] max-h-[70vh]",)}><div className="flex items-center justify-between px-5 py-3 border-b border-[#727987]">@@ -92,47 +153,33 @@ export function ManageBackendsModal({ onClose }: ManageBackendsModalProps) {) : (<ul>{backends.map((backend) => (- <li+ <BackendRowkey={backend.id}- className="flex items-center gap-3 px-5 py-3 border-b border-[#363840] last:border-b-0"- data-testid={`manage-backends-row-${backend.name}`}- >- <div className="flex flex-col min-w-0 flex-1">- <span className="text-sm text-white truncate">- {backend.name}- </span>- <span className="text-xs text-[#A3A3A3] truncate">- {backend.host}- </span>- <BackendVersion backend={backend} />- </div>- <span className="px-2 py-1 rounded-full text-[11px] uppercase tracking-wide text-[#D6D6D6] bg-[#1F1F1F] border border-[#4B4E57]">- {backend.kind === "cloud"- ? t(I18nKey.BACKEND$KIND_CLOUD)- : t(I18nKey.BACKEND$KIND_LOCAL)}- </span>- <button- type="button"- onClick={() =>- setPendingRemoval({- id: backend.id,- name: backend.name,- })- }- aria-label={t(I18nKey.BACKEND$REMOVE)}- data-testid={`manage-backends-remove-${backend.name}`}- className="flex items-center gap-1 px-2 py-1 rounded text-xs text-[#D6D6D6] hover:bg-[#5C5D62] hover:text-white cursor-pointer"- >- <CloseIcon width={12} height={12} />- <span>{t(I18nKey.BACKEND$REMOVE)}</span>- </button>- </li>+ backend={backend}+ health={healthByBackendId[backend.id]}+ onEdit={() => setEditingBackend(backend)}+ onRemove={() =>+ setPendingRemoval({+ id: backend.id,+ name: backend.name,+ })+ }+ />))}</ul>)}</div>- <div className="flex justify-end gap-2 px-5 py-3 border-t border-[#727987]">+ <div className="flex justify-between gap-2 px-5 py-3 border-t border-[#727987]">+ <BrandButton+ type="button"+ variant="secondary"+ onClick={() => setShowAddForm(true)}+ testId="manage-backends-add"+ startContent={<Plus width={14} height={14} />}+ >+ {t(I18nKey.BACKEND$ADD)}+ </BrandButton><BrandButtontype="button"variant="primary"@@ -145,6 +192,18 @@ export function ManageBackendsModal({ onClose }: ManageBackendsModalProps) {</div></ModalBackdrop>+ {showAddForm ? (+ <BackendFormModal mode="add" onClose={() => setShowAddForm(false)} />+ ) : null}++ {editingBackend ? (+ <BackendFormModal+ mode="edit"+ backend={editingBackend}+ onClose={() => setEditingBackend(null)}+ />+ ) : null}+{pendingRemoval ? (<ConfirmationModaltext={t(I18nKey.BACKEND$REMOVE_CONFIRMATION, {diff --git a/src/hooks/query/use-backends-health.ts b/src/hooks/query/use-backends-health.tsnew file mode 100644index 0000000000..6ff5a125ea--- /dev/null+++ b/src/hooks/query/use-backends-health.ts@@ -0,0 +1,86 @@+import { useQueries } from "@tanstack/react-query";+import { getCurrentCloudApiKey } from "#/api/cloud/organization-service.api";+import type { Backend } from "#/api/backend-registry/types";+import { createServerClient } from "#/api/typescript-client";++const REFRESH_INTERVAL_MS = 10000;+const PROBE_TIMEOUT_MS = 4000;++/**+ * Probe a single backend for connectivity. The probe path differs by+ * backend kind:+ *+ * - Local agent-server: GET `/server_info` via the typescript-client.+ * That's the same endpoint the root compatibility check uses, so a+ * healthy backend always answers it.+ * - Cloud SaaS: GET `/api/keys/current` via the bundled local+ * agent-server's `/api/cloud-proxy`. That endpoint is lightweight,+ * requires auth, and `getCurrentCloudApiKey` already absorbs the+ * legacy-key 400 fallback so we treat that as "connected" too.+ * Any other failure (network, 401, 5xx, …) means the backend is+ * not reachable / not usable from the GUI.+ *+ * Throws on failure so React Query marks the query as errored — the+ * dropdown reads `isSuccess` to flip the indicator green.+ */+async function probeBackend(backend: Backend): Promise<true> {+ if (backend.kind === "cloud") {+ await getCurrentCloudApiKey(backend);+ return true;+ }++ await createServerClient({+ host: backend.host,+ sessionApiKey: backend.apiKey || null,+ timeout: PROBE_TIMEOUT_MS,+ }).getServerInfo();+ return true;+}++export interface BackendHealth {+ /** `null` while the first probe is in flight; then `true` / `false`. */+ isConnected: boolean | null;+}++/**+ * Poll every backend in `backends` once every 10s and report a simple+ * connected / disconnected verdict per backend id.+ *+ * The query key includes `host` and `apiKey` so editing a backend's+ * connection details re-keys the query and triggers an immediate+ * refetch instead of waiting for the next tick.+ */+export function useBackendsHealth(+ backends: Backend[],+): Record<string, BackendHealth> {+ const results = useQueries({+ queries: backends.map((b) => ({+ queryKey: [+ "backend-health",+ b.id,+ b.kind,+ b.host,+ b.apiKey ?? "",+ ] as const,+ queryFn: () => probeBackend(b),+ refetchInterval: REFRESH_INTERVAL_MS,+ refetchIntervalInBackground: false,+ retry: false,+ // Keep the previous verdict visible while the next probe is in+ // flight so the indicator doesn't flicker every 2s.+ staleTime: REFRESH_INTERVAL_MS,+ meta: { disableToast: true },+ })),+ });++ const out: Record<string, BackendHealth> = {};+ backends.forEach((b, i) => {+ const r = results[i];+ let isConnected: boolean | null;+ if (r.isSuccess) isConnected = true;+ else if (r.isError) isConnected = false;+ else isConnected = null;+ out[b.id] = { isConnected };+ });+ return out;+}diff --git a/src/i18n/translation.json b/src/i18n/translation.jsonindex 15aaba9857..41e46509fd 100644--- a/src/i18n/translation.json+++ b/src/i18n/translation.json@@ -22495,6 +22495,23 @@"uk": "Редагувати","ca": "Editar"},+ "BACKEND$EDIT_TITLE": {+ "en": "Edit backend",+ "ja": "バックエンドを編集",+ "zh-CN": "编辑后端",+ "zh-TW": "編輯後端",+ "ko-KR": "백엔드 편집",+ "no": "Rediger backend",+ "it": "Modifica backend",+ "pt": "Editar backend",+ "es": "Editar backend",+ "ar": "تعديل الخادم الخلفي",+ "fr": "Modifier le backend",+ "tr": "Backend'i düzenle",+ "de": "Backend bearbeiten",+ "uk": "Редагувати бекенд",+ "ca": "Editar backend"+ },"BACKEND$SAVE": {"en": "Save","ja": "保存",diff --git a/src/root.tsx b/src/root.tsxindex c8063a729d..4274b01adb 100644--- a/src/root.tsx+++ b/src/root.tsx@@ -10,12 +10,8 @@ import "./tailwind.css";import "./index.css";import React from "react";import { Toaster } from "react-hot-toast";-import { useTranslation } from "react-i18next";-import {- AgentServerUnavailableError,- isAgentServerUnavailableError,-} from "#/api/agent-server-compatibility";-import { AgentServerConnectionForm } from "#/components/features/settings/agent-server-onboarding";+import { isAgentServerUnavailableError } from "#/api/agent-server-compatibility";+import { ManageBackendsModal } from "#/components/features/backends/manage-backends-modal";import { TelemetryConsentBanner } from "#/components/features/analytics/telemetry-consent-banner";import { LoadingSpinner } from "#/components/shared/loading-spinner";import { useConfig } from "#/hooks/query/use-config";@@ -44,30 +40,6 @@ export function Layout({ children }: { children: React.ReactNode }) {);}-function AgentServerStatusCard({- title,- message,- details,-}: {- title: string;- message: string;- details?: string | null;-}) {- const { t } = useTranslation("openhands");-- return (- <div className="mt-6 rounded-2xl border border-primary/20 bg-primary/10 p-4">- <p className="text-sm font-semibold text-white">{title}</p>- <p className="mt-2 text-sm leading-6 text-neutral-200">{message}</p>- {details ? (- <p className="mt-3 text-xs leading-5 text-neutral-400">- {t("SETTINGS$AGENT_SERVER_DETAILS_LABEL", { details })}- </p>- ) : null}- </div>- );-}-function AgentServerBootstrapLoading() {return (<main className="min-h-screen bg-base px-6 py-10 text-white">@@ -80,92 +52,32 @@ function AgentServerBootstrapLoading() {);}-function AgentServerOnboardingLayout({- testId,- eyebrow,- title,- description,- statusTitle,- statusMessage,- statusDetails,-}: {- testId: string;- eyebrow: string;- title: string;- description: string;- statusTitle: string;- statusMessage: string;- statusDetails?: string | null;-}) {- const { t } = useTranslation("openhands");+/**+ * When the active backend is unreachable, the rest of the app cannot+ * render (most queries chain off of `/server_info`). Instead of the+ * old full-screen onboarding error, drop a minimal placeholder behind+ * the Manage Backends modal so the user can edit, add, or pick another+ * backend right away. Closing the modal just reopens it — the only way+ * out is a successful reconnection (the modal triggers a refetch via+ * its health probe and the user can reload).+ */+function MissingAgentServerScreen() {+ // Provide a no-op `onClose` so the user can't dismiss the modal into+ // a broken empty state. Editing/adding a backend reseeds the registry+ // and the next config refetch (via React Query's natural retry on+ // mount or a manual reload) recovers the app.+ const noop = React.useCallback(() => {}, []);return (- <main className="min-h-screen bg-base px-6 py-10 text-white">- <div className="mx-auto flex min-h-screen max-w-6xl items-center">- <div- data-testid={testId}- className="grid w-full gap-8 lg:grid-cols-[1.15fr,0.85fr]"- >- <section className="rounded-3xl border border-white/10 bg-neutral-900/80 p-8 shadow-2xl">- <p className="text-sm font-medium uppercase tracking-[0.24em] text-primary">- {eyebrow}- </p>- <h1 className="mt-4 text-4xl font-semibold leading-tight text-white">- {title}- </h1>- <p className="mt-4 max-w-3xl text-base leading-7 text-neutral-200">- {description}- </p>-- <AgentServerStatusCard- title={statusTitle}- message={statusMessage}- details={statusDetails}- />-- <p className="mt-6 max-w-3xl text-sm leading-6 text-gray-400">- {t("SETTINGS$AGENT_SERVER_SETUP_GUIDE_HINT")}{" "}- <a- href="https://github.com/OpenHands/agent-canvas"- target="_blank"- rel="noreferrer noopener"- className="underline underline-offset-2 transition-colors hover:text-white"- >- {t("SETTINGS$AGENT_SERVER_SETUP_GUIDE_LINK")}- </a>- .- </p>- </section>-- <aside className="lg:pt-6">- <AgentServerConnectionForm />- </aside>- </div>- </div>+ <main+ data-testid="agent-server-onboarding-screen"+ className="min-h-screen bg-base"+ >+ <ManageBackendsModal onClose={noop} /></main>);}-function MissingAgentServerNotice({- error,-}: {- error: AgentServerUnavailableError;-}) {- const { t } = useTranslation("openhands");-- return (- <AgentServerOnboardingLayout- testId="agent-server-onboarding-screen"- eyebrow={t("SETTINGS$AGENT_SERVER_ONBOARDING_EYEBROW")}- title={t("SETTINGS$AGENT_SERVER_ONBOARDING_TITLE")}- description={t("SETTINGS$AGENT_SERVER_ONBOARDING_DESCRIPTION")}- statusTitle={t("SETTINGS$AGENT_SERVER_UNAVAILABLE_STATUS_TITLE")}- statusMessage={t("SETTINGS$AGENT_SERVER_UNAVAILABLE_STATUS_MESSAGE")}- statusDetails={error.details}- />- );-}-export const meta: MetaFunction = () => [{ title: "OpenHands" },{ name: "description", content: "Let's Start Building!" },@@ -179,7 +91,7 @@ export default function App() {}if (isAgentServerUnavailableError(config.error)) {- return <MissingAgentServerNotice error={config.error} />;+ return <MissingAgentServerScreen />;}return <Outlet />;diff --git a/src/ui/dropdown/dropdown-menu.tsx b/src/ui/dropdown/dropdown-menu.tsxindex 4bc0ee3f70..4277b83306 100644--- a/src/ui/dropdown/dropdown-menu.tsx+++ b/src/ui/dropdown/dropdown-menu.tsx@@ -54,13 +54,15 @@ export function DropdownMenu({className: cn("px-2 py-2 cursor-pointer text-sm rounded-md","text-white focus:outline-none font-normal",+ "flex items-center gap-2",selectedItem?.value === option.value? "bg-[#C9B974] text-black": "hover:bg-[#5C5D62]",),})}>- {option.label}+ {option.prefix}+ <span className="min-w-0 truncate">{option.label}</span></li>))}</ul>diff --git a/src/ui/dropdown/dropdown.tsx b/src/ui/dropdown/dropdown.tsxindex 90e48b1741..7ddf138662 100644--- a/src/ui/dropdown/dropdown.tsx+++ b/src/ui/dropdown/dropdown.tsx@@ -89,6 +89,15 @@ export function Dropdown({const isDisabled = loading || disabled;+ // `selectedItem` is downshift's internal state, frozen to whatever+ // initialized it. Resolve the currently selected option against the+ // live `options` array so per-option fields like `prefix` (e.g. a+ // status indicator that re-renders on a timer) update on the trigger+ // without remounting the dropdown.+ const liveSelectedOption = selectedItem+ ? (options.find((o) => o.value === selectedItem.value) ?? selectedItem)+ : null;+// Wrap getInputProps to inject a direct onChange handler that preserves// cursor position. Downshift's default onInputValueChange resets cursor// to end of input on every keystroke; reading from e.target.value keeps@@ -112,6 +121,11 @@ export function Dropdown({className,)}>+ {liveSelectedOption?.prefix ? (+ <span className="flex items-center shrink-0">+ {liveSelectedOption.prefix}+ </span>+ ) : null}<DropdownInputplaceholder={placeholder}isDisabled={isDisabled}diff --git a/src/ui/dropdown/types.ts b/src/ui/dropdown/types.tsindex 511e5d707d..1313807c48 100644--- a/src/ui/dropdown/types.ts+++ b/src/ui/dropdown/types.ts@@ -1,4 +1,12 @@+import type { ReactNode } from "react";+export interface DropdownOption {value: string;label: string;+ /**+ * Optional content rendered before the label in both the trigger+ * (when this option is selected) and each menu row. Used for things+ * like status indicators; not searchable.+ */+ prefix?: ReactNode;}