From e073e755f93588c71617c828c540327ef176c40d Mon Sep 17 00:00:00 2001 From: yyh <92089059+lyzno1@users.noreply.github.com> Date: Tue, 25 Nov 2025 18:08:46 +0800 Subject: [PATCH] Fix start tab marketplace trigger search and plugin list scroll (#28645) --- .../block-selector/all-start-blocks.tsx | 62 ++++++++++++++++--- .../workflow/block-selector/all-tools.tsx | 2 +- 2 files changed, 54 insertions(+), 10 deletions(-) diff --git a/web/app/components/workflow/block-selector/all-start-blocks.tsx b/web/app/components/workflow/block-selector/all-start-blocks.tsx index a089978bdd..ac8f665ad4 100644 --- a/web/app/components/workflow/block-selector/all-start-blocks.tsx +++ b/web/app/components/workflow/block-selector/all-start-blocks.tsx @@ -3,8 +3,12 @@ import { useCallback, useEffect, useMemo, + useRef, useState, } from 'react' +import type { + RefObject, +} from 'react' import { useTranslation } from 'react-i18next' import type { BlockEnum, OnSelectBlock } from '../types' import type { TriggerDefaultValue, TriggerWithProvider } from './types' @@ -23,6 +27,9 @@ import Divider from '@/app/components/base/divider' import { useGlobalPublicStore } from '@/context/global-public-context' import { useAllTriggerPlugins, useInvalidateAllTriggerPlugins } from '@/service/use-triggers' import { useFeaturedTriggersRecommendations } from '@/service/use-plugins' +import { PluginCategoryEnum } from '../../plugins/types' +import { useMarketplacePlugins } from '../../plugins/marketplace/hooks' +import PluginList, { type ListRef } from './market-place-plugin/list' const marketplaceFooterClassName = 'system-sm-medium z-10 flex h-8 flex-none cursor-pointer items-center rounded-b-lg border-[0.5px] border-t border-components-panel-border bg-components-panel-bg-blur px-4 py-1 text-text-accent-light-mode-only shadow-lg' @@ -47,6 +54,8 @@ const AllStartBlocks = ({ const [hasStartBlocksContent, setHasStartBlocksContent] = useState(false) const [hasPluginContent, setHasPluginContent] = useState(false) const { enable_marketplace } = useGlobalPublicStore(s => s.systemFeatures) + const pluginRef = useRef(null) + const wrapElemRef = useRef(null) const entryNodeTypes = availableBlocksTypes?.length ? availableBlocksTypes @@ -71,14 +80,21 @@ const AllStartBlocks = ({ const invalidateTriggers = useInvalidateAllTriggerPlugins() const trimmedSearchText = searchText.trim() const hasSearchText = trimmedSearchText.length > 0 + const hasFilter = hasSearchText || tags.length > 0 const { plugins: featuredPlugins = [], isLoading: featuredLoading, - } = useFeaturedTriggersRecommendations(enableTriggerPlugin && enable_marketplace && !hasSearchText) + } = useFeaturedTriggersRecommendations(enableTriggerPlugin && enable_marketplace && !hasFilter) + const { + queryPluginsWithDebounced: fetchPlugins, + plugins: marketplacePlugins = [], + } = useMarketplacePlugins() const shouldShowFeatured = enableTriggerPlugin && enable_marketplace - && !hasSearchText + && !hasFilter + const shouldShowTriggerListTitle = hasStartBlocksContent || hasPluginContent + const shouldShowMarketplaceFooter = enable_marketplace && !hasFilter const handleStartBlocksContentChange = useCallback((hasContent: boolean) => { setHasStartBlocksContent(hasContent) @@ -88,18 +104,34 @@ const AllStartBlocks = ({ setHasPluginContent(hasContent) }, []) - const hasAnyContent = hasStartBlocksContent || hasPluginContent || shouldShowFeatured - const shouldShowEmptyState = hasSearchText && !hasAnyContent + const hasMarketplaceContent = enableTriggerPlugin && enable_marketplace && marketplacePlugins.length > 0 + const hasAnyContent = hasStartBlocksContent || hasPluginContent || shouldShowFeatured || hasMarketplaceContent + const shouldShowEmptyState = hasFilter && !hasAnyContent useEffect(() => { if (!enableTriggerPlugin && hasPluginContent) setHasPluginContent(false) }, [enableTriggerPlugin, hasPluginContent]) + useEffect(() => { + if (!enableTriggerPlugin || !enable_marketplace) return + if (hasFilter) { + fetchPlugins({ + query: searchText, + tags, + category: PluginCategoryEnum.trigger, + }) + } + }, [enableTriggerPlugin, enable_marketplace, hasFilter, fetchPlugins, searchText, tags]) + return (
-
+
pluginRef.current?.handleScroll()} + >
{shouldShowFeatured && ( <> @@ -117,9 +149,11 @@ const AllStartBlocks = ({
)} -
- {t('workflow.tabs.allTriggers')} -
+ {shouldShowTriggerListTitle && ( +
+ {t('workflow.tabs.allTriggers')} +
+ )} )} + {enableTriggerPlugin && enable_marketplace && ( + } + list={marketplacePlugins} + searchText={trimmedSearchText} + tags={tags} + hideFindMoreFooter + /> + )}
{shouldShowEmptyState && ( @@ -160,7 +204,7 @@ const AllStartBlocks = ({ )}
- {!shouldShowEmptyState && ( + {shouldShowMarketplaceFooter && !shouldShowEmptyState && ( // Footer - Same as Tools tab marketplace footer pluginRef.current?.handleScroll()} >
{isShowRAGRecommendations && onTagsChange && (