Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix: pass the active org when opening cloud settings links (#17066)

Hiep Le30e799a6593d
diff --git a/__tests__/components/features/settings/cloud-settings-link.test.tsx b/__tests__/components/features/settings/cloud-settings-link.test.tsx
index d6bc200577..2aa98ee34c 100644
--- a/__tests__/components/features/settings/cloud-settings-link.test.tsx
+++ b/__tests__/components/features/settings/cloud-settings-link.test.tsx
@@ -79,6 +79,18 @@ describe("CloudSettingsLink", () => {
);
});
+ it("appends the active org so cloud settings open on the same organization", () => {
+ setRegisteredBackends([cloudBackend]);
+ setActiveSelection({ backendId: cloudBackend.id, orgId: "org-123" });
+
+ renderWithProviders();
+
+ expect(screen.getByTestId("settings-cloud-link")).toHaveAttribute(
+ "href",
+ "https://app.all-hands.dev/settings?org=org-123",
+ );
+ });
+
it("renders nothing when a local backend is active", () => {
setRegisteredBackends([localBackend]);
setActiveSelection({ backendId: localBackend.id });
diff --git a/__tests__/components/features/settings/integrations-settings-link.test.tsx b/__tests__/components/features/settings/integrations-settings-link.test.tsx
index 3a5f9221df..1a9cf99b24 100644
--- a/__tests__/components/features/settings/integrations-settings-link.test.tsx
+++ b/__tests__/components/features/settings/integrations-settings-link.test.tsx
@@ -60,6 +60,21 @@ describe("IntegrationsSettingsLink", () => {
expect(link).toHaveAttribute("target", "_blank");
});
+ it("appends the active org so cloud integrations open on the same organization", () => {
+ // Arrange
+ setRegisteredBackends([cloudBackend]);
+ setActiveSelection({ backendId: cloudBackend.id, orgId: "org-123" });
+
+ // Act
+ renderWithProviders();
+
+ // Assert
+ expect(screen.getByTestId("settings-integrations-link")).toHaveAttribute(
+ "href",
+ "https://app.all-hands.dev/settings/integrations?org=org-123",
+ );
+ });
+
it("renders nothing when the canvas is locked to a Cloud host", () => {
// Arrange β€” SaaS / self-hosted OHE serve the canvas with `--lock-to-cloud`;
// the OHE settings shell already exposes Integrations.
diff --git a/src/components/features/settings/cloud-settings-link.tsx b/src/components/features/settings/cloud-settings-link.tsx
index 445b44dd2c..10cf6b6d94 100644
--- a/src/components/features/settings/cloud-settings-link.tsx
+++ b/src/components/features/settings/cloud-settings-link.tsx
@@ -18,11 +18,14 @@ import {
export function CloudSettingsLink() {
const { t } = useTranslation("openhands");
const { active } = useActiveBackendContext();
- const { backend } = active;
+ const { backend, orgId } = active;
if (isNoBackend(backend) || backend.kind !== "cloud") return null;
- const cloudSettingsUrl = `${backend.host.replace(/\/+$/, "")}/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 orgQuery = orgId ? `?org=${encodeURIComponent(orgId)}` : "";
+ const cloudSettingsUrl = `${backend.host.replace(/\/+$/, "")}/settings${orgQuery}`;
return (
<a
diff --git a/src/components/features/settings/integrations-settings-link.tsx b/src/components/features/settings/integrations-settings-link.tsx
index 41b6cc9558..5e6f1dc1fa 100644
--- a/src/components/features/settings/integrations-settings-link.tsx
+++ b/src/components/features/settings/integrations-settings-link.tsx
@@ -21,12 +21,15 @@ import {
export function IntegrationsSettingsLink() {
const { t } = useTranslation("openhands");
const { active } = useActiveBackendContext();
- const { backend } = active;
+ const { backend, orgId } = active;
if (isNoBackend(backend) || backend.kind !== "cloud") return null;
if (getLockedCloudHost() !== null) return null;
- const integrationsUrl = `${backend.host.replace(/\/+$/, "")}/settings/integrations`;
+ // `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 orgQuery = orgId ? `?org=${encodeURIComponent(orgId)}` : "";
+ const integrationsUrl = `${backend.host.replace(/\/+$/, "")}/settings/integrations${orgQuery}`;
return (
<a