🙌 OpenHands: AI-Driven Development
feat: add deployment-choice modal for GitHub and Slack responders (#1379)
Hiep Le8d8ae5f8a051
diff --git a/__tests__/components/automations/recommended-automations.test.tsx b/__tests__/components/automations/recommended-automations.test.tsxindex e1154c174b..b270ee2b39 100644--- a/__tests__/components/automations/recommended-automations.test.tsx+++ b/__tests__/components/automations/recommended-automations.test.tsx@@ -367,6 +367,7 @@ describe("recommended automations", () => {fireEvent.click(screen.getByTestId("recommended-automation-card-github-pr-reviewer"),);+ fireEvent.click(screen.getByTestId("responder-deployment-continue-local"));const modal = await screen.findByTestId("mcp-install-modal");expect(modal).toHaveAttribute("data-marketplace-id", "github");@@ -393,6 +394,7 @@ describe("recommended automations", () => {fireEvent.click(screen.getByTestId("recommended-automation-card-github-pr-reviewer"),);+ fireEvent.click(screen.getByTestId("responder-deployment-continue-local"));expect(mockCreateConversationMutate).toHaveBeenCalledTimes(1);expect(screen.queryByTestId("mcp-install-modal")).not.toBeInTheDocument();@@ -404,18 +406,21 @@ describe("recommended automations", () => {expect(draft).toBeTruthy();});- it("ignores repeated card clicks while a recommendation launch is in flight", () => {+ it("ignores repeated launches once a responder deployment choice is in flight", () => {mockUseSettings.mockReturnValue({data: settingsWithGithubMcp(),});renderLauncher();- const card = screen.getByTestId(- "recommended-automation-card-github-pr-reviewer",+ fireEvent.click(+ screen.getByTestId("recommended-automation-card-github-pr-reviewer"),+ );+ fireEvent.click(screen.getByTestId("responder-deployment-continue-local"));+ // The launch is now in flight; re-selecting the card must not launch again.+ fireEvent.click(+ screen.getByTestId("recommended-automation-card-github-pr-reviewer"),);- fireEvent.click(card);- fireEvent.click(card);expect(mockCreateConversationMutate).toHaveBeenCalledTimes(1);});@@ -441,6 +446,7 @@ describe("recommended automations", () => {fireEvent.click(screen.getByTestId("recommended-automation-card-github-pr-reviewer"),);+ fireEvent.click(screen.getByTestId("responder-deployment-continue-local"));await screen.findByTestId("mcp-install-modal");fireEvent.change(screen.getByTestId("mcp-install-field-api_key"), {@@ -453,6 +459,40 @@ describe("recommended automations", () => {expect(mockCreateConversationMutate).toHaveBeenCalledTimes(1),);});++ it("opens the OpenHands Cloud integrations page without launching when the cloud option is chosen", () => {+ const openSpy = vi.spyOn(window, "open").mockReturnValue(null);++ renderLauncher();++ fireEvent.click(+ screen.getByTestId("recommended-automation-card-github-pr-reviewer"),+ );+ fireEvent.click(+ screen.getByTestId("responder-deployment-open-openhands-cloud"),+ );++ expect(openSpy).toHaveBeenCalledWith(+ "https://app.all-hands.dev/settings/integrations",+ "_blank",+ "noopener,noreferrer",+ );+ expect(mockCreateConversationMutate).not.toHaveBeenCalled();++ openSpy.mockRestore();+ });++ it("does not show the deployment choice modal for non-responder automations", () => {+ renderLauncher();++ fireEvent.click(+ screen.getByTestId("recommended-automation-card-linear-triage-assistant"),+ );++ expect(+ screen.queryByTestId("responder-deployment-modal"),+ ).not.toBeInTheDocument();+ });});describe("buildAutomationPrompt", () => {diff --git a/__tests__/utils/responder-deployment.test.ts b/__tests__/utils/responder-deployment.test.tsnew file mode 100644index 0000000000..eea1c128f6--- /dev/null+++ b/__tests__/utils/responder-deployment.test.ts@@ -0,0 +1,49 @@+import { describe, expect, it } from "vitest";+import { AUTOMATION_CATALOG } from "@openhands/extensions/automations";+import {+ OPENHANDS_CLOUD_INTEGRATIONS_URL,+ isResponderAutomation,+ resolveResponderDeploymentOption,+} from "#/utils/responder-deployment";++const automationById = (id: string) =>+ AUTOMATION_CATALOG.find((automation) => automation.id === id)!;++describe("isResponderAutomation", () => {+ it("matches pure GitHub/Slack automations and excludes multi-tool or other integrations", () => {+ // Arrange / Act / Assert — representative pure GitHub/Slack responders.+ expect(isResponderAutomation(automationById("github-pr-reviewer"))).toBe(+ true,+ );+ expect(isResponderAutomation(automationById("slack-channel-monitor"))).toBe(+ true,+ );+ expect(isResponderAutomation(automationById("slack-standup-digest"))).toBe(+ true,+ );+ // Multi-tool digest (slack + linear + notion) is not a pure responder.+ expect(+ isResponderAutomation(automationById("incident-retrospective-drafter")),+ ).toBe(false);+ // No GitHub/Slack integration at all.+ expect(+ isResponderAutomation(automationById("linear-triage-assistant")),+ ).toBe(false);+ });+});++describe("resolveResponderDeploymentOption", () => {+ it("resolves each supported target to its action and rejects unsupported targets", () => {+ expect(resolveResponderDeploymentOption("local").action).toEqual({+ kind: "launch-local",+ });+ expect(resolveResponderDeploymentOption("openhands-cloud").action).toEqual({+ kind: "open-url",+ url: OPENHANDS_CLOUD_INTEGRATIONS_URL,+ });+ expect(OPENHANDS_CLOUD_INTEGRATIONS_URL).toBe(+ "https://app.all-hands.dev/settings/integrations",+ );+ expect(() => resolveResponderDeploymentOption("user-cloud")).toThrow();+ });+});diff --git a/src/components/features/automations/recommended-automations-launcher.tsx b/src/components/features/automations/recommended-automations-launcher.tsxindex 1ceb5c091c..dda3fee479 100644--- a/src/components/features/automations/recommended-automations-launcher.tsx+++ b/src/components/features/automations/recommended-automations-launcher.tsx@@ -23,7 +23,9 @@ import {} from "#/utils/mcp-marketplace-utils";import { InstallServerModal } from "#/components/features/mcp-page/install-server-modal";import { useTracking } from "#/hooks/use-tracking";+import { isResponderAutomation } from "#/utils/responder-deployment";import { RecommendedAutomationsSection } from "./recommended-automations-section";+import { ResponderDeploymentModal } from "./responder-deployment-modal";interface RecommendedAutomationsLauncherProps {query?: string;@@ -65,6 +67,8 @@ export function RecommendedAutomationsLauncher({);const [pendingAutomation, setPendingAutomation] =useState<RecommendedAutomation | null>(null);+ const [deploymentChoiceAutomation, setDeploymentChoiceAutomation] =+ useState<RecommendedAutomation | null>(null);const [installQueue, setInstallQueue] = useState<MarketplaceEntry[]>([]);const completedInstallRef = useRef(false);const launchInFlightRef = useRef(false);@@ -135,24 +139,53 @@ export function RecommendedAutomationsLauncher({[installedMcpServers],);+ const proceedWithLocalLaunch = (automation: RecommendedAutomation) => {+ const missingEntries = getMissingEntries(automation);+ if (missingEntries.length === 0) {+ launchAutomation(automation);+ return;+ }++ setPendingAutomation(automation);+ setInstallQueue(missingEntries);+ };+const handleSelectAutomation = (automation: RecommendedAutomation) => {if (launchInFlightRef.current ||createConversation.isPending ||isCreatingConversation ||- installQueue.length > 0+ installQueue.length > 0 ||+ deploymentChoiceAutomation !== null) {return;}- const missingEntries = getMissingEntries(automation);- if (missingEntries.length === 0) {- launchAutomation(automation);+ // GitHub/Slack responders poll continuously; let the user choose where the+ // responder runs before committing to the local setup flow.+ if (isResponderAutomation(automation)) {+ setDeploymentChoiceAutomation(automation);return;}- setPendingAutomation(automation);- setInstallQueue(missingEntries);+ proceedWithLocalLaunch(automation);+ };++ const handleDeploymentContinueLocal = () => {+ const automation = deploymentChoiceAutomation;+ setDeploymentChoiceAutomation(null);+ if (automation) {+ proceedWithLocalLaunch(automation);+ }+ };++ const handleDeploymentOpenUrl = (url: string) => {+ setDeploymentChoiceAutomation(null);+ window.open(url, "_blank", "noopener,noreferrer");+ };++ const handleDeploymentClose = () => {+ setDeploymentChoiceAutomation(null);};const cancelInstallFlow = () => {@@ -206,6 +239,13 @@ export function RecommendedAutomationsLauncher({onSuccess={handleInstallSuccess}/>)}++ <ResponderDeploymentModal+ isOpen={deploymentChoiceAutomation !== null}+ onClose={handleDeploymentClose}+ onContinueLocal={handleDeploymentContinueLocal}+ onOpenUrl={handleDeploymentOpenUrl}+ /></>);}diff --git a/src/components/features/automations/responder-deployment-modal.tsx b/src/components/features/automations/responder-deployment-modal.tsxnew file mode 100644index 0000000000..85fc5e6613--- /dev/null+++ b/src/components/features/automations/responder-deployment-modal.tsx@@ -0,0 +1,93 @@+import { useTranslation } from "react-i18next";+import { ModalBackdrop } from "#/components/shared/modals/modal-backdrop";+import { ModalCloseButton } from "#/components/shared/modals/modal-close-button";+import { BrandButton } from "#/components/features/settings/brand-button";+import { I18nKey } from "#/i18n/declaration";+import { cn } from "#/utils/utils";+import { modalTitleLgClassName } from "#/utils/modal-classes";+import {+ VISIBLE_RESPONDER_DEPLOYMENT_TARGETS,+ resolveResponderDeploymentOption,+} from "#/utils/responder-deployment";++interface ResponderDeploymentModalProps {+ isOpen: boolean;+ onClose: () => void;+ /** Fired for the "Continue with local setup" action. */+ onContinueLocal: () => void;+ /** Fired for an external-URL action (e.g. OpenHands Cloud integrations). */+ onOpenUrl: (url: string) => void;+}++export function ResponderDeploymentModal({+ isOpen,+ onClose,+ onContinueLocal,+ onOpenUrl,+}: ResponderDeploymentModalProps) {+ const { t } = useTranslation("openhands");++ if (!isOpen) return null;++ return (+ <ModalBackdrop+ onClose={onClose}+ aria-label={t(I18nKey.RESPONDER_DEPLOYMENT$TITLE)}+ >+ <div+ data-testid="responder-deployment-modal"+ className="relative flex w-full max-w-3xl flex-col rounded-xl border border-[var(--oh-border)] bg-base-secondary"+ >+ <ModalCloseButton+ onClose={onClose}+ testId="responder-deployment-modal-close"+ />+ <header className="flex-shrink-0 px-6 pb-4 pt-6">+ <h2 className={cn("pr-6", modalTitleLgClassName)}>+ {t(I18nKey.RESPONDER_DEPLOYMENT$TITLE)}+ </h2>+ <p className="mt-2 text-sm text-muted">+ {t(I18nKey.RESPONDER_DEPLOYMENT$DESCRIPTION)}+ </p>+ </header>+ <div className="flex flex-col gap-3 px-6 pb-6 sm:flex-row">+ {VISIBLE_RESPONDER_DEPLOYMENT_TARGETS.map((target) => {+ const option = resolveResponderDeploymentOption(target);+ const { action } = option;+ return (+ <div+ key={option.target}+ data-testid={option.testId}+ className="flex flex-1 flex-col gap-3 rounded-xl border border-[var(--oh-border)] bg-surface-raised p-4"+ >+ <div className="flex flex-col gap-1">+ <h3 className="text-sm font-semibold text-white">+ {t(option.titleKey)}+ </h3>+ <p className="text-xs leading-relaxed text-tertiary-light">+ {t(option.descriptionKey)}+ </p>+ </div>+ <BrandButton+ type="button"+ variant="primary"+ className="mt-auto"+ testId={option.primaryActionTestId}+ onClick={() => {+ if (action.kind === "launch-local") {+ onContinueLocal();+ } else {+ onOpenUrl(action.url);+ }+ }}+ >+ {t(option.primaryActionKey)}+ </BrandButton>+ </div>+ );+ })}+ </div>+ </div>+ </ModalBackdrop>+ );+}diff --git a/src/i18n/translation.json b/src/i18n/translation.jsonindex 1ecbba3304..57712d72cb 100644--- a/src/i18n/translation.json+++ b/src/i18n/translation.json@@ -31262,6 +31262,142 @@"uk": "Під час отримання налаштувань сталася помилка. Будь ласка, перезавантажте сторінку.","ca": "S'ha produït un error en obtenir la configuració. Torneu a carregar la pàgina."},+ "RESPONDER_DEPLOYMENT$TITLE": {+ "ar": "اختر كيفية تشغيل المُستجيب",+ "ca": "Tria com s'executarà el teu responedor",+ "de": "Wählen Sie, wie Ihr Responder ausgeführt werden soll",+ "en": "Choose how your responder should run",+ "es": "Elige cómo se ejecutará tu respondedor",+ "fr": "Choisissez comment exécuter votre répondeur",+ "it": "Scegli come eseguire il tuo responder",+ "ja": "レスポンダーの実行方法を選択",+ "ko-KR": "응답기 실행 방식 선택",+ "no": "Velg hvordan responderen skal kjøre",+ "pt": "Escolha como o seu respondedor deve ser executado",+ "tr": "Yanıtlayıcınızın nasıl çalışacağını seçin",+ "uk": "Виберіть, як має працювати ваш відповідач",+ "zh-CN": "选择响应程序的运行方式",+ "zh-TW": "選擇回應程式的執行方式"+ },+ "RESPONDER_DEPLOYMENT$DESCRIPTION": {+ "ar": "تعمل مُستجيبات Slack وGitHub على أفضل وجه عندما تتمكن من الاستماع إلى الأحداث باستمرار. يمكنك تشغيل المُستجيب محليًا، أو الاتصال بـ OpenHands Cloud حتى يتمكن من مواصلة الاستجابة حتى عندما يكون حاسوبك المحمول مغلقًا.",+ "ca": "Els responedors de Slack i GitHub funcionen millor quan poden escoltar esdeveniments contínuament. Pots executar el responedor localment o connectar OpenHands Cloud perquè continuï responent fins i tot quan el teu portàtil estigui tancat.",+ "de": "Slack- und GitHub-Responder funktionieren am besten, wenn sie kontinuierlich auf Ereignisse warten können. Sie können den Responder lokal ausführen oder OpenHands Cloud verbinden, damit er auch dann weiter antwortet, wenn Ihr Laptop geschlossen ist.",+ "en": "Slack and GitHub responders work best when they can listen for events continuously. You can run the responder locally, or connect OpenHands Cloud so it can keep responding even when your laptop is closed.",+ "es": "Los respondedores de Slack y GitHub funcionan mejor cuando pueden escuchar eventos de forma continua. Puedes ejecutar el respondedor localmente o conectar OpenHands Cloud para que siga respondiendo incluso cuando tu portátil esté cerrado.",+ "fr": "Les répondeurs Slack et GitHub fonctionnent mieux lorsqu'ils peuvent écouter les événements en continu. Vous pouvez exécuter le répondeur localement, ou connecter OpenHands Cloud pour qu'il continue de répondre même lorsque votre ordinateur portable est fermé.",+ "it": "I responder di Slack e GitHub funzionano al meglio quando possono restare in ascolto degli eventi in modo continuo. Puoi eseguire il responder localmente oppure collegare OpenHands Cloud così da continuare a rispondere anche quando il tuo laptop è chiuso.",+ "ja": "SlackとGitHubのレスポンダーは、イベントを継続的に監視できるときに最も効果を発揮します。レスポンダーをローカルで実行するか、OpenHands Cloudに接続すれば、ノートパソコンを閉じていても応答し続けられます。",+ "ko-KR": "Slack 및 GitHub 응답기는 이벤트를 지속적으로 수신할 수 있을 때 가장 잘 작동합니다. 응답기를 로컬에서 실행하거나 OpenHands Cloud에 연결하면 노트북을 닫아도 계속 응답할 수 있습니다.",+ "no": "Slack- og GitHub-respondere fungerer best når de kan lytte etter hendelser kontinuerlig. Du kan kjøre responderen lokalt, eller koble til OpenHands Cloud slik at den kan fortsette å svare selv når den bærbare datamaskinen er lukket.",+ "pt": "Os respondedores do Slack e do GitHub funcionam melhor quando podem ouvir eventos continuamente. Você pode executar o respondedor localmente ou conectar o OpenHands Cloud para que ele continue respondendo mesmo quando o seu laptop estiver fechado.",+ "tr": "Slack ve GitHub yanıtlayıcıları, olayları sürekli dinleyebildiklerinde en iyi şekilde çalışır. Yanıtlayıcıyı yerel olarak çalıştırabilir veya OpenHands Cloud'a bağlayarak dizüstü bilgisayarınız kapalıyken bile yanıt vermeye devam etmesini sağlayabilirsiniz.",+ "uk": "Відповідачі Slack і GitHub працюють найкраще, коли можуть безперервно слухати події. Ви можете запускати відповідач локально або підключити OpenHands Cloud, щоб він продовжував відповідати навіть коли ваш ноутбук закрито.",+ "zh-CN": "当能够持续监听事件时,Slack 和 GitHub 响应程序的效果最佳。你可以在本地运行响应程序,或连接 OpenHands Cloud,这样即使合上笔记本电脑它也能继续响应。",+ "zh-TW": "當能夠持續監聽事件時,Slack 與 GitHub 回應程式的效果最佳。你可以在本機執行回應程式,或連接 OpenHands Cloud,這樣即使闔上筆記型電腦也能持續回應。"+ },+ "RESPONDER_DEPLOYMENT$LOCAL_TITLE": {+ "ar": "الاستقصاء محليًا على حاسوبك المحمول",+ "ca": "Sondeja localment al teu portàtil",+ "de": "Lokal auf Ihrem Laptop abfragen",+ "en": "Poll locally on your laptop",+ "es": "Sondear localmente en tu portátil",+ "fr": "Interroger localement sur votre ordinateur portable",+ "it": "Esegui il polling localmente sul tuo laptop",+ "ja": "ノートパソコンでローカルにポーリング",+ "ko-KR": "노트북에서 로컬로 폴링",+ "no": "Avspør lokalt på den bærbare datamaskinen",+ "pt": "Fazer polling localmente no seu laptop",+ "tr": "Dizüstü bilgisayarınızda yerel olarak yoklayın",+ "uk": "Опитування локально на вашому ноутбуці",+ "zh-CN": "在你的笔记本电脑上本地轮询",+ "zh-TW": "在你的筆記型電腦上本機輪詢"+ },+ "RESPONDER_DEPLOYMENT$LOCAL_DESCRIPTION": {+ "ar": "يُبقي كل شيء على جهازك، لكنه يتوقف عن الاستقصاء عند إيقاف تشغيل حاسوبك المحمول.",+ "ca": "Manté tot al teu equip, però atura el sondeig quan el teu portàtil està apagat.",+ "de": "Behält alles auf Ihrem Gerät, stoppt die Abfrage jedoch, wenn Ihr Laptop ausgeschaltet ist.",+ "en": "Keeps everything on your machine, but stops polling when your laptop is off.",+ "es": "Mantiene todo en tu equipo, pero deja de sondear cuando tu portátil está apagado.",+ "fr": "Conserve tout sur votre machine, mais cesse d'interroger lorsque votre ordinateur portable est éteint.",+ "it": "Mantiene tutto sul tuo dispositivo, ma interrompe il polling quando il laptop è spento.",+ "ja": "すべてをマシン上に保持しますが、ノートパソコンの電源が切れるとポーリングを停止します。",+ "ko-KR": "모든 것을 사용자의 기기에 유지하지만, 노트북이 꺼지면 폴링을 중지합니다.",+ "no": "Holder alt på maskinen din, men slutter å avspørre når den bærbare datamaskinen er av.",+ "pt": "Mantém tudo na sua máquina, mas para de fazer polling quando o seu laptop está desligado.",+ "tr": "Her şeyi cihazınızda tutar, ancak dizüstü bilgisayarınız kapalıyken yoklamayı durdurur.",+ "uk": "Зберігає все на вашому пристрої, але припиняє опитування, коли ваш ноутбук вимкнено.",+ "zh-CN": "将所有内容保留在你的设备上,但当笔记本电脑关闭时会停止轮询。",+ "zh-TW": "將所有內容保留在你的裝置上,但當筆記型電腦關閉時會停止輪詢。"+ },+ "RESPONDER_DEPLOYMENT$LOCAL_ACTION": {+ "ar": "المتابعة بالإعداد المحلي",+ "ca": "Continua amb la configuració local",+ "de": "Mit lokaler Einrichtung fortfahren",+ "en": "Continue with local setup",+ "es": "Continuar con la configuración local",+ "fr": "Continuer avec la configuration locale",+ "it": "Continua con la configurazione locale",+ "ja": "ローカルセットアップを続行",+ "ko-KR": "로컬 설정으로 계속",+ "no": "Fortsett med lokalt oppsett",+ "pt": "Continuar com a configuração local",+ "tr": "Yerel kurulumla devam et",+ "uk": "Продовжити з локальним налаштуванням",+ "zh-CN": "继续本地设置",+ "zh-TW": "繼續本機設定"+ },+ "RESPONDER_DEPLOYMENT$OPENHANDS_CLOUD_TITLE": {+ "ar": "استخدام OpenHands Cloud",+ "ca": "Utilitza OpenHands Cloud",+ "de": "OpenHands Cloud verwenden",+ "en": "Use OpenHands Cloud",+ "es": "Usar OpenHands Cloud",+ "fr": "Utiliser OpenHands Cloud",+ "it": "Usa OpenHands Cloud",+ "ja": "OpenHands Cloudを使用",+ "ko-KR": "OpenHands Cloud 사용",+ "no": "Bruk OpenHands Cloud",+ "pt": "Usar o OpenHands Cloud",+ "tr": "OpenHands Cloud'u kullan",+ "uk": "Використовувати OpenHands Cloud",+ "zh-CN": "使用 OpenHands Cloud",+ "zh-TW": "使用 OpenHands Cloud"+ },+ "RESPONDER_DEPLOYMENT$OPENHANDS_CLOUD_DESCRIPTION": {+ "ar": "يستجيب دائمًا حتى عندما يكون حاسوبك المحمول مغلقًا.",+ "ca": "Respon sempre, fins i tot quan el teu portàtil està tancat.",+ "de": "Antwortet immer, selbst wenn Ihr Laptop geschlossen ist.",+ "en": "Always responds even when your laptop is closed.",+ "es": "Responde siempre, incluso cuando tu portátil está cerrado.",+ "fr": "Répond toujours, même lorsque votre ordinateur portable est fermé.",+ "it": "Risponde sempre, anche quando il tuo laptop è chiuso.",+ "ja": "ノートパソコンを閉じていても常に応答します。",+ "ko-KR": "노트북을 닫아도 항상 응답합니다.",+ "no": "Svarer alltid, selv når den bærbare datamaskinen er lukket.",+ "pt": "Responde sempre, mesmo quando o seu laptop está fechado.",+ "tr": "Dizüstü bilgisayarınız kapalı olsa bile her zaman yanıt verir.",+ "uk": "Завжди відповідає, навіть коли ваш ноутбук закрито.",+ "zh-CN": "即使合上笔记本电脑也始终响应。",+ "zh-TW": "即使闔上筆記型電腦也始終回應。"+ },+ "RESPONDER_DEPLOYMENT$OPENHANDS_CLOUD_ACTION": {+ "ar": "فتح تكاملات OpenHands Cloud",+ "ca": "Obre les integracions d'OpenHands Cloud",+ "de": "OpenHands Cloud-Integrationen öffnen",+ "en": "Open OpenHands Cloud integrations",+ "es": "Abrir las integraciones de OpenHands Cloud",+ "fr": "Ouvrir les intégrations OpenHands Cloud",+ "it": "Apri le integrazioni di OpenHands Cloud",+ "ja": "OpenHands Cloudの連携を開く",+ "ko-KR": "OpenHands Cloud 통합 열기",+ "no": "Åpne OpenHands Cloud-integrasjoner",+ "pt": "Abrir as integrações do OpenHands Cloud",+ "tr": "OpenHands Cloud entegrasyonlarını aç",+ "uk": "Відкрити інтеграції OpenHands Cloud",+ "zh-CN": "打开 OpenHands Cloud 集成",+ "zh-TW": "開啟 OpenHands Cloud 整合"+ },"BUTTON$COLLAPSE_DETAILS": {"en": "Collapse details","zh-CN": "收起详情",diff --git a/src/utils/responder-deployment.ts b/src/utils/responder-deployment.tsnew file mode 100644index 0000000000..f116bf81b9--- /dev/null+++ b/src/utils/responder-deployment.ts@@ -0,0 +1,97 @@+import type { RecommendedAutomation } from "@openhands/extensions/automations";+import { I18nKey } from "#/i18n/declaration";+import { PRODUCT_URL } from "#/utils/constants";++/** OpenHands Cloud integrations page — where always-on responders are set up. */+export const OPENHANDS_CLOUD_INTEGRATIONS_URL = `${PRODUCT_URL.PRODUCTION}/settings/integrations`;++/**+ * Integrations whose automations are treated as event "responders" that poll+ * continuously. A responder is an automation whose required integrations are+ * exclusively from this set, so multi-tool digests (e.g. slack + linear ++ * notion) are not treated as Slack responders.+ */+const RESPONDER_INTEGRATION_IDS = ["github", "slack"];++/**+ * Single source of truth for "does this automation get the deployment-choice+ * modal?" — true only for pure GitHub/Slack responders.+ */+export function isResponderAutomation(+ automation: RecommendedAutomation,+): boolean {+ const ids = automation.requiredIntegrationIds;+ return (+ ids.length > 0 && ids.every((id) => RESPONDER_INTEGRATION_IDS.includes(id))+ );+}++/**+ * Where a responder runs. Only `local` and `openhands-cloud` are wired today;+ * `user-cloud` is reserved for a future remote-deployment target.+ */+export type ResponderDeploymentTarget =+ | "local"+ | "user-cloud"+ | "openhands-cloud";++/** What the launcher should do when an option's primary action fires. */+export type ResponderDeploymentAction =+ | { kind: "launch-local" }+ | { kind: "open-url"; url: string };++/** Presentational + behavioral descriptor for one deployment option. */+export interface ResponderDeploymentOption {+ target: ResponderDeploymentTarget;+ testId: string;+ titleKey: I18nKey;+ descriptionKey: I18nKey;+ primaryActionKey: I18nKey;+ primaryActionTestId: string;+ action: ResponderDeploymentAction;+}++/**+ * Centralized runtime-selection mechanism. Returns a descriptor (data) rather+ * than executing behavior, so the side effects stay with the launcher that owns+ * the relevant state. Adding a target later means adding a `case` here and an+ * entry to {@link VISIBLE_RESPONDER_DEPLOYMENT_TARGETS}; the `never` check makes+ * an unhandled target a compile error.+ */+export function resolveResponderDeploymentOption(+ target: ResponderDeploymentTarget,+): ResponderDeploymentOption {+ switch (target) {+ case "local":+ return {+ target,+ testId: "responder-deployment-option-local",+ titleKey: I18nKey.RESPONDER_DEPLOYMENT$LOCAL_TITLE,+ descriptionKey: I18nKey.RESPONDER_DEPLOYMENT$LOCAL_DESCRIPTION,+ primaryActionKey: I18nKey.RESPONDER_DEPLOYMENT$LOCAL_ACTION,+ primaryActionTestId: "responder-deployment-continue-local",+ action: { kind: "launch-local" },+ };+ case "openhands-cloud":+ return {+ target,+ testId: "responder-deployment-option-openhands-cloud",+ titleKey: I18nKey.RESPONDER_DEPLOYMENT$OPENHANDS_CLOUD_TITLE,+ descriptionKey:+ I18nKey.RESPONDER_DEPLOYMENT$OPENHANDS_CLOUD_DESCRIPTION,+ primaryActionKey: I18nKey.RESPONDER_DEPLOYMENT$OPENHANDS_CLOUD_ACTION,+ primaryActionTestId: "responder-deployment-open-openhands-cloud",+ action: { kind: "open-url", url: OPENHANDS_CLOUD_INTEGRATIONS_URL },+ };+ case "user-cloud":+ throw new Error("User Cloud responder deployment is not yet supported");+ default: {+ const exhaustive: never = target;+ return exhaustive;+ }+ }+}++/** Targets the modal renders today, in display order (excludes `user-cloud`). */+export const VISIBLE_RESPONDER_DEPLOYMENT_TARGETS: ResponderDeploymentTarget[] =+ ["local", "openhands-cloud"];diff --git a/tests/e2e/mock-llm/automations/mock-llm-preset-automation.spec.ts b/tests/e2e/mock-llm/automations/mock-llm-preset-automation.spec.tsindex fde5f6d5d1..73a6613960 100644--- a/tests/e2e/mock-llm/automations/mock-llm-preset-automation.spec.ts+++ b/tests/e2e/mock-llm/automations/mock-llm-preset-automation.spec.ts@@ -10,8 +10,9 @@** Two tests:* 1. **Card flow**: configure a dummy Slack MCP server so the automation- * card is launchable, click the card, verify it sends the correct- * slash command and triggers skill activation.+ * card is launchable, click the card, choose "Poll locally" in the+ * responder-deployment modal, then verify it sends the correct slash+ * command and triggers skill activation.* 2. **Direct slash command**: send the slash command from the home page* (no MCP needed), verify skill activation + agent reply.*/@@ -194,6 +195,15 @@ test.describe("preset automation → slash command conversation", () => {await card.click();});+ // Slack/GitHub responders now prompt for a deployment target first.+ // Choose "Poll locally on your laptop" to resume the existing local+ // setup + launch flow this test exercises.+ await test.step("choose local deployment", async () => {+ const modal = page.getByTestId("responder-deployment-modal");+ await expect(modal).toBeVisible({ timeout: 10_000 });+ await page.getByTestId("responder-deployment-continue-local").click();+ });+// Should navigate to a new conversationawait waitForPath(page, /\/conversations\/.+/, 30_000);const conversationId = getConversationIdFromURL(page);