diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/list/index.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/list/index.tsx index cdc7b67bdb..f21f65904b 100644 --- a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/list/index.tsx +++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/list/index.tsx @@ -44,7 +44,7 @@ const List = ({ observerRef.current.observe(anchorRef.current) } return () => observerRef.current?.disconnect() - }, [anchorRef, isLoading]) + }, [anchorRef, isLoading, dataSourceStore]) const isAllLoading = isLoading && fileList.length === 0 && keywords.length === 0 const isPartialLoading = isLoading && fileList.length > 0 diff --git a/web/app/components/datasets/list/datasets.tsx b/web/app/components/datasets/list/datasets.tsx index beb4e591e1..69ea395795 100644 --- a/web/app/components/datasets/list/datasets.tsx +++ b/web/app/components/datasets/list/datasets.tsx @@ -51,7 +51,7 @@ const Datasets = ({ observerRef.current.observe(anchorRef.current) } return () => observerRef.current?.disconnect() - }, [anchorRef]) + }, [anchorRef, hasNextPage, isFetching, fetchNextPage]) return ( <> diff --git a/web/app/components/plugins/hooks.ts b/web/app/components/plugins/hooks.ts index 2717740272..0af7c1a170 100644 --- a/web/app/components/plugins/hooks.ts +++ b/web/app/components/plugins/hooks.ts @@ -26,9 +26,16 @@ export const useTags = (translateFromOut?: TFunction) => { return acc }, {} as Record) + const getTagLabel = (name: string) => { + if (!tagsMap[name]) + return name + return tagsMap[name].label + } + return { tags, tagsMap, + getTagLabel, } } diff --git a/web/app/components/plugins/marketplace/list/card-wrapper.tsx b/web/app/components/plugins/marketplace/list/card-wrapper.tsx index 8d9f3a5b10..d2a38b3ce3 100644 --- a/web/app/components/plugins/marketplace/list/card-wrapper.tsx +++ b/web/app/components/plugins/marketplace/list/card-wrapper.tsx @@ -29,7 +29,7 @@ const CardWrapper = ({ setFalse: hideInstallFromMarketplace, }] = useBoolean(false) const { locale: localeFromLocale } = useI18N() - const { tagsMap } = useTags(t) + const { getTagLabel } = useTags(t) if (showInstallButton) { return ( @@ -43,7 +43,7 @@ const CardWrapper = ({ footer={ tagsMap[tag.name].label)} + tags={plugin.tags.map(tag => getTagLabel(tag.name))} /> } /> @@ -92,7 +92,7 @@ const CardWrapper = ({ footer={ tagsMap[tag.name].label)} + tags={plugin.tags.map(tag => getTagLabel(tag.name))} /> } /> diff --git a/web/app/components/plugins/marketplace/utils.ts b/web/app/components/plugins/marketplace/utils.ts index 830779f820..f840ee1b85 100644 --- a/web/app/components/plugins/marketplace/utils.ts +++ b/web/app/components/plugins/marketplace/utils.ts @@ -7,6 +7,7 @@ import type { PluginsSearchParams, } from '@/app/components/plugins/marketplace/types' import { + APP_VERSION, MARKETPLACE_API_PREFIX, } from '@/config' import { getMarketplaceUrl } from '@/utils/var' @@ -49,11 +50,15 @@ export const getMarketplacePluginsByCollectionId = async (collectionId: string, try { const url = `${MARKETPLACE_API_PREFIX}/collections/${collectionId}/plugins` + const headers = new Headers({ + 'X-Dify-Version': APP_VERSION, + }) const marketplaceCollectionPluginsData = await globalThis.fetch( url, { cache: 'no-store', method: 'POST', + headers, body: JSON.stringify({ category: query?.category, exclude: query?.exclude, @@ -83,7 +88,10 @@ export const getMarketplaceCollectionsAndPlugins = async (query?: CollectionsAnd marketplaceUrl += `&condition=${query.condition}` if (query?.type) marketplaceUrl += `&type=${query.type}` - const marketplaceCollectionsData = await globalThis.fetch(marketplaceUrl, { cache: 'no-store' }) + const headers = new Headers({ + 'X-Dify-Version': APP_VERSION, + }) + const marketplaceCollectionsData = await globalThis.fetch(marketplaceUrl, { headers, cache: 'no-store' }) const marketplaceCollectionsDataJson = await marketplaceCollectionsData.json() marketplaceCollections = marketplaceCollectionsDataJson.data.collections await Promise.all(marketplaceCollections.map(async (collection: MarketplaceCollection) => { diff --git a/web/app/components/plugins/plugin-page/filter-management/tag-filter.tsx b/web/app/components/plugins/plugin-page/filter-management/tag-filter.tsx index 43c75b5f93..843d041763 100644 --- a/web/app/components/plugins/plugin-page/filter-management/tag-filter.tsx +++ b/web/app/components/plugins/plugin-page/filter-management/tag-filter.tsx @@ -27,7 +27,7 @@ const TagsFilter = ({ const { t } = useTranslation() const [open, setOpen] = useState(false) const [searchText, setSearchText] = useState('') - const { tags: options, tagsMap } = useTags() + const { tags: options, getTagLabel } = useTags() const filteredOptions = options.filter(option => option.name.toLowerCase().includes(searchText.toLowerCase())) const handleCheck = (id: string) => { if (value.includes(id)) @@ -59,7 +59,7 @@ const TagsFilter = ({ !selectedTagsLength && t('pluginTags.allTags') } { - !!selectedTagsLength && value.map(val => tagsMap[val].label).slice(0, 2).join(',') + !!selectedTagsLength && value.map(val => getTagLabel(val)).slice(0, 2).join(',') } { selectedTagsLength > 2 && ( diff --git a/web/config/index.ts b/web/config/index.ts index e5f9d8497d..f9ae7096a8 100644 --- a/web/config/index.ts +++ b/web/config/index.ts @@ -3,6 +3,7 @@ import { AgentStrategy } from '@/types/app' import { PromptRole } from '@/models/debug' import { PipelineInputVarType } from '@/models/pipeline' import { DatasetAttr } from '@/types/feature' +import pkg from '../package.json' const getBooleanConfig = (envVar: string | undefined, dataAttrKey: DatasetAttr, defaultValue: boolean = true) => { if (envVar !== undefined && envVar !== '') @@ -296,4 +297,6 @@ export const VALUE_SELECTOR_DELIMITER = '@@@' export const validPassword = /^(?=.*[a-zA-Z])(?=.*\d)\S{8,}$/ +export const APP_VERSION = pkg.version + export const RAG_PIPELINE_PREVIEW_CHUNK_NUM = 20 diff --git a/web/service/fetch.ts b/web/service/fetch.ts index a05c4cdfce..48adedd453 100644 --- a/web/service/fetch.ts +++ b/web/service/fetch.ts @@ -2,7 +2,7 @@ import type { AfterResponseHook, BeforeErrorHook, BeforeRequestHook, Hooks } fro import ky from 'ky' import type { IOtherOptions } from './base' import Toast from '@/app/components/base/toast' -import { API_PREFIX, MARKETPLACE_API_PREFIX, PUBLIC_API_PREFIX } from '@/config' +import { API_PREFIX, APP_VERSION, MARKETPLACE_API_PREFIX, PUBLIC_API_PREFIX } from '@/config' import { getInitialTokenV2, isTokenV1 } from '@/app/components/share/utils' import { getProcessedSystemVariablesFromUrlParams } from '@/app/components/base/chat/utils' @@ -151,6 +151,10 @@ async function base(url: string, options: FetchOptionType = {}, otherOptions: if (deleteContentType) (headers as any).delete('Content-Type') + // ! For Marketplace API, help to filter tags added in new version + if (isMarketplaceAPI) + (headers as any).set('X-Dify-Version', APP_VERSION) + const client = baseClient.extend({ hooks: { ...baseHooks,