π OpenHands: AI-Driven Development
fix(onboarding): unblock keyless/open local backends in the connect flow (#1133)
simonrosenberg6f25fb663038
diff --git a/__tests__/api/option-service.test.ts b/__tests__/api/option-service.test.tsindex b8ba9fe857..5debec4cfe 100644--- a/__tests__/api/option-service.test.ts+++ b/__tests__/api/option-service.test.ts@@ -50,7 +50,7 @@ describe("OptionService", () => {await expect(OptionService.getConfig()).rejects.toMatchObject({name: AgentServerUnavailableError.name,- message: expect.stringContaining("Agent server not found"),+ message: expect.stringContaining("Could not connect to the configured agent server"),details: expect.stringContaining("Request failed"),});});diff --git a/src/api/agent-server-compatibility.ts b/src/api/agent-server-compatibility.tsindex 99f24bb9c8..63ee467502 100644--- a/src/api/agent-server-compatibility.ts+++ b/src/api/agent-server-compatibility.ts@@ -28,13 +28,21 @@ const getAdvertisedTools = (serverInfo: AgentServerInfo | null) => {export class AgentServerUnavailableError extends Error {readonly details: string | null;+ readonly noBackendConfigured: boolean;- constructor(details?: string | null) {+ constructor(+ details?: string | null,+ options?: { noBackendConfigured?: boolean },+ ) {+ const noBackendConfigured = options?.noBackendConfigured ?? false;super(- "Agent server not found. Could not connect to the configured agent server. Start a compatible agent server and reload the page.",+ noBackendConfigured+ ? "No agent server backend is configured yet. Add a backend to get started."+ : "Could not connect to the configured agent server. Make sure it is running and reachable, then reload the page.",);this.name = "AgentServerUnavailableError";this.details = details ?? null;+ this.noBackendConfigured = noBackendConfigured;}}@@ -103,7 +111,9 @@ export async function loadAgentServerInfo() {// configured at all. Throw so root.tsx shows the manage-backends// modal instead of silently rendering a broken home page.if (isNoBackend(getActiveBackend().backend)) {- throw new AgentServerUnavailableError("No backend configured");+ throw new AgentServerUnavailableError("No backend configured", {+ noBackendConfigured: true,+ });}// Active backend is cloud β no local probe needed.diff --git a/src/components/features/onboarding/steps/check-backend-step.tsx b/src/components/features/onboarding/steps/check-backend-step.tsxindex c27c393423..f1d186b482 100644--- a/src/components/features/onboarding/steps/check-backend-step.tsx+++ b/src/components/features/onboarding/steps/check-backend-step.tsx@@ -2,7 +2,10 @@ import React from "react";import { useTranslation } from "react-i18next";import { CheckCircle2, Loader2, AlertCircle } from "lucide-react";import { isNoBackend } from "#/api/backend-registry/active-store";-import { getAgentServerFormDefaults } from "#/api/agent-server-config";+import {+ getAgentServerFormDefaults,+ isAuthRequired,+} from "#/api/agent-server-config";import { DEFAULT_LOCAL_BACKEND_NAME } from "#/api/backend-registry/default-backend";import { BackendForm } from "#/components/features/backends/backend-form-modal";import { BrandButton } from "#/components/features/settings/brand-button";@@ -156,7 +159,7 @@ export function CheckBackendStep({ onBack, onNext }: CheckBackendStepProps) {backend={backendForForm}onSubmitted={onNext}testIdRoot="onboarding-backend"- requireApiKey+ requireApiKey={isAuthRequired()}hideConfigurationFields={hideConfigurationFields}renderActions={({ canSubmit, isSubmitting }) => (<divdiff --git a/src/root.tsx b/src/root.tsxindex a250c5d6f2..6bbb48ff0d 100644--- a/src/root.tsx+++ b/src/root.tsx@@ -10,6 +10,7 @@ import {import "./tailwind.css";import "./index.css";import React from "react";+import { useQueryClient } from "@tanstack/react-query";import { Toaster } from "react-hot-toast";import {isAgentServerUnavailableError,@@ -21,6 +22,7 @@ import { TOAST_OPTIONS } from "#/utils/custom-toast-handlers";import { TelemetryConsentBanner } from "#/components/features/analytics/telemetry-consent-banner";import { LoadingSpinner } from "#/components/shared/loading-spinner";import { useConfig } from "#/hooks/query/use-config";+import { QUERY_KEYS } from "#/hooks/query/query-keys";import { AgentServerUIRoot } from "#/components/providers";import {applyColorTheme,@@ -91,7 +93,20 @@ function AgentServerBootstrapLoading() {* add, or pick another backend right away.*/function MissingAgentServerScreen() {- const noop = React.useCallback(() => {}, []);+ const queryClient = useQueryClient();++ // The modal is the no-backend gate. Closing it must re-run the+ // /server_info probe once a usable local backend has been registered,+ // otherwise the app stays stuck behind a "Done" button that closes a+ // modal with nothing rendered behind it (the probe never re-fires on its+ // own). Re-fetch only when a backend now exists; otherwise keep the modal.+ const handleClose = React.useCallback(() => {+ if (getEffectiveLocalBackend()) {+ queryClient.invalidateQueries({+ queryKey: QUERY_KEYS.WEB_CLIENT_CONFIG,+ });+ }+ }, [queryClient]);return (<main@@ -99,7 +114,7 @@ function MissingAgentServerScreen() {className="min-h-screen bg-base"><React.Suspense fallback={null}>- <ManageBackendsModal onClose={noop} />+ <ManageBackendsModal onClose={handleClose} /></React.Suspense></main>);