π OpenHands: AI-Driven Development
feat(automations): hide templates that overlap built-in integrations on self-hosted instances (OHE-3611) (#18565)
Hiep Le6dbebfb3f6a6
diff --git a/src/api/cloud/settings-service.api.ts b/src/api/cloud/settings-service.api.tsindex 7bde0a975d..04d5abd5b3 100644--- a/src/api/cloud/settings-service.api.ts+++ b/src/api/cloud/settings-service.api.ts@@ -237,13 +237,22 @@ export interface CloudIntegrationsConfig {isJiraEnabled: boolean;/** Whether the built-in Linear integration is enabled. */isLinearEnabled: boolean;+ /**+ * How the instance is deployed: `cloud` for OpenHands Cloud, `self_hosted`+ * for an OpenHands Enterprise install, or null when it reports neither.+ */+ deploymentMode: string | null;}export async function fetchCloudIntegrationsConfig(): Promise<CloudIntegrationsConfig> {const backend = getActiveCloudBackend();const config = await callCloudProxy<{providers_configured?: Provider[];- feature_flags?: { enable_jira?: boolean; enable_linear?: boolean };+ feature_flags?: {+ enable_jira?: boolean;+ enable_linear?: boolean;+ deployment_mode?: string;+ };}>({backend,method: "GET",@@ -253,5 +262,6 @@ export async function fetchCloudIntegrationsConfig(): Promise<CloudIntegrationsCprovidersConfigured: config.providers_configured ?? [],isJiraEnabled: config.feature_flags?.enable_jira === true,isLinearEnabled: config.feature_flags?.enable_linear === true,+ deploymentMode: config.feature_flags?.deployment_mode ?? null,};}diff --git a/src/components/features/automations/recommended-automations-launcher.tsx b/src/components/features/automations/recommended-automations-launcher.tsxindex 5c7163dd0d..fee6c56758 100644--- a/src/components/features/automations/recommended-automations-launcher.tsx+++ b/src/components/features/automations/recommended-automations-launcher.tsx@@ -31,6 +31,7 @@ import {import { SETUP_REGISTRY } from "#/manifests/manifest-sources";import {getAutomationLaunchPrompt,+ getHiddenAutomationIds,getRequiredIntegrationIds,} from "#/utils/automation-catalog";import { isResponderAutomation } from "#/utils/responder-deployment";@@ -124,8 +125,10 @@ export function RecommendedAutomationsLauncher({getNativeIntegration,isJiraEnabled,isLinearEnabled,+ deploymentMode,isLoading: isNativeIntegrationsLoading,} = useNativeGitIntegrations();+ const hiddenAutomationIds = getHiddenAutomationIds(deploymentMode);const installedMcpConfig = useMemo(() =>@@ -365,12 +368,14 @@ export function RecommendedAutomationsLauncher({<RecommendedAutomationsRailclassName={className}installedAutomations={automationsData?.automations ?? []}+ hiddenAutomationIds={hiddenAutomationIds}onSelect={handleSelectAutomation}/>) : (<RecommendedAutomationsSectionbackendKind={activeBackend.backend.kind}installedServers={installedMcpConfig}+ hiddenAutomationIds={hiddenAutomationIds}getNativeIntegration={getNativeIntegration}query={query}onSelect={handleSelectAutomation}diff --git a/src/components/features/automations/recommended-automations-rail.tsx b/src/components/features/automations/recommended-automations-rail.tsxindex 1a7b8728eb..86bd8e447f 100644--- a/src/components/features/automations/recommended-automations-rail.tsx+++ b/src/components/features/automations/recommended-automations-rail.tsx@@ -34,6 +34,8 @@ import {interface RecommendedAutomationsRailProps {installedAutomations: readonly Pick<Automation, "name">[];+ /** Catalog entries the active backend's deployment does not offer. */+ hiddenAutomationIds?: ReadonlySet<string>;onSelect: (automation: RecommendedAutomation) => void;className?: string;}@@ -102,12 +104,13 @@ function RailIntegrationIcons({export function RecommendedAutomationsRail({installedAutomations,+ hiddenAutomationIds,onSelect,className,}: RecommendedAutomationsRailProps) {const { t } = useTranslation("openhands");const items = flattenRecommendedRailGroups(- getRecommendedRailGroups(installedAutomations),+ getRecommendedRailGroups(installedAutomations, hiddenAutomationIds),);const scrollRef = useRef<HTMLDivElement>(null);const { handleMouseDown, handleClickCapture, handleDragStart } =diff --git a/src/components/features/automations/recommended-automations-section.tsx b/src/components/features/automations/recommended-automations-section.tsxindex 5f0cb8a553..43a2bb19f6 100644--- a/src/components/features/automations/recommended-automations-section.tsx+++ b/src/components/features/automations/recommended-automations-section.tsx@@ -46,6 +46,8 @@ type GetNativeIntegration = (entryId: string) => NativeGitIntegration | null;interface RecommendedAutomationsSectionProps {backendKind: "local" | "cloud";installedServers: MCPServerConfig[];+ /** Catalog entries the active backend's deployment does not offer. */+ hiddenAutomationIds?: ReadonlySet<string>;/** Resolves an integration's native (cloud) connection; none by default. */getNativeIntegration?: GetNativeIntegration;query?: string;@@ -307,6 +309,7 @@ function AutomationCardGrid({export function RecommendedAutomationsSection({backendKind: _backendKind,installedServers,+ hiddenAutomationIds,getNativeIntegration = () => null,query = "",onSelect,@@ -314,16 +317,18 @@ export function RecommendedAutomationsSection({}: RecommendedAutomationsSectionProps) {const { t } = useTranslation("openhands");- // Only the query narrows the grid. An automation that declares no- // integration needs nothing connected, and one naming an integration this- // host cannot resolve is shown with that gap on its pill, so neither is a- // reason to hide a card the catalog ships.- const visibleAutomations = RECOMMENDED_AUTOMATIONS.filter((automation) =>- automationMatchesQuery(- automation,- getIntegrationEntries(automation),- query,- ),+ // Only the deployment's hide list and the query narrow the grid. An+ // automation that declares no integration needs nothing connected, and one+ // naming an integration this host cannot resolve is shown with that gap on+ // its pill, so neither is a reason to hide a card the catalog ships.+ const visibleAutomations = RECOMMENDED_AUTOMATIONS.filter(+ (automation) =>+ !hiddenAutomationIds?.has(automation.id) &&+ automationMatchesQuery(+ automation,+ getIntegrationEntries(automation),+ query,+ ),);if (visibleAutomations.length === 0) return null;diff --git a/src/hooks/query/use-native-git-integrations.ts b/src/hooks/query/use-native-git-integrations.tsindex 214feb98d3..d290fda7ea 100644--- a/src/hooks/query/use-native-git-integrations.ts+++ b/src/hooks/query/use-native-git-integrations.ts@@ -32,6 +32,8 @@ export function isNativeGitCandidate(entryId: string): boolean {* `isJiraEnabled` and `isLinearEnabled` are whether the instance offers the* built-in Jira Cloud and Linear integrations there; they are not git* connections, so they never satisfy an integration requirement.+ * `deploymentMode` is the instance's reported deployment mode (`cloud` or+ * `self_hosted`), null on local backends and on instances that report none.*/export function useNativeGitIntegrations() {const { backend } = useActiveBackend();@@ -67,6 +69,7 @@ export function useNativeGitIntegrations() {getNativeIntegration,isJiraEnabled: isCloud && config?.isJiraEnabled === true,isLinearEnabled: isCloud && config?.isLinearEnabled === true,+ deploymentMode: isCloud ? (config?.deploymentMode ?? null) : null,isLoading,};}diff --git a/src/utils/automation-catalog.ts b/src/utils/automation-catalog.tsindex aa7ffbeebe..a39e6f1b0d 100644--- a/src/utils/automation-catalog.ts+++ b/src/utils/automation-catalog.ts@@ -64,6 +64,36 @@ export function getRequiredIntegrationIds(.map(([id]) => id);}+/**+ * Catalog entries an OpenHands Enterprise install does not offer: each one+ * overlaps a built-in integration, depends on a user-managed secret, or is+ * covered by the Create Automation UI. They stay in the catalog for OpenHands+ * Cloud and local backends.+ */+const SELF_HOSTED_HIDDEN_AUTOMATION_IDS: ReadonlySet<string> = new Set([+ "github-repo-monitor",+ "slack-standup-digest",+ "github-issue-triage",+ "github-delivery-watchdog",+ "github-stale-ci-pr-closer",+ "custom-automation",+]);++const NO_HIDDEN_AUTOMATION_IDS: ReadonlySet<string> = new Set();++/**+ * The catalog entries to hide for a backend reporting `deploymentMode` (the+ * cloud web-client config's `feature_flags.deployment_mode`). Only a+ * self-hosted (Enterprise) instance hides anything.+ */+export function getHiddenAutomationIds(+ deploymentMode: string | null | undefined,+): ReadonlySet<string> {+ return deploymentMode === "self_hosted"+ ? SELF_HOSTED_HIDDEN_AUTOMATION_IDS+ : NO_HIDDEN_AUTOMATION_IDS;+}+/*** The command that invokes this automation's skill, or null when that skill is* invoked by description instead.diff --git a/src/utils/recommended-automation-rail.ts b/src/utils/recommended-automation-rail.tsindex ff343dfbd2..9ca633da05 100644--- a/src/utils/recommended-automation-rail.ts+++ b/src/utils/recommended-automation-rail.ts@@ -72,16 +72,20 @@ export interface RecommendedRailGroups {/*** Home / dashboard rail: remaining proven workflows, then other useful* automations that open in a new conversation. Already-created automations- * are dropped from both groups.+ * are dropped from both groups, as are the entries the active backend's+ * deployment hides (`hiddenAutomationIds`).*/export function getRecommendedRailGroups(installed: readonly Pick<Automation, "name">[],+ hiddenAutomationIds?: ReadonlySet<string>,): RecommendedRailGroups {// Every catalog entry is offerable: one that declares no integration needs// nothing connected, and one that names an integration this host cannot// resolve stays visible so the drift is actionable rather than hidden.const available = getAutomationsByPopularity(AUTOMATION_CATALOG).filter(- (entry) => !isCatalogAutomationAdded(entry, installed),+ (entry) =>+ !hiddenAutomationIds?.has(entry.id) &&+ !isCatalogAutomationAdded(entry, installed),);return {