diff --git a/web/app/components/plugins/install-plugin/hooks/use-refresh-plugin-list.tsx b/web/app/components/plugins/install-plugin/hooks/use-refresh-plugin-list.tsx
new file mode 100644
index 0000000000..6bcb8f0321
--- /dev/null
+++ b/web/app/components/plugins/install-plugin/hooks/use-refresh-plugin-list.tsx
@@ -0,0 +1,43 @@
+import { useUpdateModelProviders } from '@/app/components/header/account-setting/model-provider-page/hooks'
+import { useProviderContext } from '@/context/provider-context'
+import { useInvalidateInstalledPluginList } from '@/service/use-plugins'
+import { useInvalidateAllBuiltInTools, useInvalidateAllToolProviders } from '@/service/use-tools'
+import { useInvalidateStrategyProviders } from '@/service/use-strategy'
+import type { Plugin, PluginManifestInMarket } from '../../types'
+import { PluginType } from '../../types'
+
+const useRefreshPluginList = () => {
+ const invalidateInstalledPluginList = useInvalidateInstalledPluginList()
+ const updateModelProviders = useUpdateModelProviders()
+ const { refreshModelProviders } = useProviderContext()
+
+ const invalidateAllToolProviders = useInvalidateAllToolProviders()
+ const invalidateAllBuiltInTools = useInvalidateAllBuiltInTools()
+
+ const invalidateStrategyProviders = useInvalidateStrategyProviders()
+ return {
+ refreshPluginList: (manifest: PluginManifestInMarket | Plugin) => {
+ // installed list
+ invalidateInstalledPluginList()
+
+ // tool page, tool select
+ if (PluginType.tool.includes(manifest.category)) {
+ invalidateAllToolProviders()
+ invalidateAllBuiltInTools()
+ // TODO: update suggested tools. It's a function in hook useMarketplacePlugins,handleUpdatePlugins
+ }
+
+ // model select
+ if (PluginType.model.includes(manifest.category)) {
+ updateModelProviders()
+ refreshModelProviders()
+ }
+
+ // agent select
+ if (PluginType.agent.includes(manifest.category))
+ invalidateStrategyProviders()
+ },
+ }
+}
+
+export default useRefreshPluginList
diff --git a/web/app/components/plugins/install-plugin/install-from-marketplace/index.tsx b/web/app/components/plugins/install-plugin/install-from-marketplace/index.tsx
index 046806ee08..7ac271b83f 100644
--- a/web/app/components/plugins/install-plugin/install-from-marketplace/index.tsx
+++ b/web/app/components/plugins/install-plugin/install-from-marketplace/index.tsx
@@ -3,13 +3,11 @@
import React, { useCallback, useState } from 'react'
import Modal from '@/app/components/base/modal'
import type { Dependency, Plugin, PluginManifestInMarket } from '../../types'
-import { InstallStep, PluginType } from '../../types'
+import { InstallStep } from '../../types'
import Install from './steps/install'
import Installed from '../base/installed'
import { useTranslation } from 'react-i18next'
-import { useUpdateModelProviders } from '@/app/components/header/account-setting/model-provider-page/hooks'
-import { useInvalidateInstalledPluginList } from '@/service/use-plugins'
-import { useInvalidateAllToolProviders } from '@/service/use-tools'
+import useRefreshPluginList from '../hooks/use-refresh-plugin-list'
import ReadyToInstallBundle from '../install-bundle/ready-to-install'
const i18nPrefix = 'plugin.installModal'
@@ -35,9 +33,7 @@ const InstallFromMarketplace: React.FC = ({
// readyToInstall -> check installed -> installed/failed
const [step, setStep] = useState(InstallStep.readyToInstall)
const [errorMsg, setErrorMsg] = useState(null)
- const updateModelProviders = useUpdateModelProviders()
- const invalidateAllToolProviders = useInvalidateAllToolProviders()
- const invalidateInstalledPluginList = useInvalidateInstalledPluginList()
+ const { refreshPluginList } = useRefreshPluginList()
const getTitle = useCallback(() => {
if (isBundle && step === InstallStep.installed)
@@ -51,12 +47,8 @@ const InstallFromMarketplace: React.FC = ({
const handleInstalled = useCallback(() => {
setStep(InstallStep.installed)
- invalidateInstalledPluginList()
- if (PluginType.model.includes(manifest.category))
- updateModelProviders()
- if (PluginType.tool.includes(manifest.category))
- invalidateAllToolProviders()
- }, [invalidateAllToolProviders, invalidateInstalledPluginList, manifest, updateModelProviders])
+ refreshPluginList(manifest)
+ }, [manifest, refreshPluginList])
const handleFailed = useCallback((errorMsg?: string) => {
setStep(InstallStep.installFailed)