Skip to content

🙌 OpenHands: AI-Driven Development

style(automations): tab the setup choice modal between native and MCP server (#18833)

FraterCCCLXIII6be67b820bc3
diff --git a/__tests__/components/automations/recommended-automations.test.tsx b/__tests__/components/automations/recommended-automations.test.tsx
index b25319d5e5..ec8977a567 100644
--- a/__tests__/components/automations/recommended-automations.test.tsx
+++ b/__tests__/components/automations/recommended-automations.test.tsx
@@ -1133,11 +1133,12 @@ describe("recommended automations", () => {
);
// Assert
- expect(
- await screen.findByTestId("built-in-integration-choice-modal"),
- ).toHaveTextContent(
- `AUTOMATION_SETUP_CHOICE$BUILT_IN_TITLE:${integrationName}`,
+ const modal = await screen.findByTestId(
+ "built-in-integration-choice-modal",
);
+ expect(
+ within(modal).getByRole("heading", { level: 3, name: integrationName }),
+ ).toBeInTheDocument();
expect(mockNavigate).not.toHaveBeenCalled();
expect(screen.queryByTestId("mcp-install-modal")).not.toBeInTheDocument();
},
@@ -1170,6 +1171,73 @@ describe("recommended automations", () => {
expect(mockCreateConversationMutate).not.toHaveBeenCalled();
});
+ it("shows a connected user how to use the built-in integration and closes without opening its settings", async () => {
+ // Arrange
+ const openSpy = vi.spyOn(window, "open").mockImplementation(() => null);
+ openSpy.mockClear();
+ await activateCloudBackend({
+ providersConfigured: ["github"],
+ settings: { provider_tokens_set: { github: null } },
+ });
+ renderLauncher({ withBackendProvider: true });
+ // Wait until the settings show GitHub as connected.
+ await within(
+ await screen.findByTestId(
+ "recommended-automation-pills-github-repo-monitor-wrap",
+ ),
+ ).findByText("RECOMMENDED_AUTOMATIONS$CONNECTED");
+ fireEvent.click(
+ screen.getByTestId("recommended-automation-card-github-issue-to-pr"),
+ );
+ expect(
+ await screen.findByTestId("built-in-integration-choice-example"),
+ ).toBeInTheDocument();
+
+ // Act
+ fireEvent.click(
+ screen.getByTestId("built-in-integration-choice-use-built-in"),
+ );
+
+ // Assert
+ expect(openSpy).not.toHaveBeenCalled();
+ expect(
+ screen.queryByTestId("built-in-integration-choice-modal"),
+ ).not.toBeInTheDocument();
+ expect(mockNavigate).not.toHaveBeenCalled();
+ });
+
+ it("shows the native integration first and the MCP server on its own tab", async () => {
+ // Arrange
+ await activateCloudBackend({ providersConfigured: ["gitlab"] });
+ renderLauncher({ withBackendProvider: true });
+ fireEvent.click(
+ await screen.findByTestId(
+ "recommended-automation-card-gitlab-issue-to-mr",
+ ),
+ );
+
+ // Assert: the native tab leads and the polling option is hidden
+ expect(
+ await screen.findByTestId("built-in-integration-choice-option-built-in"),
+ ).toBeInTheDocument();
+ expect(
+ screen.queryByTestId("built-in-integration-choice-option-polling"),
+ ).not.toBeInTheDocument();
+
+ // Act
+ fireEvent.click(
+ screen.getByTestId("built-in-integration-choice-tab-polling"),
+ );
+
+ // Assert
+ expect(
+ screen.getByTestId("built-in-integration-choice-option-polling"),
+ ).toBeInTheDocument();
+ expect(
+ screen.queryByTestId("built-in-integration-choice-option-built-in"),
+ ).not.toBeInTheDocument();
+ });
+
it("connects the integration through its MCP server when the polling automation is chosen", async () => {
// Arrange
await activateCloudBackend({ providersConfigured: ["gitlab"] });
@@ -1181,6 +1249,9 @@ describe("recommended automations", () => {
);
// Act
+ fireEvent.click(
+ await screen.findByTestId("built-in-integration-choice-tab-polling"),
+ );
fireEvent.click(
await screen.findByTestId("built-in-integration-choice-continue-polling"),
);
diff --git a/src/components/features/automations/built-in-integration-choice-modal.tsx b/src/components/features/automations/built-in-integration-choice-modal.tsx
index c0d3b8addc..f74f5c1ef5 100644
--- a/src/components/features/automations/built-in-integration-choice-modal.tsx
+++ b/src/components/features/automations/built-in-integration-choice-modal.tsx
@@ -1,3 +1,4 @@
+import React from "react";
import { useTranslation } from "react-i18next";
import {
ArrowRight,
@@ -14,8 +15,8 @@ import { BrandButton } from "#/components/features/settings/brand-button";
import { McpLogoBadge } from "#/components/features/mcp-logo-badge";
import { I18nKey } from "#/i18n/declaration";
import { cn } from "#/utils/utils";
-import { extensionModuleCardPillClassName } from "#/utils/extension-module-card-classes";
import { modalTitleLgClassName } from "#/utils/modal-classes";
+import { pillToggleClassName } from "#/utils/pill-toggle-classes";
/**
* Whether the current user has already connected the built-in integration
@@ -58,7 +59,22 @@ export function BuiltInIntegrationChoiceModal({
const { t } = useTranslation("openhands");
const { name } = integration;
const isConnected = state === "connected";
+ const [selectedTab, setSelectedTab] = React.useState<"built-in" | "polling">(
+ "built-in",
+ );
+ const tabs = [
+ {
+ id: "built-in" as const,
+ label: t(I18nKey.AUTOMATION_SETUP_CHOICE$BUILT_IN_TAB),
+ recommended: true,
+ },
+ {
+ id: "polling" as const,
+ label: t(I18nKey.AUTOMATION_SETUP_CHOICE$MCP_TAB),
+ recommended: false,
+ },
+ ];
const builtInFeatures = [
t(I18nKey.AUTOMATION_SETUP_CHOICE$BUILT_IN_FEATURE_READY),
t(I18nKey.AUTOMATION_SETUP_CHOICE$BUILT_IN_FEATURE_EVENT_DRIVEN),
@@ -86,7 +102,7 @@ export function BuiltInIntegrationChoiceModal({
>
<div
data-testid="built-in-integration-choice-modal"
- className="relative flex w-full max-w-3xl flex-col rounded-xl border border-border bg-base-secondary"
+ className="relative flex w-[92vw] max-w-xl flex-col rounded-xl border border-border bg-base-secondary"
>
<ModalCloseButton
onClose={onClose}
@@ -105,109 +121,160 @@ export function BuiltInIntegrationChoiceModal({
)}
</p>
</header>
- <div className="flex flex-col gap-3 px-6 pb-6 sm:flex-row">
- <div
- data-testid="built-in-integration-choice-option-built-in"
- className="flex flex-1 flex-col gap-3 rounded-xl border border-border bg-surface-raised p-4"
- >
- <div className="flex items-start justify-between gap-2">
- <McpLogoBadge entry={integration} />
- <span className={extensionModuleCardPillClassName}>
- {t(I18nKey.SETTINGS$SKILLS_RECOMMENDED)}
- </span>
- </div>
- <div className="flex flex-col gap-1">
- <h3 className="text-sm font-semibold text-contrast">
- {t(I18nKey.AUTOMATION_SETUP_CHOICE$BUILT_IN_TITLE, { name })}
- </h3>
- <p className="text-xs leading-relaxed text-tertiary-light">
- {t(I18nKey.AUTOMATION_SETUP_CHOICE$BUILT_IN_DESCRIPTION, {
- name,
- })}
- </p>
- </div>
- {isConnected ? (
- <code
- data-testid="built-in-integration-choice-example"
- className="block rounded-md border border-border-subtle bg-base-secondary px-3 py-2 font-mono text-xs text-contrast"
+ <div
+ role="tablist"
+ aria-label={t(I18nKey.AUTOMATION_SETUP_CHOICE$TITLE)}
+ className="flex w-full flex-wrap items-center gap-2 px-6"
+ >
+ {tabs.map(({ id, label, recommended }) => {
+ const isActive = selectedTab === id;
+ return (
+ <button
+ key={id}
+ type="button"
+ role="tab"
+ id={`built-in-integration-choice-tab-${id}`}
+ aria-selected={isActive}
+ aria-controls={`built-in-integration-choice-panel-${id}`}
+ data-testid={`built-in-integration-choice-tab-${id}`}
+ onClick={() => setSelectedTab(id)}
+ className={cn(
+ pillToggleClassName(isActive),
+ "flex-1 justify-center text-center",
+ )}
>
- {USAGE_EXAMPLE}
- </code>
- ) : (
- <ul className="flex flex-col gap-2">
- {builtInFeatures.map((feature) => (
+ {label}
+ {recommended && (
+ <span
+ className={cn(
+ "shrink-0 rounded-full px-2 py-0.5 text-xs font-medium leading-none",
+ isActive
+ ? "bg-contrast-foreground text-contrast"
+ : "bg-contrast text-contrast-foreground",
+ )}
+ >
+ {t(I18nKey.SETTINGS$SKILLS_RECOMMENDED)}
+ </span>
+ )}
+ </button>
+ );
+ })}
+ </div>
+ <div
+ role="tabpanel"
+ id={`built-in-integration-choice-panel-${selectedTab}`}
+ aria-labelledby={`built-in-integration-choice-tab-${selectedTab}`}
+ className="px-6 pb-6 pt-4"
+ >
+ {selectedTab === "built-in" ? (
+ <div
+ data-testid="built-in-integration-choice-option-built-in"
+ className="flex flex-col gap-4 rounded-xl border border-border bg-surface-raised p-4"
+ >
+ <div className="flex items-start gap-3">
+ <McpLogoBadge entry={integration} />
+ <div className="flex flex-col gap-1">
+ <h3 className="text-sm font-semibold text-contrast">
+ {name}
+ </h3>
+ <p className="text-xs leading-relaxed text-tertiary-light">
+ {t(I18nKey.AUTOMATION_SETUP_CHOICE$BUILT_IN_DESCRIPTION, {
+ name,
+ })}
+ </p>
+ </div>
+ </div>
+ {isConnected ? (
+ <code
+ data-testid="built-in-integration-choice-example"
+ className="block rounded-md border border-border-subtle bg-base-secondary px-3 py-2 font-mono text-xs text-contrast"
+ >
+ {USAGE_EXAMPLE}
+ </code>
+ ) : (
+ <ul className="flex flex-col gap-2 py-3">
+ {builtInFeatures.map((feature) => (
+ <li
+ key={feature}
+ className="flex items-center gap-2 text-sm text-contrast"
+ >
+ <CircleCheck
+ className="size-4 shrink-0 text-success"
+ aria-hidden
+ />
+ {feature}
+ </li>
+ ))}
+ </ul>
+ )}
+ <div className="flex justify-end border-t border-border pt-4">
+ <BrandButton
+ type="button"
+ variant="primary"
+ className="flex items-center justify-center gap-2 bg-contrast text-contrast-foreground"
+ testId="built-in-integration-choice-use-built-in"
+ onClick={isConnected ? onClose : onUseBuiltIn}
+ >
+ {isConnected
+ ? t(I18nKey.BUTTON$CLOSE)
+ : t(I18nKey.AUTOMATION_SETUP_CHOICE$CONNECT_ACTION, {
+ name,
+ })}
+ {!isConnected && (
+ <ArrowRight className="size-4 shrink-0" aria-hidden />
+ )}
+ </BrandButton>
+ </div>
+ </div>
+ ) : (
+ <div
+ data-testid="built-in-integration-choice-option-polling"
+ className="flex flex-col gap-4 rounded-xl border border-border bg-surface-raised p-4"
+ >
+ <div className="flex items-start gap-3">
+ <McpLogoBadge
+ entry={null}
+ fallback={<Settings className="h-5 w-5" strokeWidth={2.25} />}
+ />
+ <div className="flex flex-col gap-1">
+ <h3 className="text-sm font-semibold text-contrast">
+ {t(I18nKey.AUTOMATION_SETUP_CHOICE$POLLING_TITLE)}
+ </h3>
+ <p className="text-xs leading-relaxed text-tertiary-light">
+ {t(I18nKey.AUTOMATION_SETUP_CHOICE$POLLING_DESCRIPTION, {
+ name,
+ })}
+ </p>
+ </div>
+ </div>
+ <ul className="flex flex-col gap-2 py-3">
+ {pollingFeatures.map(({ Icon, label }) => (
<li
- key={feature}
+ key={label}
className="flex items-center gap-2 text-sm text-contrast"
>
- <CircleCheck
+ <Icon
className="size-4 shrink-0 text-tertiary-light"
aria-hidden
/>
- {feature}
+ {label}
</li>
))}
</ul>
- )}
- <BrandButton
- type="button"
- variant="primary"
- className="mt-auto flex items-center justify-center gap-2 bg-contrast text-contrast-foreground"
- testId="built-in-integration-choice-use-built-in"
- onClick={isConnected ? onClose : onUseBuiltIn}
- >
- {isConnected
- ? t(I18nKey.CHAT_INTERFACE$BTW_GOT_IT)
- : t(I18nKey.AUTOMATION_SETUP_CHOICE$CONNECT_ACTION, { name })}
- {!isConnected && (
- <ArrowRight className="size-4 shrink-0" aria-hidden />
- )}
- </BrandButton>
- </div>
-
- <div
- data-testid="built-in-integration-choice-option-polling"
- className="flex flex-1 flex-col gap-3 rounded-xl border border-border bg-surface-raised p-4"
- >
- <McpLogoBadge
- entry={null}
- fallback={<Settings className="h-5 w-5" strokeWidth={2.25} />}
- />
- <div className="flex flex-col gap-1">
- <h3 className="text-sm font-semibold text-contrast">
- {t(I18nKey.AUTOMATION_SETUP_CHOICE$POLLING_TITLE)}
- </h3>
- <p className="text-xs leading-relaxed text-tertiary-light">
- {t(I18nKey.AUTOMATION_SETUP_CHOICE$POLLING_DESCRIPTION, {
- name,
- })}
- </p>
- </div>
- <ul className="flex flex-col gap-2">
- {pollingFeatures.map(({ Icon, label }) => (
- <li
- key={label}
- className="flex items-center gap-2 text-sm text-contrast"
+ <div className="flex justify-end border-t border-border pt-4">
+ <BrandButton
+ type="button"
+ variant="tertiary"
+ className="flex items-center justify-center gap-2"
+ testId="built-in-integration-choice-continue-polling"
+ onClick={onContinuePolling}
>
- <Icon
- className="size-4 shrink-0 text-tertiary-light"
- aria-hidden
- />
- {label}
- </li>
- ))}
- </ul>
- <BrandButton
- type="button"
- variant="tertiary"
- className="mt-auto flex items-center justify-center gap-2"
- testId="built-in-integration-choice-continue-polling"
- onClick={onContinuePolling}
- >
- {t(I18nKey.AUTOMATION_SETUP_CHOICE$POLLING_ACTION)}
- <ArrowRight className="size-4 shrink-0" aria-hidden />
- </BrandButton>
- </div>
+ {t(I18nKey.AUTOMATION_SETUP_CHOICE$POLLING_ACTION)}
+ <ArrowRight className="size-4 shrink-0" aria-hidden />
+ </BrandButton>
+ </div>
+ </div>
+ )}
</div>
</div>
</ModalBackdrop>
diff --git a/src/i18n/translation.json b/src/i18n/translation.json
index a31de48356..628b721c9b 100644
--- a/src/i18n/translation.json
+++ b/src/i18n/translation.json
@@ -41093,24 +41093,6 @@
"zh-TW": "當能夠持續監聽事件時,{{name}} 回應程式的效果最佳。請選擇符合你需求的設定方式。",
"id": "Responder {{name}} bekerja paling baik saat dapat memantau peristiwa secara terus-menerus. Pilih penyiapan yang sesuai dengan kebutuhan Anda."
},
- "AUTOMATION_SETUP_CHOICE$BUILT_IN_TITLE": {
- "ar": "استخدم تكامل {{name}} المدمج",
- "ca": "Utilitza la integració integrada de {{name}}",
- "de": "Integrierte {{name}}-Integration verwenden",
- "en": "Use Built-In {{name}} Integration",
- "es": "Usar la integración integrada de {{name}}",
- "fr": "Utiliser l'intégration {{name}} intégrée",
- "it": "Usa l'integrazione {{name}} integrata",
- "ja": "組み込みの{{name}}連携を使用",
- "ko-KR": "기본 제공 {{name}} 통합 사용",
- "no": "Bruk innebygd {{name}}-integrasjon",
- "pt": "Usar a integração nativa do {{name}}",
- "tr": "Yerleşik {{name}} entegrasyonunu kullan",
- "uk": "Використати вбудовану інтеграцію {{name}}",
- "zh-CN": "使用内置的 {{name}} 集成",
- "zh-TW": "使用內建的 {{name}} 整合",
- "id": "Gunakan Integrasi {{name}} Bawaan"
- },
"AUTOMATION_SETUP_CHOICE$BUILT_IN_DESCRIPTION": {
"ar": "الطريقة الأسرع والأبسط لإعداد مُستجيب {{name}}.",
"ca": "La manera més ràpida i senzilla de configurar un responedor de {{name}}.",
@@ -52720,5 +52702,41 @@
"uk": "Немає активного профілю агента. Виберіть його в Налаштування → Агент.",
"ca": "No hi ha cap perfil d'agent actiu. Trieu-ne un a Configuració → Agent.",
"id": "Tidak ada profil agen yang aktif. Pilih satu di Pengaturan → Agen."
+ },
+ "AUTOMATION_SETUP_CHOICE$BUILT_IN_TAB": {
+ "en": "Native Integration",
+ "ja": "ネイティブ連携",
+ "zh-CN": "原生集成",
+ "zh-TW": "原生整合",
+ "ko-KR": "네이티브 통합",
+ "no": "Innebygd integrasjon",
+ "it": "Integrazione nativa",
+ "pt": "Integração nativa",
+ "es": "Integración nativa",
+ "ar": "التكامل الأصلي",
+ "fr": "Intégration native",
+ "tr": "Yerel entegrasyon",
+ "de": "Native Integration",
+ "uk": "Нативна інтеграція",
+ "ca": "Integració nativa",
+ "id": "Integrasi Bawaan"
+ },
+ "AUTOMATION_SETUP_CHOICE$MCP_TAB": {
+ "en": "MCP Server",
+ "ja": "MCPサーバー",
+ "zh-CN": "MCP 服务器",
+ "zh-TW": "MCP 伺服器",
+ "ko-KR": "MCP 서버",
+ "no": "MCP-server",
+ "it": "Server MCP",
+ "pt": "Servidor MCP",
+ "es": "Servidor MCP",
+ "ar": "خادم MCP",
+ "fr": "Serveur MCP",
+ "tr": "MCP Sunucusu",
+ "de": "MCP-Server",
+ "uk": "Сервер MCP",
+ "ca": "Servidor MCP",
+ "id": "Server MCP"
}
}