π OpenHands: AI-Driven Development
fix: pass the active org from the gear icon to cloud settings (#17256)
Hiep Le2fb2c526e1af
diff --git a/__tests__/components/backends/backend-selector.test.tsx b/__tests__/components/backends/backend-selector.test.tsxindex c8434b6412..aaf0bfc140 100644--- a/__tests__/components/backends/backend-selector.test.tsx+++ b/__tests__/components/backends/backend-selector.test.tsx@@ -830,6 +830,27 @@ describe("BackendSelector", () => {expect(link).toHaveAttribute("target", "_blank");expect(link).toHaveAttribute("rel", "noopener noreferrer");});++ it("passes the active org to the cloud settings link", () => {+ let cloudId = "";+ renderWithProviders(+ <TestSeed+ onMount={(ctx) => {+ cloudId = ctx.addBackend(SEED_CLOUD_PRODUCTION).id;+ ctx.setActive(cloudId, "org-2");+ }}+ >+ <BackendSelector />+ </TestSeed>,+ );++ expect(+ screen.getByTestId("backend-selector-settings-link"),+ ).toHaveAttribute(+ "href",+ `${SEED_CLOUD_PRODUCTION.host}/settings?org=org-2`,+ );+ });});describe("connection indicator", () => {diff --git a/__tests__/components/features/sidebar/sidebar-cloud-settings.test.tsx b/__tests__/components/features/sidebar/sidebar-cloud-settings.test.tsxindex b0864c724c..9fe55553c4 100644--- a/__tests__/components/features/sidebar/sidebar-cloud-settings.test.tsx+++ b/__tests__/components/features/sidebar/sidebar-cloud-settings.test.tsx@@ -43,7 +43,7 @@ const cloudBackendMock = {host: "https://cloud.example.com",apiKey: "test-key",},- orgId: "org-1",+ orgId: "org-1" as string | null,};vi.mock("#/hooks/query/use-config", () => ({@@ -230,6 +230,7 @@ describe("Sidebar with Cloud Backend", () => {afterEach(() => {window.localStorage.clear();useSidebarStore.setState({ collapsed: false });+ cloudBackendMock.orgId = "org-1";});it("opens cloud settings in new tab when connected to cloud backend", () => {@@ -240,6 +241,17 @@ describe("Sidebar with Cloud Backend", () => {expect(settingsLink).toBeInTheDocument();expect(settingsLink).toHaveAttribute("target", "_blank");expect(settingsLink).toHaveAttribute(+ "href",+ "https://cloud.example.com/settings?org=org-1",+ );+ });++ it("omits the org param from the cloud settings link when no org is active", () => {+ cloudBackendMock.orgId = null;+ useSidebarStore.setState({ collapsed: true });+ renderSidebar("/conversations");++ expect(screen.getByTestId("collapsed-settings-link")).toHaveAttribute("href","https://cloud.example.com/settings",);diff --git a/src/components/features/backends/backend-selector.tsx b/src/components/features/backends/backend-selector.tsxindex 6c904748bc..677ab8b479 100644--- a/src/components/features/backends/backend-selector.tsx+++ b/src/components/features/backends/backend-selector.tsx@@ -191,6 +191,11 @@ export function BackendSelector({: options.find((o) => o.value === activeValue);const isSettingsActive = Boolean(settingsMatch || settingsSubrouteMatch);const settingsLabel = t(I18nKey.SIDEBAR$SETTINGS);+ // `org` is consumed by the cloud settings loader so the page opens on the+ // org that is active here instead of the cloud's last-used org.+ const cloudSettingsOrgQuery = active.orgId+ ? `?org=${encodeURIComponent(active.orgId)}`+ : "";const isRightPanelShown = useConversationStore((state) => state.isRightPanelShown,);@@ -420,7 +425,7 @@ export function BackendSelector({>{active.backend.kind === "cloud" ? (<a- href={`${active.backend.host.replace(/\/+$/, "")}/settings`}+ href={`${active.backend.host.replace(/\/+$/, "")}/settings${cloudSettingsOrgQuery}`}target="_blank"rel="noopener noreferrer"data-testid="backend-selector-settings-link"diff --git a/src/components/features/sidebar/sidebar-rail-body.tsx b/src/components/features/sidebar/sidebar-rail-body.tsxindex 632308a640..bba1054236 100644--- a/src/components/features/sidebar/sidebar-rail-body.tsx+++ b/src/components/features/sidebar/sidebar-rail-body.tsx@@ -60,6 +60,7 @@ export interface SidebarRailBodyProps {isExtensionsActive: boolean;currentPath: string;activeBackend: Backend;+ activeOrgId: string | null;activeBackendHealth: { isConnected: boolean | null } | undefined;collapsedBackendPopoverOpen: boolean;setCollapsedBackendPopoverOpen: (open: boolean) => void;@@ -83,6 +84,7 @@ export function SidebarRailBody({isExtensionsActive,currentPath,activeBackend,+ activeOrgId,activeBackendHealth,collapsedBackendPopoverOpen,setCollapsedBackendPopoverOpen,@@ -109,8 +111,13 @@ export function SidebarRailBody({};const isCloudBackend = activeBackend.kind === "cloud";+ // `org` is consumed by the cloud settings loader so the page opens on the+ // org that is active here instead of the cloud's last-used org.+ const cloudSettingsOrgQuery = activeOrgId+ ? `?org=${encodeURIComponent(activeOrgId)}`+ : "";const cloudSettingsUrl = isCloudBackend- ? `${activeBackend.host.replace(/\/+$/, "")}/settings`+ ? `${activeBackend.host.replace(/\/+$/, "")}/settings${cloudSettingsOrgQuery}`: null;return (diff --git a/src/components/features/sidebar/sidebar.tsx b/src/components/features/sidebar/sidebar.tsxindex 223f715407..0ca8d85ea6 100644--- a/src/components/features/sidebar/sidebar.tsx+++ b/src/components/features/sidebar/sidebar.tsx@@ -192,6 +192,7 @@ export function Sidebar() {isExtensionsActive,currentPath,activeBackend: active.backend,+ activeOrgId: active.orgId,activeBackendHealth,collapsedBackendPopoverOpen,setCollapsedBackendPopoverOpen,