Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
refactor: spilt context for better hmr (#33033)
Stephen Zhouf487b680f57e
diff --git a/web/__tests__/rag-pipeline/dsl-export-import-flow.test.ts b/web/__tests__/rag-pipeline/dsl-export-import-flow.test.tsindex 578552840d9..dc5ab3fc86b 100644--- a/web/__tests__/rag-pipeline/dsl-export-import-flow.test.ts+++ b/web/__tests__/rag-pipeline/dsl-export-import-flow.test.ts@@ -19,7 +19,7 @@ vi.mock('react-i18next', () => ({}),}))-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: () => ({ notify: mockNotify }),}))diff --git a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/card-view.tsx b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/card-view.tsxindex f07b2932c90..8c1df8d63df 100644--- a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/card-view.tsx+++ b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/card-view.tsx@@ -12,7 +12,7 @@ import AppCard from '@/app/components/app/overview/app-card'import TriggerCard from '@/app/components/app/overview/trigger-card'import { useStore as useAppStore } from '@/app/components/app/store'import Loading from '@/app/components/base/loading'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import MCPServiceCard from '@/app/components/tools/mcp/mcp-service-card'import { isTriggerNode } from '@/app/components/workflow/types'import { NEED_REFRESH_APP_LIST_KEY } from '@/config'diff --git a/web/app/(commonLayout)/layout.tsx b/web/app/(commonLayout)/layout.tsxindex bd067fde6ac..db2786f6cf9 100644--- a/web/app/(commonLayout)/layout.tsx+++ b/web/app/(commonLayout)/layout.tsx@@ -9,9 +9,9 @@ import Header from '@/app/components/header'import HeaderWrapper from '@/app/components/header/header-wrapper'import ReadmePanel from '@/app/components/plugins/readme-panel'import { AppContextProvider } from '@/context/app-context-provider'-import { EventEmitterContextProvider } from '@/context/event-emitter'-import { ModalContextProvider } from '@/context/modal-context'-import { ProviderContextProvider } from '@/context/provider-context'+import { EventEmitterContextProvider } from '@/context/event-emitter-provider'+import { ModalContextProvider } from '@/context/modal-context-provider'+import { ProviderContextProvider } from '@/context/provider-context-provider'import PartnerStack from '../components/billing/partner-stack'import Splash from '../components/splash'import RoleRouteGuard from './role-route-guard'diff --git a/web/app/account/(commonLayout)/account-page/AvatarWithEdit.tsx b/web/app/account/(commonLayout)/account-page/AvatarWithEdit.tsxindex 49b59704b19..0a17822187f 100644--- a/web/app/account/(commonLayout)/account-page/AvatarWithEdit.tsx+++ b/web/app/account/(commonLayout)/account-page/AvatarWithEdit.tsx@@ -16,7 +16,7 @@ import Button from '@/app/components/base/button'import Divider from '@/app/components/base/divider'import { useLocalFileUploader } from '@/app/components/base/image-uploader/hooks'import Modal from '@/app/components/base/modal'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { DISABLE_UPLOAD_IMAGE_AS_ICON } from '@/config'import { updateUserProfile } from '@/service/common'diff --git a/web/app/account/(commonLayout)/account-page/email-change-modal.tsx b/web/app/account/(commonLayout)/account-page/email-change-modal.tsxindex 87ca6a689cc..463c27294a5 100644--- a/web/app/account/(commonLayout)/account-page/email-change-modal.tsx+++ b/web/app/account/(commonLayout)/account-page/email-change-modal.tsx@@ -9,7 +9,7 @@ import { useContext } from 'use-context-selector'import Button from '@/app/components/base/button'import Input from '@/app/components/base/input'import Modal from '@/app/components/base/modal'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import {checkEmailExisted,resetEmail,diff --git a/web/app/account/(commonLayout)/account-page/index.tsx b/web/app/account/(commonLayout)/account-page/index.tsxindex f01efc002ce..908ef9c2e80 100644--- a/web/app/account/(commonLayout)/account-page/index.tsx+++ b/web/app/account/(commonLayout)/account-page/index.tsx@@ -12,7 +12,7 @@ import Button from '@/app/components/base/button'import Input from '@/app/components/base/input'import Modal from '@/app/components/base/modal'import PremiumBadge from '@/app/components/base/premium-badge'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import Collapse from '@/app/components/header/account-setting/collapse'import { IS_CE_EDITION, validPassword } from '@/config'import { useAppContext } from '@/context/app-context'diff --git a/web/app/account/(commonLayout)/layout.tsx b/web/app/account/(commonLayout)/layout.tsxindex 47fb47b02b4..8fdbd8a238c 100644--- a/web/app/account/(commonLayout)/layout.tsx+++ b/web/app/account/(commonLayout)/layout.tsx@@ -5,9 +5,9 @@ import AmplitudeProvider from '@/app/components/base/amplitude'import GA, { GaType } from '@/app/components/base/ga'import HeaderWrapper from '@/app/components/header/header-wrapper'import { AppContextProvider } from '@/context/app-context-provider'-import { EventEmitterContextProvider } from '@/context/event-emitter'-import { ModalContextProvider } from '@/context/modal-context'-import { ProviderContextProvider } from '@/context/provider-context'+import { EventEmitterContextProvider } from '@/context/event-emitter-provider'+import { ModalContextProvider } from '@/context/modal-context-provider'+import { ProviderContextProvider } from '@/context/provider-context-provider'import Header from './header'const Layout = ({ children }: { children: ReactNode }) => {diff --git a/web/app/components/app-sidebar/app-info/__tests__/use-app-info-actions.spec.ts b/web/app/components/app-sidebar/app-info/__tests__/use-app-info-actions.spec.tsindex e5966ed972f..6104e2b6413 100644--- a/web/app/components/app-sidebar/app-info/__tests__/use-app-info-actions.spec.ts+++ b/web/app/components/app-sidebar/app-info/__tests__/use-app-info-actions.spec.ts@@ -42,7 +42,7 @@ vi.mock('@/app/components/app/store', () => ({}),}))-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({ToastContext: {},}))diff --git a/web/app/components/app-sidebar/app-info/use-app-info-actions.ts b/web/app/components/app-sidebar/app-info/use-app-info-actions.tsindex 13880acbed3..800f21de444 100644--- a/web/app/components/app-sidebar/app-info/use-app-info-actions.ts+++ b/web/app/components/app-sidebar/app-info/use-app-info-actions.ts@@ -6,7 +6,7 @@ import { useCallback, useState } from 'react'import { useTranslation } from 'react-i18next'import { useContext } from 'use-context-selector'import { useStore as useAppStore } from '@/app/components/app/store'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { NEED_REFRESH_APP_LIST_KEY } from '@/config'import { useProviderContext } from '@/context/provider-context'import { copyApp, deleteApp, exportAppConfig, updateAppInfo } from '@/service/apps'diff --git a/web/app/components/app/annotation/batch-add-annotation-modal/csv-uploader.spec.tsx b/web/app/components/app/annotation/batch-add-annotation-modal/csv-uploader.spec.tsxindex 6a67ba32079..55f5ee0564d 100644--- a/web/app/components/app/annotation/batch-add-annotation-modal/csv-uploader.spec.tsx+++ b/web/app/components/app/annotation/batch-add-annotation-modal/csv-uploader.spec.tsx@@ -1,7 +1,7 @@import type { Props } from './csv-uploader'import { fireEvent, render, screen, waitFor } from '@testing-library/react'import * as React from 'react'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import CSVUploader from './csv-uploader'describe('CSVUploader', () => {diff --git a/web/app/components/app/annotation/batch-add-annotation-modal/csv-uploader.tsx b/web/app/components/app/annotation/batch-add-annotation-modal/csv-uploader.tsxindex 6d5eb1ef952..118eaea58e0 100644--- a/web/app/components/app/annotation/batch-add-annotation-modal/csv-uploader.tsx+++ b/web/app/components/app/annotation/batch-add-annotation-modal/csv-uploader.tsx@@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next'import { useContext } from 'use-context-selector'import Button from '@/app/components/base/button'import { Csv as CSVIcon } from '@/app/components/base/icons/src/public/files'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { cn } from '@/utils/classnames'export type Props = {diff --git a/web/app/components/app/configuration/config-prompt/advanced-prompt-input.tsx b/web/app/components/app/configuration/config-prompt/advanced-prompt-input.tsxindex d0e9eb586cc..9625204d814 100644--- a/web/app/components/app/configuration/config-prompt/advanced-prompt-input.tsx+++ b/web/app/components/app/configuration/config-prompt/advanced-prompt-input.tsx@@ -20,7 +20,7 @@ import {} from '@/app/components/base/icons/src/vender/line/files'import PromptEditor from '@/app/components/base/prompt-editor'import { INSERT_VARIABLE_VALUE_BLOCK_COMMAND } from '@/app/components/base/prompt-editor/plugins/variable-block'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import Tooltip from '@/app/components/base/tooltip'import ConfigContext from '@/context/debug-configuration'import { useEventEmitterContextContext } from '@/context/event-emitter'diff --git a/web/app/components/app/configuration/config-prompt/simple-prompt-input.tsx b/web/app/components/app/configuration/config-prompt/simple-prompt-input.tsxindex bc94f878386..c33d55873d1 100644--- a/web/app/components/app/configuration/config-prompt/simple-prompt-input.tsx+++ b/web/app/components/app/configuration/config-prompt/simple-prompt-input.tsx@@ -17,7 +17,7 @@ import { useFeaturesStore } from '@/app/components/base/features/hooks'import PromptEditor from '@/app/components/base/prompt-editor'import { PROMPT_EDITOR_UPDATE_VALUE_BY_EVENT_EMITTER } from '@/app/components/base/prompt-editor/plugins/update-block'import { INSERT_VARIABLE_VALUE_BLOCK_COMMAND } from '@/app/components/base/prompt-editor/plugins/variable-block'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import Tooltip from '@/app/components/base/tooltip'import ConfigContext from '@/context/debug-configuration'import { useEventEmitterContextContext } from '@/context/event-emitter'diff --git a/web/app/components/app/configuration/config/agent/prompt-editor.tsx b/web/app/components/app/configuration/config/agent/prompt-editor.tsxindex e9e3b608594..9f1f04ba3c7 100644--- a/web/app/components/app/configuration/config/agent/prompt-editor.tsx+++ b/web/app/components/app/configuration/config/agent/prompt-editor.tsx@@ -12,7 +12,7 @@ import {CopyCheck,} from '@/app/components/base/icons/src/vender/line/files'import PromptEditor from '@/app/components/base/prompt-editor'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import ConfigContext from '@/context/debug-configuration'import { useModalContext } from '@/context/modal-context'import { cn } from '@/utils/classnames'diff --git a/web/app/components/app/configuration/dataset-config/settings-modal/index.spec.tsx b/web/app/components/app/configuration/dataset-config/settings-modal/index.spec.tsxindex c4fdfb75531..ea70725ea81 100644--- a/web/app/components/app/configuration/dataset-config/settings-modal/index.spec.tsx+++ b/web/app/components/app/configuration/dataset-config/settings-modal/index.spec.tsx@@ -3,7 +3,7 @@ import type { DataSet } from '@/models/datasets'import type { RetrievalConfig } from '@/types/app'import { render, screen, waitFor } from '@testing-library/react'import userEvent from '@testing-library/user-event'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { IndexingType } from '@/app/components/datasets/create/step-two'import { ACCOUNT_SETTING_TAB } from '@/app/components/header/account-setting/constants'import { ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'diff --git a/web/app/components/app/configuration/dataset-config/settings-modal/index.tsx b/web/app/components/app/configuration/dataset-config/settings-modal/index.tsxindex e910702b664..c9c8d080f21 100644--- a/web/app/components/app/configuration/dataset-config/settings-modal/index.tsx+++ b/web/app/components/app/configuration/dataset-config/settings-modal/index.tsx@@ -9,7 +9,7 @@ import { useTranslation } from 'react-i18next'import Button from '@/app/components/base/button'import Input from '@/app/components/base/input'import Textarea from '@/app/components/base/textarea'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import { isReRankModelSelected } from '@/app/components/datasets/common/check-rerank-model'import { IndexingType } from '@/app/components/datasets/create/step-two'import IndexMethod from '@/app/components/datasets/settings/index-method'diff --git a/web/app/components/app/configuration/debug/debug-with-multiple-model/context-provider.tsx b/web/app/components/app/configuration/debug/debug-with-multiple-model/context-provider.tsxnew file mode 100644index 00000000000..74aed2d1e29--- /dev/null+++ b/web/app/components/app/configuration/debug/debug-with-multiple-model/context-provider.tsx@@ -0,0 +1,28 @@+'use client'++import type { ReactNode } from 'react'+import type { DebugWithMultipleModelContextType } from './context'+import { DebugWithMultipleModelContext } from './context'++type DebugWithMultipleModelContextProviderProps = {+ children: ReactNode+} & DebugWithMultipleModelContextType+export const DebugWithMultipleModelContextProvider = ({+ children,+ onMultipleModelConfigsChange,+ multipleModelConfigs,+ onDebugWithMultipleModelChange,+ checkCanSend,+}: DebugWithMultipleModelContextProviderProps) => {+ return (+ <DebugWithMultipleModelContext.Provider value={{+ onMultipleModelConfigsChange,+ multipleModelConfigs,+ onDebugWithMultipleModelChange,+ checkCanSend,+ }}+ >+ {children}+ </DebugWithMultipleModelContext.Provider>+ )+}diff --git a/web/app/components/app/configuration/debug/debug-with-multiple-model/context.spec.tsx b/web/app/components/app/configuration/debug/debug-with-multiple-model/context.spec.tsxindex e26fcec6073..989285f8122 100644--- a/web/app/components/app/configuration/debug/debug-with-multiple-model/context.spec.tsx+++ b/web/app/components/app/configuration/debug/debug-with-multiple-model/context.spec.tsx@@ -1,10 +1,8 @@import type { ModelAndParameter } from '../types'import type { DebugWithMultipleModelContextType } from './context'import { render, screen } from '@testing-library/react'-import {- DebugWithMultipleModelContextProvider,- useDebugWithMultipleModelContext,-} from './context'+import { useDebugWithMultipleModelContext } from './context'+import { DebugWithMultipleModelContextProvider } from './context-provider'const createModelAndParameter = (overrides: Partial<ModelAndParameter> = {}): ModelAndParameter => ({id: 'model-1',diff --git a/web/app/components/app/configuration/debug/debug-with-multiple-model/context.tsx b/web/app/components/app/configuration/debug/debug-with-multiple-model/context.tssimilarity index 50%rename from web/app/components/app/configuration/debug/debug-with-multiple-model/context.tsxrename to web/app/components/app/configuration/debug/debug-with-multiple-model/context.tsindex 38f803f8abc..e3ad06f1b92 100644--- a/web/app/components/app/configuration/debug/debug-with-multiple-model/context.tsx+++ b/web/app/components/app/configuration/debug/debug-with-multiple-model/context.ts@@ -10,7 +10,8 @@ export type DebugWithMultipleModelContextType = {onDebugWithMultipleModelChange: (singleModelConfig: ModelAndParameter) => voidcheckCanSend?: () => boolean}-const DebugWithMultipleModelContext = createContext<DebugWithMultipleModelContextType>({++export const DebugWithMultipleModelContext = createContext<DebugWithMultipleModelContextType>({multipleModelConfigs: [],onMultipleModelConfigsChange: noop,onDebugWithMultipleModelChange: noop,@@ -18,27 +19,4 @@ const DebugWithMultipleModelContext = createContext<DebugWithMultipleModelContexexport const useDebugWithMultipleModelContext = () => useContext(DebugWithMultipleModelContext)-type DebugWithMultipleModelContextProviderProps = {- children: React.ReactNode-} & DebugWithMultipleModelContextType-export const DebugWithMultipleModelContextProvider = ({- children,- onMultipleModelConfigsChange,- multipleModelConfigs,- onDebugWithMultipleModelChange,- checkCanSend,-}: DebugWithMultipleModelContextProviderProps) => {- return (- <DebugWithMultipleModelContext.Provider value={{- onMultipleModelConfigsChange,- multipleModelConfigs,- onDebugWithMultipleModelChange,- checkCanSend,- }}- >- {children}- </DebugWithMultipleModelContext.Provider>- )-}-export default DebugWithMultipleModelContextdiff --git a/web/app/components/app/configuration/debug/debug-with-multiple-model/index.tsx b/web/app/components/app/configuration/debug/debug-with-multiple-model/index.tsxindex c73eb543297..f98e8c1f062 100644--- a/web/app/components/app/configuration/debug/debug-with-multiple-model/index.tsx+++ b/web/app/components/app/configuration/debug/debug-with-multiple-model/index.tsx@@ -14,10 +14,8 @@ import { useDebugConfigurationContext } from '@/context/debug-configuration'import { useEventEmitterContextContext } from '@/context/event-emitter'import { AppModeEnum } from '@/types/app'import { APP_CHAT_WITH_MULTIPLE_MODEL } from '../types'-import {- DebugWithMultipleModelContextProvider,- useDebugWithMultipleModelContext,-} from './context'+import { useDebugWithMultipleModelContext } from './context'+import { DebugWithMultipleModelContextProvider } from './context-provider'import DebugItem from './debug-item'const DebugWithMultipleModel = () => {diff --git a/web/app/components/app/configuration/debug/debug-with-single-model/index.spec.tsx b/web/app/components/app/configuration/debug/debug-with-single-model/index.spec.tsxindex 08bdd2bfcb2..48141d00452 100644--- a/web/app/components/app/configuration/debug/debug-with-single-model/index.spec.tsx+++ b/web/app/components/app/configuration/debug/debug-with-single-model/index.spec.tsx@@ -387,7 +387,7 @@ vi.mock('@/context/event-emitter', () => ({}))// Mock toast context-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: vi.fn(() => ({notify: vi.fn(),})),diff --git a/web/app/components/app/configuration/debug/index.tsx b/web/app/components/app/configuration/debug/index.tsxindex 14a00e85c72..1a6f9e264f8 100644--- a/web/app/components/app/configuration/debug/index.tsx+++ b/web/app/components/app/configuration/debug/index.tsx@@ -29,7 +29,7 @@ import Button from '@/app/components/base/button'import { useFeatures, useFeaturesStore } from '@/app/components/base/features/hooks'import { RefreshCcw01 } from '@/app/components/base/icons/src/vender/line/arrows'import PromptLogModal from '@/app/components/base/prompt-log-modal'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import TooltipPlus from '@/app/components/base/tooltip'import { ModelFeatureEnum, ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'import { useDefaultModel } from '@/app/components/header/account-setting/model-provider-page/hooks'diff --git a/web/app/components/app/configuration/index.tsx b/web/app/components/app/configuration/index.tsxindex 16cf9454caf..a39eb3c63ef 100644--- a/web/app/components/app/configuration/index.tsx+++ b/web/app/components/app/configuration/index.tsx@@ -49,7 +49,8 @@ import { FeaturesProvider } from '@/app/components/base/features'import NewFeaturePanel from '@/app/components/base/features/new-feature-panel'import Loading from '@/app/components/base/loading'import { FILE_EXTS } from '@/app/components/base/prompt-editor/constants'-import Toast, { ToastContext } from '@/app/components/base/toast'+import Toast from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { ACCOUNT_SETTING_TAB } from '@/app/components/header/account-setting/constants'import { ModelFeatureEnum, ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'import {@@ -66,7 +67,7 @@ import { SupportUploadFileTypes } from '@/app/components/workflow/types'import { ANNOTATION_DEFAULT, DATASET_DEFAULT, DEFAULT_AGENT_SETTING, DEFAULT_CHAT_PROMPT_CONFIG, DEFAULT_COMPLETION_PROMPT_CONFIG } from '@/config'import { useAppContext } from '@/context/app-context'import ConfigContext from '@/context/debug-configuration'-import { MittProvider } from '@/context/mitt-context'+import { MittProvider } from '@/context/mitt-context-provider'import { useModalContext } from '@/context/modal-context'import { useProviderContext } from '@/context/provider-context'import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'diff --git a/web/app/components/app/configuration/tools/external-data-tool-modal.tsx b/web/app/components/app/configuration/tools/external-data-tool-modal.tsxindex fece5598e1d..35ba59a5fb2 100644--- a/web/app/components/app/configuration/tools/external-data-tool-modal.tsx+++ b/web/app/components/app/configuration/tools/external-data-tool-modal.tsx@@ -13,7 +13,7 @@ import FormGeneration from '@/app/components/base/features/new-feature-panel/modimport { BookOpen01 } from '@/app/components/base/icons/src/vender/line/education'import Modal from '@/app/components/base/modal'import { SimpleSelect } from '@/app/components/base/select'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import ApiBasedExtensionSelector from '@/app/components/header/account-setting/api-based-extension-page/selector'import { useDocLink, useLocale } from '@/context/i18n'import { LanguagesSupported } from '@/i18n-config/language'diff --git a/web/app/components/app/configuration/tools/index.tsx b/web/app/components/app/configuration/tools/index.tsxindex d2873b0be37..f348a7718d1 100644--- a/web/app/components/app/configuration/tools/index.tsx+++ b/web/app/components/app/configuration/tools/index.tsx@@ -15,7 +15,7 @@ import {} from '@/app/components/base/icons/src/vender/line/general'import { Tool03 } from '@/app/components/base/icons/src/vender/solid/general'import Switch from '@/app/components/base/switch'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import Tooltip from '@/app/components/base/tooltip'import ConfigContext from '@/context/debug-configuration'import { useModalContext } from '@/context/modal-context'diff --git a/web/app/components/app/create-app-modal/index.spec.tsx b/web/app/components/app/create-app-modal/index.spec.tsxindex 8c368df62cd..a9adb17582f 100644--- a/web/app/components/app/create-app-modal/index.spec.tsx+++ b/web/app/components/app/create-app-modal/index.spec.tsx@@ -4,7 +4,7 @@ import { useRouter } from 'next/navigation'import { afterAll, beforeEach, describe, expect, it, vi } from 'vitest'import { trackEvent } from '@/app/components/base/amplitude'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { NEED_REFRESH_APP_LIST_KEY } from '@/config'import { useAppContext } from '@/context/app-context'import { useProviderContext } from '@/context/provider-context'diff --git a/web/app/components/app/create-app-modal/index.tsx b/web/app/components/app/create-app-modal/index.tsxindex 66c7bce80cf..16ca4bdaff7 100644--- a/web/app/components/app/create-app-modal/index.tsx+++ b/web/app/components/app/create-app-modal/index.tsx@@ -17,7 +17,7 @@ import FullScreenModal from '@/app/components/base/fullscreen-modal'import { BubbleTextMod, ChatBot, ListSparkle, Logic } from '@/app/components/base/icons/src/vender/solid/communication'import Input from '@/app/components/base/input'import Textarea from '@/app/components/base/textarea'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import AppsFull from '@/app/components/billing/apps-full-in-dialog'import { NEED_REFRESH_APP_LIST_KEY } from '@/config'import { useAppContext } from '@/context/app-context'diff --git a/web/app/components/app/create-from-dsl-modal/index.tsx b/web/app/components/app/create-from-dsl-modal/index.tsxindex 04d8b1e7542..a542ef059fd 100644--- a/web/app/components/app/create-from-dsl-modal/index.tsx+++ b/web/app/components/app/create-from-dsl-modal/index.tsx@@ -12,7 +12,7 @@ import { trackEvent } from '@/app/components/base/amplitude'import Button from '@/app/components/base/button'import Input from '@/app/components/base/input'import Modal from '@/app/components/base/modal'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import AppsFull from '@/app/components/billing/apps-full-in-dialog'import { usePluginDependencies } from '@/app/components/workflow/plugin-dependency/hooks'import { NEED_REFRESH_APP_LIST_KEY } from '@/config'diff --git a/web/app/components/app/create-from-dsl-modal/uploader.tsx b/web/app/components/app/create-from-dsl-modal/uploader.tsxindex 778a2c14201..6b7ca4db61b 100644--- a/web/app/components/app/create-from-dsl-modal/uploader.tsx+++ b/web/app/components/app/create-from-dsl-modal/uploader.tsx@@ -10,7 +10,7 @@ import { useTranslation } from 'react-i18next'import { useContext } from 'use-context-selector'import ActionButton from '@/app/components/base/action-button'import { Yaml as YamlIcon } from '@/app/components/base/icons/src/public/files'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { cn } from '@/utils/classnames'import { formatFileSize } from '@/utils/format'diff --git a/web/app/components/app/log/list.tsx b/web/app/components/app/log/list.tsxindex 40519dcb36f..4eb733a02cb 100644--- a/web/app/components/app/log/list.tsx+++ b/web/app/components/app/log/list.tsx@@ -31,7 +31,7 @@ import Drawer from '@/app/components/base/drawer'import { getProcessedFilesFromResponse } from '@/app/components/base/file-uploader/utils'import Loading from '@/app/components/base/loading'import MessageLogModal from '@/app/components/base/message-log-modal'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import Tooltip from '@/app/components/base/tooltip'import { addFileInfos, sortAgentSorts } from '@/app/components/tools/utils'import { WorkflowContextProvider } from '@/app/components/workflow/context'diff --git a/web/app/components/app/overview/settings/index.spec.tsx b/web/app/components/app/overview/settings/index.spec.tsxindex c9cbe0b7244..d98e02ad571 100644--- a/web/app/components/app/overview/settings/index.spec.tsx+++ b/web/app/components/app/overview/settings/index.spec.tsx@@ -59,16 +59,12 @@ vi.mock('@/context/modal-context', () => ({useModalContext: () => buildModalContext(),}))-vi.mock('@/app/components/base/toast', async () => {- const actual = await vi.importActual<typeof import('@/app/components/base/toast')>('@/app/components/base/toast')- return {- ...actual,- useToastContext: () => ({- notify: mockNotify,- close: vi.fn(),- }),- }-})+vi.mock('@/app/components/base/toast/context', () => ({+ useToastContext: () => ({+ notify: mockNotify,+ close: vi.fn(),+ }),+}))vi.mock('@/context/i18n', async () => {const actual = await vi.importActual<typeof import('@/context/i18n')>('@/context/i18n')diff --git a/web/app/components/app/overview/settings/index.tsx b/web/app/components/app/overview/settings/index.tsxindex 040703f41cd..92bfdc5d316 100644--- a/web/app/components/app/overview/settings/index.tsx+++ b/web/app/components/app/overview/settings/index.tsx@@ -20,7 +20,7 @@ import PremiumBadge from '@/app/components/base/premium-badge'import { SimpleSelect } from '@/app/components/base/select'import Switch from '@/app/components/base/switch'import Textarea from '@/app/components/base/textarea'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import Tooltip from '@/app/components/base/tooltip'import { ACCOUNT_SETTING_TAB } from '@/app/components/header/account-setting/constants'import { useModalContext } from '@/context/modal-context'diff --git a/web/app/components/app/switch-app-modal/index.spec.tsx b/web/app/components/app/switch-app-modal/index.spec.tsxindex f0400f8b75e..c905d79b31e 100644--- a/web/app/components/app/switch-app-modal/index.spec.tsx+++ b/web/app/components/app/switch-app-modal/index.spec.tsx@@ -3,7 +3,7 @@ import { render, screen, waitFor } from '@testing-library/react'import userEvent from '@testing-library/user-event'import * as React from 'react'import { useStore as useAppStore } from '@/app/components/app/store'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { Plan } from '@/app/components/billing/type'import { NEED_REFRESH_APP_LIST_KEY } from '@/config'import { AppModeEnum } from '@/types/app'diff --git a/web/app/components/app/switch-app-modal/index.tsx b/web/app/components/app/switch-app-modal/index.tsxindex 30d7877ed01..8caa07c1871 100644--- a/web/app/components/app/switch-app-modal/index.tsx+++ b/web/app/components/app/switch-app-modal/index.tsx@@ -15,7 +15,7 @@ import Confirm from '@/app/components/base/confirm'import { AlertTriangle } from '@/app/components/base/icons/src/vender/solid/alertsAndFeedback'import Input from '@/app/components/base/input'import Modal from '@/app/components/base/modal'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import AppsFull from '@/app/components/billing/apps-full-in-dialog'import { NEED_REFRESH_APP_LIST_KEY } from '@/config'import { useAppContext } from '@/context/app-context'diff --git a/web/app/components/apps/app-card.tsx b/web/app/components/apps/app-card.tsxindex 8dc5c82e13d..471b3420d10 100644--- a/web/app/components/apps/app-card.tsx+++ b/web/app/components/apps/app-card.tsx@@ -18,7 +18,8 @@ import AppIcon from '@/app/components/base/app-icon'import Divider from '@/app/components/base/divider'import CustomPopover from '@/app/components/base/popover'import TagSelector from '@/app/components/base/tag-management/selector'-import Toast, { ToastContext } from '@/app/components/base/toast'+import Toast from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import Tooltip from '@/app/components/base/tooltip'import {AlertDialog,diff --git a/web/app/components/base/agent-log-modal/__tests__/detail.spec.tsx b/web/app/components/base/agent-log-modal/__tests__/detail.spec.tsxindex c77f144da27..47d854e028c 100644--- a/web/app/components/base/agent-log-modal/__tests__/detail.spec.tsx+++ b/web/app/components/base/agent-log-modal/__tests__/detail.spec.tsx@@ -2,7 +2,7 @@ import type { ComponentProps } from 'react'import type { IChatItem } from '@/app/components/base/chat/chat/type'import type { AgentLogDetailResponse } from '@/models/log'import { fireEvent, render, screen, waitFor } from '@testing-library/react'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { fetchAgentLogDetail } from '@/service/log'import AgentLogDetail from '../detail'diff --git a/web/app/components/base/agent-log-modal/__tests__/index.spec.tsx b/web/app/components/base/agent-log-modal/__tests__/index.spec.tsxindex 6b59e90c777..6437ae5b43e 100644--- a/web/app/components/base/agent-log-modal/__tests__/index.spec.tsx+++ b/web/app/components/base/agent-log-modal/__tests__/index.spec.tsx@@ -1,7 +1,7 @@import type { IChatItem } from '@/app/components/base/chat/chat/type'import { fireEvent, render, screen, waitFor } from '@testing-library/react'import { useClickAway } from 'ahooks'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { fetchAgentLogDetail } from '@/service/log'import AgentLogModal from '../index'diff --git a/web/app/components/base/agent-log-modal/detail.tsx b/web/app/components/base/agent-log-modal/detail.tsxindex 36b502e9a58..21ed0be7e8c 100644--- a/web/app/components/base/agent-log-modal/detail.tsx+++ b/web/app/components/base/agent-log-modal/detail.tsx@@ -10,7 +10,7 @@ import { useTranslation } from 'react-i18next'import { useContext } from 'use-context-selector'import { useStore as useAppStore } from '@/app/components/app/store'import Loading from '@/app/components/base/loading'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { fetchAgentLogDetail } from '@/service/log'import { cn } from '@/utils/classnames'import ResultPanel from './result'diff --git a/web/app/components/base/chat/chat-with-history/context.tsx b/web/app/components/base/chat/chat-with-history/context.tssimilarity index 100%rename from web/app/components/base/chat/chat-with-history/context.tsxrename to web/app/components/base/chat/chat-with-history/context.tsdiff --git a/web/app/components/base/chat/chat-with-history/hooks.tsx b/web/app/components/base/chat/chat-with-history/hooks.tsxindex da344a9789d..23936111ce0 100644--- a/web/app/components/base/chat/chat-with-history/hooks.tsx+++ b/web/app/components/base/chat/chat-with-history/hooks.tsx@@ -23,7 +23,7 @@ import {} from 'react'import { useTranslation } from 'react-i18next'import { getProcessedFilesFromResponse } from '@/app/components/base/file-uploader/utils'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import { InputVarType } from '@/app/components/workflow/types'import { useWebAppStore } from '@/context/web-app-context'import { useAppFavicon } from '@/hooks/use-app-favicon'diff --git a/web/app/components/base/chat/chat/__tests__/context.spec.tsx b/web/app/components/base/chat/chat/__tests__/context.spec.tsxindex fd00156e596..aeba073a7bb 100644--- a/web/app/components/base/chat/chat/__tests__/context.spec.tsx+++ b/web/app/components/base/chat/chat/__tests__/context.spec.tsx@@ -3,7 +3,8 @@ import type { ChatContextValue } from '../context'import { render, screen } from '@testing-library/react'import userEvent from '@testing-library/user-event'import { vi } from 'vitest'-import { ChatContextProvider, useChatContext } from '../context'+import { useChatContext } from '../context'+import { ChatContextProvider } from '../context-provider'const TestConsumer = () => {const context = useChatContext()diff --git a/web/app/components/base/chat/chat/__tests__/question.spec.tsx b/web/app/components/base/chat/chat/__tests__/question.spec.tsxindex 1d0584805b4..7c717b6e314 100644--- a/web/app/components/base/chat/chat/__tests__/question.spec.tsx+++ b/web/app/components/base/chat/chat/__tests__/question.spec.tsx@@ -9,7 +9,7 @@ import { vi } from 'vitest'import Toast from '../../../toast'import { ThemeBuilder } from '../../embedded-chatbot/theme/theme-context'-import { ChatContextProvider } from '../context'+import { ChatContextProvider } from '../context-provider'import Question from '../question'// Global Mocksdiff --git a/web/app/components/base/chat/chat/chat-input-area/__tests__/index.spec.tsx b/web/app/components/base/chat/chat/chat-input-area/__tests__/index.spec.tsxindex a6d4570fcb4..03f3c673ce9 100644--- a/web/app/components/base/chat/chat/chat-input-area/__tests__/index.spec.tsx+++ b/web/app/components/base/chat/chat/chat-input-area/__tests__/index.spec.tsx@@ -91,15 +91,9 @@ vi.mock('@/app/components/base/features/hooks', () => ({// ---------------------------------------------------------------------------// Toast context// ----------------------------------------------------------------------------vi.mock('@/app/components/base/toast', async () => {- const actual = await vi.importActual<typeof import('@/app/components/base/toast')>(- '@/app/components/base/toast',- )- return {- ...actual,- useToastContext: () => ({ notify: mockNotify }),- }-})+vi.mock('@/app/components/base/toast/context', () => ({+ useToastContext: () => ({ notify: mockNotify, close: vi.fn() }),+}))// ---------------------------------------------------------------------------// Internal layout hook – controls single/multi-line textarea modediff --git a/web/app/components/base/chat/chat/chat-input-area/index.tsx b/web/app/components/base/chat/chat/chat-input-area/index.tsxindex 9de52cb18cf..170cccaacac 100644--- a/web/app/components/base/chat/chat/chat-input-area/index.tsx+++ b/web/app/components/base/chat/chat/chat-input-area/index.tsx@@ -22,7 +22,7 @@ import {FileContextProvider,useFileStore,} from '@/app/components/base/file-uploader/store'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import VoiceInput from '@/app/components/base/voice-input'import { TransferMethod } from '@/types/app'import { cn } from '@/utils/classnames'diff --git a/web/app/components/base/chat/chat/check-input-forms-hooks.ts b/web/app/components/base/chat/chat/check-input-forms-hooks.tsindex 2da57b289e9..842e89070b5 100644--- a/web/app/components/base/chat/chat/check-input-forms-hooks.ts+++ b/web/app/components/base/chat/chat/check-input-forms-hooks.ts@@ -1,7 +1,7 @@import type { InputForm } from './type'import { useCallback } from 'react'import { useTranslation } from 'react-i18next'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import { InputVarType } from '@/app/components/workflow/types'import { TransferMethod } from '@/types/app'diff --git a/web/app/components/base/chat/chat/context.tsx b/web/app/components/base/chat/chat/context-provider.tsxsimilarity index 58%rename from web/app/components/base/chat/chat/context.tsxrename to web/app/components/base/chat/chat/context-provider.tsxindex 7843665ad73..02503521e5d 100644--- a/web/app/components/base/chat/chat/context.tsx+++ b/web/app/components/base/chat/chat/context-provider.tsx@@ -1,30 +1,8 @@'use client'import type { ReactNode } from 'react'-import type { ChatProps } from './index'-import { createContext, useContext } from 'use-context-selector'--export type ChatContextValue = Pick<ChatProps, 'config'- | 'isResponding'- | 'chatList'- | 'showPromptLog'- | 'questionIcon'- | 'answerIcon'- | 'onSend'- | 'onRegenerate'- | 'onAnnotationEdited'- | 'onAnnotationAdded'- | 'onAnnotationRemoved'- | 'disableFeedback'- | 'onFeedback'- | 'getHumanInputNodeData'> & {- readonly?: boolean- }--const ChatContext = createContext<ChatContextValue>({- chatList: [],- readonly: false,-})+import type { ChatContextValue } from './context'+import { ChatContext } from './context'type ChatContextProviderProps = {children: ReactNode@@ -71,7 +49,3 @@ export const ChatContextProvider = ({</ChatContext.Provider>)}--export const useChatContext = () => useContext(ChatContext)--export default ChatContextdiff --git a/web/app/components/base/chat/chat/context.ts b/web/app/components/base/chat/chat/context.tsnew file mode 100644index 00000000000..ff0bd263366--- /dev/null+++ b/web/app/components/base/chat/chat/context.ts@@ -0,0 +1,30 @@+'use client'++import type { ChatProps } from './index'+import { createContext, useContext } from 'use-context-selector'++export type ChatContextValue = Pick<ChatProps, 'config'+ | 'isResponding'+ | 'chatList'+ | 'showPromptLog'+ | 'questionIcon'+ | 'answerIcon'+ | 'onSend'+ | 'onRegenerate'+ | 'onAnnotationEdited'+ | 'onAnnotationAdded'+ | 'onAnnotationRemoved'+ | 'disableFeedback'+ | 'onFeedback'+ | 'getHumanInputNodeData'> & {+ readonly?: boolean+ }++export const ChatContext = createContext<ChatContextValue>({+ chatList: [],+ readonly: false,+})++export const useChatContext = () => useContext(ChatContext)++export default ChatContextdiff --git a/web/app/components/base/chat/chat/hooks.ts b/web/app/components/base/chat/chat/hooks.tsindex 3e01fa5ade9..4828ef2a479 100644--- a/web/app/components/base/chat/chat/hooks.ts+++ b/web/app/components/base/chat/chat/hooks.ts@@ -30,7 +30,7 @@ import {getProcessedFiles,getProcessedFilesFromResponse,} from '@/app/components/base/file-uploader/utils'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import { NodeRunningStatus, WorkflowRunningStatus } from '@/app/components/workflow/types'import useTimestamp from '@/hooks/use-timestamp'import {diff --git a/web/app/components/base/chat/chat/index.tsx b/web/app/components/base/chat/chat/index.tsxindex a77911d8957..69c064e3e26 100644--- a/web/app/components/base/chat/chat/index.tsx+++ b/web/app/components/base/chat/chat/index.tsx@@ -30,7 +30,7 @@ import PromptLogModal from '@/app/components/base/prompt-log-modal'import { cn } from '@/utils/classnames'import Answer from './answer'import ChatInputArea from './chat-input-area'-import { ChatContextProvider } from './context'+import { ChatContextProvider } from './context-provider'import Question from './question'import TryToAsk from './try-to-ask'diff --git a/web/app/components/base/chat/embedded-chatbot/context.tsx b/web/app/components/base/chat/embedded-chatbot/context.tssimilarity index 100%rename from web/app/components/base/chat/embedded-chatbot/context.tsxrename to web/app/components/base/chat/embedded-chatbot/context.tsdiff --git a/web/app/components/base/chat/embedded-chatbot/hooks.tsx b/web/app/components/base/chat/embedded-chatbot/hooks.tsxindex bffee787922..da142a69ecc 100644--- a/web/app/components/base/chat/embedded-chatbot/hooks.tsx+++ b/web/app/components/base/chat/embedded-chatbot/hooks.tsx@@ -21,7 +21,7 @@ import {useState,} from 'react'import { useTranslation } from 'react-i18next'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import { addFileInfos, sortAgentSorts } from '@/app/components/tools/utils'import { InputVarType } from '@/app/components/workflow/types'import { useWebAppStore } from '@/context/web-app-context'diff --git a/web/app/components/base/chat/embedded-chatbot/inputs-form/__tests__/content.spec.tsx b/web/app/components/base/chat/embedded-chatbot/inputs-form/__tests__/content.spec.tsxindex 08c9a035e70..aad2d3d09b4 100644--- a/web/app/components/base/chat/embedded-chatbot/inputs-form/__tests__/content.spec.tsx+++ b/web/app/components/base/chat/embedded-chatbot/inputs-form/__tests__/content.spec.tsx@@ -16,7 +16,7 @@ vi.mock('next/navigation', () => ({useSearchParams: () => new URLSearchParams(),}))-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: () => ({ notify: vi.fn() }),}))diff --git a/web/app/components/base/features/new-feature-panel/moderation/__tests__/moderation-setting-modal.spec.tsx b/web/app/components/base/features/new-feature-panel/moderation/__tests__/moderation-setting-modal.spec.tsxindex 3c690635da2..88f74d26861 100644--- a/web/app/components/base/features/new-feature-panel/moderation/__tests__/moderation-setting-modal.spec.tsx+++ b/web/app/components/base/features/new-feature-panel/moderation/__tests__/moderation-setting-modal.spec.tsx@@ -3,7 +3,7 @@ import { fireEvent, render, screen } from '@testing-library/react'import ModerationSettingModal from '../moderation-setting-modal'const mockNotify = vi.fn()-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: () => ({ notify: mockNotify }),}))diff --git a/web/app/components/base/features/new-feature-panel/moderation/moderation-setting-modal.tsx b/web/app/components/base/features/new-feature-panel/moderation/moderation-setting-modal.tsxindex c68abfd7b15..4c0682d1826 100644--- a/web/app/components/base/features/new-feature-panel/moderation/moderation-setting-modal.tsx+++ b/web/app/components/base/features/new-feature-panel/moderation/moderation-setting-modal.tsx@@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next'import Button from '@/app/components/base/button'import Divider from '@/app/components/base/divider'import Modal from '@/app/components/base/modal'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import ApiBasedExtensionSelector from '@/app/components/header/account-setting/api-based-extension-page/selector'import { ACCOUNT_SETTING_TAB } from '@/app/components/header/account-setting/constants'import { CustomConfigurationStatusEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'diff --git a/web/app/components/base/file-uploader/__tests__/hooks.spec.ts b/web/app/components/base/file-uploader/__tests__/hooks.spec.tsindex 00c64224aa1..8343974967b 100644--- a/web/app/components/base/file-uploader/__tests__/hooks.spec.ts+++ b/web/app/components/base/file-uploader/__tests__/hooks.spec.ts@@ -11,7 +11,7 @@ vi.mock('next/navigation', () => ({}))// Exception: hook requires toast context that isn't available without a provider wrapper-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: () => ({notify: mockNotify,}),diff --git a/web/app/components/base/file-uploader/hooks.ts b/web/app/components/base/file-uploader/hooks.tsindex 14e46548d86..4aab60175cd 100644--- a/web/app/components/base/file-uploader/hooks.ts+++ b/web/app/components/base/file-uploader/hooks.ts@@ -18,7 +18,7 @@ import {MAX_FILE_UPLOAD_LIMIT,VIDEO_SIZE_LIMIT,} from '@/app/components/base/file-uploader/constants'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import { SupportUploadFileTypes } from '@/app/components/workflow/types'import { uploadRemoteFileInfo } from '@/service/common'import { TransferMethod } from '@/types/app'diff --git a/web/app/components/base/form/hooks/__tests__/use-check-validated.spec.ts b/web/app/components/base/form/hooks/__tests__/use-check-validated.spec.tsindex b9d60594f77..28eb5bd5ed3 100644--- a/web/app/components/base/form/hooks/__tests__/use-check-validated.spec.ts+++ b/web/app/components/base/form/hooks/__tests__/use-check-validated.spec.ts@@ -5,7 +5,7 @@ import { useCheckValidated } from '../use-check-validated'const mockNotify = vi.fn()-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: () => ({notify: mockNotify,}),diff --git a/web/app/components/base/form/hooks/use-check-validated.ts b/web/app/components/base/form/hooks/use-check-validated.tsindex 7ed6164bb2b..d186996035c 100644--- a/web/app/components/base/form/hooks/use-check-validated.ts+++ b/web/app/components/base/form/hooks/use-check-validated.ts@@ -1,7 +1,7 @@import type { AnyFormApi } from '@tanstack/react-form'import type { FormSchema } from '@/app/components/base/form/types'import { useCallback } from 'react'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'export const useCheckValidated = (form: AnyFormApi, FormSchemas: FormSchema[]) => {const { notify } = useToastContext()diff --git a/web/app/components/base/image-uploader/__tests__/hooks.spec.ts b/web/app/components/base/image-uploader/__tests__/hooks.spec.tsindex 4d150830d0e..f79ea98081c 100644--- a/web/app/components/base/image-uploader/__tests__/hooks.spec.ts+++ b/web/app/components/base/image-uploader/__tests__/hooks.spec.ts@@ -5,7 +5,7 @@ import { Resolution, TransferMethod } from '@/types/app'import { useClipboardUploader, useDraggableUploader, useImageFiles, useLocalFileUploader } from '../hooks'const mockNotify = vi.fn()-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: () => ({ notify: mockNotify }),}))diff --git a/web/app/components/base/image-uploader/hooks.ts b/web/app/components/base/image-uploader/hooks.tsindex cd309a1f7b8..03cf0feeca9 100644--- a/web/app/components/base/image-uploader/hooks.ts+++ b/web/app/components/base/image-uploader/hooks.ts@@ -3,7 +3,7 @@ import type { ImageFile, VisionSettings } from '@/types/app'import { useParams } from 'next/navigation'import { useCallback, useMemo, useRef, useState } from 'react'import { useTranslation } from 'react-i18next'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import { ALLOW_FILE_EXTENSIONS, TransferMethod } from '@/types/app'import { getImageUploadErrorMessage, imageUpload } from './utils'diff --git a/web/app/components/base/markdown-blocks/__tests__/button.spec.tsx b/web/app/components/base/markdown-blocks/__tests__/button.spec.tsxindex 305896f4f1f..95ed788db38 100644--- a/web/app/components/base/markdown-blocks/__tests__/button.spec.tsx+++ b/web/app/components/base/markdown-blocks/__tests__/button.spec.tsx@@ -5,7 +5,7 @@ import userEvent from '@testing-library/user-event'// markdown-button.spec.tsximport * as React from 'react'import { beforeEach, describe, expect, it, vi } from 'vitest'-import { ChatContextProvider } from '@/app/components/base/chat/chat/context'+import { ChatContextProvider } from '@/app/components/base/chat/chat/context-provider'import MarkdownButton from '../button'diff --git a/web/app/components/base/markdown-blocks/__tests__/think-block.spec.tsx b/web/app/components/base/markdown-blocks/__tests__/think-block.spec.tsxindex 2cd31f9a493..e8b956cbbfd 100644--- a/web/app/components/base/markdown-blocks/__tests__/think-block.spec.tsx+++ b/web/app/components/base/markdown-blocks/__tests__/think-block.spec.tsx@@ -1,6 +1,6 @@import { act, render, screen } from '@testing-library/react'import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'-import { ChatContextProvider } from '@/app/components/base/chat/chat/context'+import { ChatContextProvider } from '@/app/components/base/chat/chat/context-provider'import ThinkBlock from '../think-block'// Mock react-i18nextdiff --git a/web/app/components/base/markdown-blocks/think-block.stories.tsx b/web/app/components/base/markdown-blocks/think-block.stories.tsxindex 23713fb2634..7c3f809ee73 100644--- a/web/app/components/base/markdown-blocks/think-block.stories.tsx+++ b/web/app/components/base/markdown-blocks/think-block.stories.tsx@@ -1,6 +1,6 @@import type { Meta, StoryObj } from '@storybook/nextjs-vite'import { useState } from 'react'-import { ChatContextProvider } from '@/app/components/base/chat/chat/context'+import { ChatContextProvider } from '@/app/components/base/chat/chat/context-provider'import ThinkBlock from './think-block'const THOUGHT_TEXT = `diff --git a/web/app/components/base/prompt-editor/plugins/component-picker-block/__tests__/index.spec.tsx b/web/app/components/base/prompt-editor/plugins/component-picker-block/__tests__/index.spec.tsxindex 2deec561e96..6cc6c3a67fe 100644--- a/web/app/components/base/prompt-editor/plugins/component-picker-block/__tests__/index.spec.tsx+++ b/web/app/components/base/prompt-editor/plugins/component-picker-block/__tests__/index.spec.tsx@@ -28,7 +28,8 @@ import {import * as React from 'react'import { GeneratorType } from '@/app/components/app/configuration/config/automatic/types'import { VarType } from '@/app/components/workflow/types'-import { EventEmitterContextProvider, useEventEmitterContextContext } from '@/context/event-emitter'+import { useEventEmitterContextContext } from '@/context/event-emitter'+import { EventEmitterContextProvider } from '@/context/event-emitter-provider'import { INSERT_CONTEXT_BLOCK_COMMAND } from '../../context-block'import { INSERT_CURRENT_BLOCK_COMMAND } from '../../current-block'import { INSERT_ERROR_MESSAGE_BLOCK_COMMAND } from '../../error-message-block'diff --git a/web/app/components/base/radio/context/index.tsx b/web/app/components/base/radio/context/index.tssimilarity index 100%rename from web/app/components/base/radio/context/index.tsxrename to web/app/components/base/radio/context/index.tsdiff --git a/web/app/components/base/tag-input/__tests__/index.spec.tsx b/web/app/components/base/tag-input/__tests__/index.spec.tsxindex b091d9cd033..f07399f8af6 100644--- a/web/app/components/base/tag-input/__tests__/index.spec.tsx+++ b/web/app/components/base/tag-input/__tests__/index.spec.tsx@@ -5,7 +5,7 @@ import TagInput from '../index'const mockNotify = vi.fn()-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: () => ({notify: mockNotify,}),diff --git a/web/app/components/base/tag-input/index.tsx b/web/app/components/base/tag-input/index.tsxindex 1c49b026fbd..377e68abe40 100644--- a/web/app/components/base/tag-input/index.tsx+++ b/web/app/components/base/tag-input/index.tsx@@ -2,7 +2,7 @@ import type { ChangeEvent, FC, KeyboardEvent } from 'react'import { useCallback, useState } from 'react'import AutosizeInput from 'react-18-input-autosize'import { useTranslation } from 'react-i18next'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import { cn } from '@/utils/classnames'type TagInputProps = {diff --git a/web/app/components/base/tag-management/__tests__/panel.spec.tsx b/web/app/components/base/tag-management/__tests__/panel.spec.tsxindex c91c72e5830..cd9e37e286d 100644--- a/web/app/components/base/tag-management/__tests__/panel.spec.tsx+++ b/web/app/components/base/tag-management/__tests__/panel.spec.tsx@@ -3,7 +3,7 @@ import { render, screen, waitFor, within } from '@testing-library/react'import userEvent from '@testing-library/user-event'import * as React from 'react'import { act } from 'react'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import Panel from '../panel'import { useStore as useTagStore } from '../store'diff --git a/web/app/components/base/tag-management/__tests__/selector.spec.tsx b/web/app/components/base/tag-management/__tests__/selector.spec.tsxindex dc58ca37e61..43f17a1e8c2 100644--- a/web/app/components/base/tag-management/__tests__/selector.spec.tsx+++ b/web/app/components/base/tag-management/__tests__/selector.spec.tsx@@ -3,7 +3,7 @@ import { render, screen, waitFor, within } from '@testing-library/react'import userEvent from '@testing-library/user-event'import * as React from 'react'import { act } from 'react'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import TagSelector from '../selector'import { useStore as useTagStore } from '../store'diff --git a/web/app/components/base/tag-management/index.tsx b/web/app/components/base/tag-management/index.tsxindex e9ce85ecc05..b7682bcdadd 100644--- a/web/app/components/base/tag-management/index.tsx+++ b/web/app/components/base/tag-management/index.tsx@@ -4,7 +4,7 @@ import { useEffect, useState } from 'react'import { useTranslation } from 'react-i18next'import { useContext } from 'use-context-selector'import Modal from '@/app/components/base/modal'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import {createTag,fetchTagList,diff --git a/web/app/components/base/tag-management/panel.tsx b/web/app/components/base/tag-management/panel.tsxindex 4174ba04764..cebed74f3b5 100644--- a/web/app/components/base/tag-management/panel.tsx+++ b/web/app/components/base/tag-management/panel.tsx@@ -10,7 +10,7 @@ import { useContext } from 'use-context-selector'import Checkbox from '@/app/components/base/checkbox'import Divider from '@/app/components/base/divider'import Input from '@/app/components/base/input'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { bindTag, createTag, unBindTag } from '@/service/tag'import { useStore as useTagStore } from './store'diff --git a/web/app/components/base/tag-management/tag-item-editor.tsx b/web/app/components/base/tag-management/tag-item-editor.tsxindex a37e42dccec..3cff335f58a 100644--- a/web/app/components/base/tag-management/tag-item-editor.tsx+++ b/web/app/components/base/tag-management/tag-item-editor.tsx@@ -6,7 +6,7 @@ import { useState } from 'react'import { useTranslation } from 'react-i18next'import { useContext } from 'use-context-selector'import Confirm from '@/app/components/base/confirm'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import Tooltip from '@/app/components/base/tooltip'import {deleteTag,diff --git a/web/app/components/base/text-generation/__tests__/hooks.spec.ts b/web/app/components/base/text-generation/__tests__/hooks.spec.tsindex cab06f1c8a2..a5b5578158d 100644--- a/web/app/components/base/text-generation/__tests__/hooks.spec.ts+++ b/web/app/components/base/text-generation/__tests__/hooks.spec.ts@@ -5,7 +5,7 @@ import { useTextGeneration } from '../hooks'const mockNotify = vi.fn()const mockSsePost = vi.fn<(url: string, fetchOptions: { body: Record<string, unknown> }, otherOptions: IOtherOptions) => void>()-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: () => ({notify: mockNotify,}),diff --git a/web/app/components/base/text-generation/hooks.ts b/web/app/components/base/text-generation/hooks.tsindex c5d008956ba..4314a819251 100644--- a/web/app/components/base/text-generation/hooks.ts+++ b/web/app/components/base/text-generation/hooks.ts@@ -1,6 +1,6 @@import { useState } from 'react'import { useTranslation } from 'react-i18next'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import { ssePost } from '@/service/base'export const useTextGeneration = () => {diff --git a/web/app/components/base/toast/__tests__/index.spec.tsx b/web/app/components/base/toast/__tests__/index.spec.tsxindex f526290fa1a..2f5fa498235 100644--- a/web/app/components/base/toast/__tests__/index.spec.tsx+++ b/web/app/components/base/toast/__tests__/index.spec.tsx@@ -2,7 +2,8 @@ import type { ReactNode } from 'react'import { act, render, screen, waitFor } from '@testing-library/react'import { noop } from 'es-toolkit/function'import * as React from 'react'-import Toast, { ToastProvider, useToastContext } from '..'+import Toast, { ToastProvider } from '..'+import { useToastContext } from '../context'const TestComponent = () => {const { notify, close } = useToastContext()diff --git a/web/app/components/base/toast/context.ts b/web/app/components/base/toast/context.tsnew file mode 100644index 00000000000..ddd8f913362--- /dev/null+++ b/web/app/components/base/toast/context.ts@@ -0,0 +1,23 @@+'use client'++import type { ReactNode } from 'react'+import { createContext, useContext } from 'use-context-selector'++export type IToastProps = {+ type?: 'success' | 'error' | 'warning' | 'info'+ size?: 'md' | 'sm'+ duration?: number+ message: string+ children?: ReactNode+ onClose?: () => void+ className?: string+ customComponent?: ReactNode+}++type IToastContext = {+ notify: (props: IToastProps) => void+ close: () => void+}++export const ToastContext = createContext<IToastContext>({} as IToastContext)+export const useToastContext = () => useContext(ToastContext)diff --git a/web/app/components/base/toast/index.stories.tsx b/web/app/components/base/toast/index.stories.tsxindex 4ab9138070b..40d6fecfc24 100644--- a/web/app/components/base/toast/index.stories.tsx+++ b/web/app/components/base/toast/index.stories.tsx@@ -1,6 +1,7 @@import type { Meta, StoryObj } from '@storybook/nextjs-vite'import { useCallback } from 'react'-import Toast, { ToastProvider, useToastContext } from '.'+import Toast, { ToastProvider } from '.'+import { useToastContext } from './context'const ToastControls = () => {const { notify } = useToastContext()diff --git a/web/app/components/base/toast/index.tsx b/web/app/components/base/toast/index.tsxindex 1b9ae4eedb7..a70a0db06c4 100644--- a/web/app/components/base/toast/index.tsx+++ b/web/app/components/base/toast/index.tsx@@ -1,5 +1,6 @@'use client'import type { ReactNode } from 'react'+import type { IToastProps } from './context'import {RiAlertFill,RiCheckboxCircleFill,@@ -11,31 +12,13 @@ import { noop } from 'es-toolkit/function'import * as React from 'react'import { useEffect, useState } from 'react'import { createRoot } from 'react-dom/client'-import { createContext, useContext } from 'use-context-selector'import ActionButton from '@/app/components/base/action-button'import { cn } from '@/utils/classnames'--export type IToastProps = {- type?: 'success' | 'error' | 'warning' | 'info'- size?: 'md' | 'sm'- duration?: number- message: string- children?: ReactNode- onClose?: () => void- className?: string- customComponent?: ReactNode-}-type IToastContext = {- notify: (props: IToastProps) => void- close: () => void-}+import { ToastContext, useToastContext } from './context'export type ToastHandle = {clear?: VoidFunction}--export const ToastContext = createContext<IToastContext>({} as IToastContext)-export const useToastContext = () => useContext(ToastContext)const Toast = ({type = 'info',size = 'md',@@ -77,11 +60,11 @@ const Toast = ({</div><div className={cn('flex grow flex-col items-start gap-1 py-1', size === 'md' ? 'px-1' : 'px-0.5')}><div className="flex items-center gap-1">- <div className="system-sm-semibold text-text-primary [word-break:break-word]">{message}</div>+ <div className="text-text-primary system-sm-semibold [word-break:break-word]">{message}</div>{customComponent}</div>{!!children && (- <div className="system-xs-regular text-text-secondary">+ <div className="text-text-secondary system-xs-regular">{children}</div>)}@@ -183,3 +166,5 @@ Toast.notify = ({}export default Toast++export type { IToastProps } from './context'diff --git a/web/app/components/custom/custom-web-app-brand/__tests__/index.spec.tsx b/web/app/components/custom/custom-web-app-brand/__tests__/index.spec.tsxindex 2ceb45235ca..1d17a2ae0fb 100644--- a/web/app/components/custom/custom-web-app-brand/__tests__/index.spec.tsx+++ b/web/app/components/custom/custom-web-app-brand/__tests__/index.spec.tsx@@ -1,7 +1,7 @@import { fireEvent, render, screen, waitFor } from '@testing-library/react'import { beforeEach, describe, expect, it, vi } from 'vitest'import { getImageUploadErrorMessage, imageUpload } from '@/app/components/base/image-uploader/utils'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import { Plan } from '@/app/components/billing/type'import { useAppContext } from '@/context/app-context'import { useGlobalPublicStore } from '@/context/global-public-context'@@ -9,7 +9,7 @@ import { useProviderContext } from '@/context/provider-context'import { updateCurrentWorkspace } from '@/service/common'import CustomWebAppBrand from '../index'-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: vi.fn(),}))vi.mock('@/service/common', () => ({diff --git a/web/app/components/custom/custom-web-app-brand/index.tsx b/web/app/components/custom/custom-web-app-brand/index.tsxindex 438e69894de..e6f9a3837b0 100644--- a/web/app/components/custom/custom-web-app-brand/index.tsx+++ b/web/app/components/custom/custom-web-app-brand/index.tsx@@ -16,7 +16,7 @@ import { BubbleTextMod } from '@/app/components/base/icons/src/vender/solid/commimport { getImageUploadErrorMessage, imageUpload } from '@/app/components/base/image-uploader/utils'import DifyLogo from '@/app/components/base/logo/dify-logo'import Switch from '@/app/components/base/switch'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import { Plan } from '@/app/components/billing/type'import { useAppContext } from '@/context/app-context'import { useGlobalPublicStore } from '@/context/global-public-context'diff --git a/web/app/components/datasets/create-from-pipeline/create-options/create-from-dsl-modal/__tests__/uploader.spec.tsx b/web/app/components/datasets/create-from-pipeline/create-options/create-from-dsl-modal/__tests__/uploader.spec.tsxindex db67c91bc05..e47a876fe80 100644--- a/web/app/components/datasets/create-from-pipeline/create-options/create-from-dsl-modal/__tests__/uploader.spec.tsx+++ b/web/app/components/datasets/create-from-pipeline/create-options/create-from-dsl-modal/__tests__/uploader.spec.tsx@@ -4,7 +4,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'import Uploader from '../uploader'const mockNotify = vi.fn()-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({ToastContext: {Provider: ({ children }: { children: React.ReactNode }) => children,Consumer: ({ children }: { children: (value: { notify: typeof mockNotify }) => React.ReactNode }) => children({ notify: mockNotify }),diff --git a/web/app/components/datasets/create-from-pipeline/create-options/create-from-dsl-modal/hooks/use-dsl-import.ts b/web/app/components/datasets/create-from-pipeline/create-options/create-from-dsl-modal/hooks/use-dsl-import.tsindex 87e55ea7401..c839fad3a2d 100644--- a/web/app/components/datasets/create-from-pipeline/create-options/create-from-dsl-modal/hooks/use-dsl-import.ts+++ b/web/app/components/datasets/create-from-pipeline/create-options/create-from-dsl-modal/hooks/use-dsl-import.ts@@ -4,7 +4,7 @@ import { useRouter } from 'next/navigation'import { useCallback, useMemo, useRef, useState } from 'react'import { useTranslation } from 'react-i18next'import { useContext } from 'use-context-selector'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { usePluginDependencies } from '@/app/components/workflow/plugin-dependency/hooks'import {DSLImportMode,diff --git a/web/app/components/datasets/create-from-pipeline/create-options/create-from-dsl-modal/uploader.tsx b/web/app/components/datasets/create-from-pipeline/create-options/create-from-dsl-modal/uploader.tsxindex 3fa940c60d9..faf168c73a3 100644--- a/web/app/components/datasets/create-from-pipeline/create-options/create-from-dsl-modal/uploader.tsx+++ b/web/app/components/datasets/create-from-pipeline/create-options/create-from-dsl-modal/uploader.tsx@@ -10,7 +10,7 @@ import { useEffect, useRef, useState } from 'react'import { useTranslation } from 'react-i18next'import { useContext } from 'use-context-selector'import ActionButton from '@/app/components/base/action-button'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { cn } from '@/utils/classnames'import { formatFileSize } from '@/utils/format'diff --git a/web/app/components/datasets/create/empty-dataset-creation-modal/index.tsx b/web/app/components/datasets/create/empty-dataset-creation-modal/index.tsxindex a9f55c8b840..0a4064de2a5 100644--- a/web/app/components/datasets/create/empty-dataset-creation-modal/index.tsx+++ b/web/app/components/datasets/create/empty-dataset-creation-modal/index.tsx@@ -8,7 +8,7 @@ import { trackEvent } from '@/app/components/base/amplitude'import Button from '@/app/components/base/button'import Input from '@/app/components/base/input'import Modal from '@/app/components/base/modal'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { createEmptyDataset } from '@/service/datasets'import { useInvalidDatasetList } from '@/service/knowledge/use-dataset'diff --git a/web/app/components/datasets/create/file-uploader/hooks/__tests__/use-file-upload.spec.tsx b/web/app/components/datasets/create/file-uploader/hooks/__tests__/use-file-upload.spec.tsxindex b5d1a965548..80331afe2a2 100644--- a/web/app/components/datasets/create/file-uploader/hooks/__tests__/use-file-upload.spec.tsx+++ b/web/app/components/datasets/create/file-uploader/hooks/__tests__/use-file-upload.spec.tsx@@ -2,7 +2,7 @@ import type { ReactNode } from 'react'import type { CustomFile, FileItem } from '@/models/datasets'import { act, render, renderHook, waitFor } from '@testing-library/react'import { beforeEach, describe, expect, it, vi } from 'vitest'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { PROGRESS_COMPLETE, PROGRESS_ERROR, PROGRESS_NOT_STARTED } from '../../constants'// Import after mocksdiff --git a/web/app/components/datasets/create/file-uploader/hooks/use-file-upload.ts b/web/app/components/datasets/create/file-uploader/hooks/use-file-upload.tsindex e097bab755b..ada60fac1af 100644--- a/web/app/components/datasets/create/file-uploader/hooks/use-file-upload.ts+++ b/web/app/components/datasets/create/file-uploader/hooks/use-file-upload.ts@@ -5,7 +5,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react'import { useTranslation } from 'react-i18next'import { useContext } from 'use-context-selector'import { getFileUploadErrorMessage } from '@/app/components/base/file-uploader/utils'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { IS_CE_EDITION } from '@/config'import { useLocale } from '@/context/i18n'import { LanguagesSupported } from '@/i18n-config/language'diff --git a/web/app/components/datasets/documents/components/__tests__/operations.spec.tsx b/web/app/components/datasets/documents/components/__tests__/operations.spec.tsxindex 5aae8dda736..b988b1aeab6 100644--- a/web/app/components/datasets/documents/components/__tests__/operations.spec.tsx+++ b/web/app/components/datasets/documents/components/__tests__/operations.spec.tsx@@ -10,7 +10,7 @@ vi.mock('next/navigation', () => ({}))const mockNotify = vi.fn()-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({ToastContext: {Provider: ({ children }: { children: React.ReactNode }) => children,},diff --git a/web/app/components/datasets/documents/components/operations.tsx b/web/app/components/datasets/documents/components/operations.tsxindex 15c89a9b26b..84e16c7c486 100644--- a/web/app/components/datasets/documents/components/operations.tsx+++ b/web/app/components/datasets/documents/components/operations.tsx@@ -24,7 +24,7 @@ import Divider from '@/app/components/base/divider'import { SearchLinesSparkle } from '@/app/components/base/icons/src/vender/knowledge'import CustomPopover from '@/app/components/base/popover'import Switch from '@/app/components/base/switch'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import Tooltip from '@/app/components/base/tooltip'import { IS_CE_EDITION } from '@/config'import { DataSourceType, DocumentActionType } from '@/models/datasets'diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/local-file/hooks/__tests__/use-local-file-upload.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/local-file/hooks/__tests__/use-local-file-upload.spec.tsxindex bc9ce04beb5..efd1f2a4835 100644--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/local-file/hooks/__tests__/use-local-file-upload.spec.tsx+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/local-file/hooks/__tests__/use-local-file-upload.spec.tsx@@ -9,7 +9,7 @@ const mockNotify = vi.fn()const mockClose = vi.fn()// Mock ToastContext with factory function-vi.mock('@/app/components/base/toast', async () => {+vi.mock('@/app/components/base/toast/context', async () => {const { createContext, useContext } = await import('use-context-selector')const context = createContext({ notify: mockNotify, close: mockClose })return {@@ -87,7 +87,7 @@ vi.mock('@/service/base', () => ({// Import after all mocks are set upconst { useLocalFileUpload } = await import('../use-local-file-upload')-const { ToastContext } = await import('@/app/components/base/toast')+const { ToastContext } = await import('@/app/components/base/toast/context')const createWrapper = () => {return ({ children }: { children: ReactNode }) => (diff --git a/web/app/components/datasets/documents/detail/batch-modal/__tests__/csv-uploader.spec.tsx b/web/app/components/datasets/documents/detail/batch-modal/__tests__/csv-uploader.spec.tsxindex 7fb1de7cf95..68767537148 100644--- a/web/app/components/datasets/documents/detail/batch-modal/__tests__/csv-uploader.spec.tsx+++ b/web/app/components/datasets/documents/detail/batch-modal/__tests__/csv-uploader.spec.tsx@@ -25,7 +25,7 @@ vi.mock('@/hooks/use-theme', () => ({}))const mockNotify = vi.fn()-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({ToastContext: {Provider: ({ children }: { children: ReactNode }) => children,Consumer: ({ children }: { children: (ctx: { notify: typeof mockNotify }) => ReactNode }) => children({ notify: mockNotify }),diff --git a/web/app/components/datasets/documents/detail/batch-modal/csv-uploader.tsx b/web/app/components/datasets/documents/detail/batch-modal/csv-uploader.tsxindex f3a86e910d2..63efc766b77 100644--- a/web/app/components/datasets/documents/detail/batch-modal/csv-uploader.tsx+++ b/web/app/components/datasets/documents/detail/batch-modal/csv-uploader.tsx@@ -12,7 +12,7 @@ import Button from '@/app/components/base/button'import { getFileUploadErrorMessage } from '@/app/components/base/file-uploader/utils'import { Csv as CSVIcon } from '@/app/components/base/icons/src/public/files'import SimplePieChart from '@/app/components/base/simple-pie-chart'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import useTheme from '@/hooks/use-theme'import { upload } from '@/service/base'import { useFileUploadConfig } from '@/service/use-common'diff --git a/web/app/components/datasets/documents/detail/completed/__tests__/index.spec.tsx b/web/app/components/datasets/documents/detail/completed/__tests__/index.spec.tsxindex 5802fb8b822..59ecbf5f257 100644--- a/web/app/components/datasets/documents/detail/completed/__tests__/index.spec.tsx+++ b/web/app/components/datasets/documents/detail/completed/__tests__/index.spec.tsx@@ -65,7 +65,7 @@ vi.mock('../../context', () => ({},}))-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({ToastContext: { Provider: ({ children }: { children: React.ReactNode }) => children, Consumer: () => null },useToastContext: () => ({ notify: mockNotify }),}))diff --git a/web/app/components/datasets/documents/detail/completed/common/__tests__/regeneration-modal.spec.tsx b/web/app/components/datasets/documents/detail/completed/common/__tests__/regeneration-modal.spec.tsxindex 719e2867b7b..cc7f1aafa41 100644--- a/web/app/components/datasets/documents/detail/completed/common/__tests__/regeneration-modal.spec.tsx+++ b/web/app/components/datasets/documents/detail/completed/common/__tests__/regeneration-modal.spec.tsx@@ -1,7 +1,8 @@import type { ReactNode } from 'react'import { act, fireEvent, render, screen, waitFor } from '@testing-library/react'import { beforeEach, describe, expect, it, vi } from 'vitest'-import { EventEmitterContextProvider, useEventEmitterContextContext } from '@/context/event-emitter'+import { useEventEmitterContextContext } from '@/context/event-emitter'+import { EventEmitterContextProvider } from '@/context/event-emitter-provider'import RegenerationModal from '../regeneration-modal'// Store emit function for triggering events in testsdiff --git a/web/app/components/datasets/documents/detail/completed/hooks/__tests__/use-child-segment-data.spec.ts b/web/app/components/datasets/documents/detail/completed/hooks/__tests__/use-child-segment-data.spec.tsindex 83918a3f303..4cfb4d5927e 100644--- a/web/app/components/datasets/documents/detail/completed/hooks/__tests__/use-child-segment-data.spec.ts+++ b/web/app/components/datasets/documents/detail/completed/hooks/__tests__/use-child-segment-data.spec.ts@@ -59,7 +59,7 @@ vi.mock('../../../context', () => ({},}))-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: () => ({ notify: mockNotify }),}))diff --git a/web/app/components/datasets/documents/detail/completed/hooks/__tests__/use-segment-list-data.spec.ts b/web/app/components/datasets/documents/detail/completed/hooks/__tests__/use-segment-list-data.spec.tsindex aef2053298f..f54c00e3e7d 100644--- a/web/app/components/datasets/documents/detail/completed/hooks/__tests__/use-segment-list-data.spec.ts+++ b/web/app/components/datasets/documents/detail/completed/hooks/__tests__/use-segment-list-data.spec.ts@@ -92,7 +92,7 @@ vi.mock('../../../context', () => ({},}))-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: () => ({ notify: mockNotify }),}))diff --git a/web/app/components/datasets/documents/detail/completed/hooks/use-child-segment-data.ts b/web/app/components/datasets/documents/detail/completed/hooks/use-child-segment-data.tsindex 4f4c6a532dc..cdc8a0b22d3 100644--- a/web/app/components/datasets/documents/detail/completed/hooks/use-child-segment-data.ts+++ b/web/app/components/datasets/documents/detail/completed/hooks/use-child-segment-data.ts@@ -2,7 +2,7 @@ import type { ChildChunkDetail, ChildSegmentsResponse, SegmentDetailModel, Segmeimport { useQueryClient } from '@tanstack/react-query'import { useCallback, useEffect, useMemo, useRef } from 'react'import { useTranslation } from 'react-i18next'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import { useEventEmitterContextContext } from '@/context/event-emitter'import {useChildSegmentList,diff --git a/web/app/components/datasets/documents/detail/completed/hooks/use-segment-list-data.ts b/web/app/components/datasets/documents/detail/completed/hooks/use-segment-list-data.tsindex fd391d2864f..aa91e9f464f 100644--- a/web/app/components/datasets/documents/detail/completed/hooks/use-segment-list-data.ts+++ b/web/app/components/datasets/documents/detail/completed/hooks/use-segment-list-data.ts@@ -4,7 +4,7 @@ import { useQueryClient } from '@tanstack/react-query'import { usePathname } from 'next/navigation'import { useCallback, useEffect, useMemo, useRef } from 'react'import { useTranslation } from 'react-i18next'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import { useEventEmitterContextContext } from '@/context/event-emitter'import { ChunkingMode } from '@/models/datasets'import {diff --git a/web/app/components/datasets/documents/detail/completed/new-child-segment.tsx b/web/app/components/datasets/documents/detail/completed/new-child-segment.tsxindex 89143662c60..7a6ae4b306c 100644--- a/web/app/components/datasets/documents/detail/completed/new-child-segment.tsx+++ b/web/app/components/datasets/documents/detail/completed/new-child-segment.tsx@@ -8,7 +8,7 @@ import { useContext } from 'use-context-selector'import { useShallow } from 'zustand/react/shallow'import { useStore as useAppStore } from '@/app/components/app/store'import Divider from '@/app/components/base/divider'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { ChunkingMode } from '@/models/datasets'import { useAddChildSegment } from '@/service/knowledge/use-segment'import { cn } from '@/utils/classnames'diff --git a/web/app/components/datasets/documents/detail/embedding/index.tsx b/web/app/components/datasets/documents/detail/embedding/index.tsxindex e89a85c6de8..bd344800db5 100644--- a/web/app/components/datasets/documents/detail/embedding/index.tsx+++ b/web/app/components/datasets/documents/detail/embedding/index.tsx@@ -5,7 +5,7 @@ import * as React from 'react'import { useCallback } from 'react'import { useTranslation } from 'react-i18next'import { useContext } from 'use-context-selector'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { useProcessRule } from '@/service/knowledge/use-dataset'import { useDocumentContext } from '../context'import { ProgressBar, RuleDetail, SegmentProgress, StatusHeader } from './components'diff --git a/web/app/components/datasets/documents/detail/metadata/hooks/__tests__/use-metadata-state.spec.ts b/web/app/components/datasets/documents/detail/metadata/hooks/__tests__/use-metadata-state.spec.tsindex ab1d45338fe..3d7b28c78c5 100644--- a/web/app/components/datasets/documents/detail/metadata/hooks/__tests__/use-metadata-state.spec.ts+++ b/web/app/components/datasets/documents/detail/metadata/hooks/__tests__/use-metadata-state.spec.ts@@ -3,7 +3,7 @@ import type { FullDocumentDetail } from '@/models/datasets'import { act, renderHook } from '@testing-library/react'import * as React from 'react'import { describe, expect, it, vi } from 'vitest'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { useMetadataState } from '../use-metadata-state'diff --git a/web/app/components/datasets/documents/detail/metadata/hooks/use-metadata-state.ts b/web/app/components/datasets/documents/detail/metadata/hooks/use-metadata-state.tsindex 08651b699e4..f7866099819 100644--- a/web/app/components/datasets/documents/detail/metadata/hooks/use-metadata-state.ts+++ b/web/app/components/datasets/documents/detail/metadata/hooks/use-metadata-state.ts@@ -4,7 +4,7 @@ import type { DocType, FullDocumentDetail } from '@/models/datasets'import { useEffect, useState } from 'react'import { useTranslation } from 'react-i18next'import { useContext } from 'use-context-selector'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { modifyDocMetadata } from '@/service/datasets'import { asyncRunSafe } from '@/utils'import { useDocumentContext } from '../../context'diff --git a/web/app/components/datasets/documents/detail/new-segment.tsx b/web/app/components/datasets/documents/detail/new-segment.tsxindex 3a58d6ac068..f32c94bf70f 100644--- a/web/app/components/datasets/documents/detail/new-segment.tsx+++ b/web/app/components/datasets/documents/detail/new-segment.tsx@@ -9,7 +9,7 @@ import { useContext } from 'use-context-selector'import { useShallow } from 'zustand/react/shallow'import { useStore as useAppStore } from '@/app/components/app/store'import Divider from '@/app/components/base/divider'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import ImageUploaderInChunk from '@/app/components/datasets/common/image-uploader/image-uploader-in-chunk'import { useDatasetDetailContextWithSelector } from '@/context/dataset-detail'import { ChunkingMode } from '@/models/datasets'diff --git a/web/app/components/datasets/documents/status-item/index.tsx b/web/app/components/datasets/documents/status-item/index.tsxindex 60d837fd81c..8d3abed7cf7 100644--- a/web/app/components/datasets/documents/status-item/index.tsx+++ b/web/app/components/datasets/documents/status-item/index.tsx@@ -8,7 +8,7 @@ import { useMemo } from 'react'import { useTranslation } from 'react-i18next'import { useContext } from 'use-context-selector'import Switch from '@/app/components/base/switch'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import Tooltip from '@/app/components/base/tooltip'import Indicator from '@/app/components/header/indicator'import { useDocumentDelete, useDocumentDisable, useDocumentEnable } from '@/service/knowledge/use-document'diff --git a/web/app/components/datasets/external-api/external-api-modal/__tests__/index.spec.tsx b/web/app/components/datasets/external-api/external-api-modal/__tests__/index.spec.tsxindex a631de3ea0c..66d9a163be0 100644--- a/web/app/components/datasets/external-api/external-api-modal/__tests__/index.spec.tsx+++ b/web/app/components/datasets/external-api/external-api-modal/__tests__/index.spec.tsx@@ -12,7 +12,7 @@ vi.mock('@/service/datasets', () => ({}))const mockNotify = vi.fn()-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: () => ({notify: mockNotify,}),diff --git a/web/app/components/datasets/external-api/external-api-modal/index.tsx b/web/app/components/datasets/external-api/external-api-modal/index.tsxindex a9a87d11bd8..b6e870cdc18 100644--- a/web/app/components/datasets/external-api/external-api-modal/index.tsx+++ b/web/app/components/datasets/external-api/external-api-modal/index.tsx@@ -19,7 +19,7 @@ import {PortalToFollowElem,PortalToFollowElemContent,} from '@/app/components/base/portal-to-follow-elem'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import Tooltip from '@/app/components/base/tooltip'import { createExternalAPI } from '@/service/datasets'import Form from './Form'diff --git a/web/app/components/datasets/external-knowledge-base/connector/__tests__/index.spec.tsx b/web/app/components/datasets/external-knowledge-base/connector/__tests__/index.spec.tsxindex ccd637887b2..a6a60aa8569 100644--- a/web/app/components/datasets/external-knowledge-base/connector/__tests__/index.spec.tsx+++ b/web/app/components/datasets/external-knowledge-base/connector/__tests__/index.spec.tsx@@ -22,7 +22,7 @@ vi.mock('@/context/i18n', () => ({}))const mockNotify = vi.fn()-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: () => ({notify: mockNotify,}),diff --git a/web/app/components/datasets/external-knowledge-base/connector/index.tsx b/web/app/components/datasets/external-knowledge-base/connector/index.tsxindex 1545c0d232a..cf36eed382a 100644--- a/web/app/components/datasets/external-knowledge-base/connector/index.tsx+++ b/web/app/components/datasets/external-knowledge-base/connector/index.tsx@@ -5,7 +5,7 @@ import { useRouter } from 'next/navigation'import * as React from 'react'import { useState } from 'react'import { trackEvent } from '@/app/components/base/amplitude'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import ExternalKnowledgeBaseCreate from '@/app/components/datasets/external-knowledge-base/create'import { createExternalKnowledgeBase } from '@/service/datasets'diff --git a/web/app/components/header/account-dropdown/workplace-selector/index.spec.tsx b/web/app/components/header/account-dropdown/workplace-selector/index.spec.tsxindex fc32b5f8dff..20104b572c1 100644--- a/web/app/components/header/account-dropdown/workplace-selector/index.spec.tsx+++ b/web/app/components/header/account-dropdown/workplace-selector/index.spec.tsx@@ -1,7 +1,7 @@import type { ProviderContextState } from '@/context/provider-context'import type { IWorkspace } from '@/models/common'import { fireEvent, render, screen, waitFor } from '@testing-library/react'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { baseProviderContextValue, useProviderContext } from '@/context/provider-context'import { useWorkspacesContext } from '@/context/workspace-context'import { switchWorkspace } from '@/service/common'diff --git a/web/app/components/header/account-dropdown/workplace-selector/index.tsx b/web/app/components/header/account-dropdown/workplace-selector/index.tsxindex 058935aa279..528686a26aa 100644--- a/web/app/components/header/account-dropdown/workplace-selector/index.tsx+++ b/web/app/components/header/account-dropdown/workplace-selector/index.tsx@@ -4,7 +4,7 @@ import { RiArrowDownSLine } from '@remixicon/react'import { Fragment } from 'react'import { useTranslation } from 'react-i18next'import { useContext } from 'use-context-selector'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import PlanBadge from '@/app/components/header/plan-badge'import { useWorkspacesContext } from '@/context/workspace-context'import { switchWorkspace } from '@/service/common'diff --git a/web/app/components/header/account-setting/api-based-extension-page/modal.spec.tsx b/web/app/components/header/account-setting/api-based-extension-page/modal.spec.tsxindex 3903fbfcf31..884ee8df335 100644--- a/web/app/components/header/account-setting/api-based-extension-page/modal.spec.tsx+++ b/web/app/components/header/account-setting/api-based-extension-page/modal.spec.tsx@@ -1,8 +1,8 @@import type { TFunction } from 'i18next'-import type { IToastProps } from '@/app/components/base/toast'+import type { IToastProps } from '@/app/components/base/toast/context'import { fireEvent, render as RTLRender, screen, waitFor } from '@testing-library/react'import * as reactI18next from 'react-i18next'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { useDocLink } from '@/context/i18n'import { addApiBasedExtension, updateApiBasedExtension } from '@/service/common'import ApiBasedExtensionModal from './modal'diff --git a/web/app/components/header/account-setting/api-based-extension-page/modal.tsx b/web/app/components/header/account-setting/api-based-extension-page/modal.tsxindex b04981bf3cb..efe6c46dcc5 100644--- a/web/app/components/header/account-setting/api-based-extension-page/modal.tsx+++ b/web/app/components/header/account-setting/api-based-extension-page/modal.tsx@@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next'import Button from '@/app/components/base/button'import { BookOpen01 } from '@/app/components/base/icons/src/vender/line/education'import Modal from '@/app/components/base/modal'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import { useDocLink } from '@/context/i18n'import {addApiBasedExtension,diff --git a/web/app/components/header/account-setting/language-page/index.tsx b/web/app/components/header/account-setting/language-page/index.tsxindex 2a0604421fb..5751e882850 100644--- a/web/app/components/header/account-setting/language-page/index.tsx+++ b/web/app/components/header/account-setting/language-page/index.tsx@@ -7,7 +7,7 @@ import { useState } from 'react'import { useTranslation } from 'react-i18next'import { useContext } from 'use-context-selector'import { SimpleSelect } from '@/app/components/base/select'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { useAppContext } from '@/context/app-context'import { useLocale } from '@/context/i18n'import { setLocaleOnClient } from '@/i18n-config'diff --git a/web/app/components/header/account-setting/members-page/edit-workspace-modal/index.spec.tsx b/web/app/components/header/account-setting/members-page/edit-workspace-modal/index.spec.tsxindex 46ce3f19927..ae0dd8cd4d4 100644--- a/web/app/components/header/account-setting/members-page/edit-workspace-modal/index.spec.tsx+++ b/web/app/components/header/account-setting/members-page/edit-workspace-modal/index.spec.tsx@@ -3,7 +3,7 @@ import type { ICurrentWorkspace } from '@/models/common'import { render, screen, waitFor } from '@testing-library/react'import userEvent from '@testing-library/user-event'import { vi } from 'vitest'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { useAppContext } from '@/context/app-context'import { updateWorkspaceInfo } from '@/service/common'import EditWorkspaceModal from './index'diff --git a/web/app/components/header/account-setting/members-page/edit-workspace-modal/index.tsx b/web/app/components/header/account-setting/members-page/edit-workspace-modal/index.tsxindex a702a83da99..1c3984b0b59 100644--- a/web/app/components/header/account-setting/members-page/edit-workspace-modal/index.tsx+++ b/web/app/components/header/account-setting/members-page/edit-workspace-modal/index.tsx@@ -6,7 +6,7 @@ import { useContext } from 'use-context-selector'import Button from '@/app/components/base/button'import Input from '@/app/components/base/input'import Modal from '@/app/components/base/modal'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { useAppContext } from '@/context/app-context'import { updateWorkspaceInfo } from '@/service/common'import { cn } from '@/utils/classnames'diff --git a/web/app/components/header/account-setting/members-page/invite-modal/index.spec.tsx b/web/app/components/header/account-setting/members-page/invite-modal/index.spec.tsxindex ef55425ee0d..82882c8be5d 100644--- a/web/app/components/header/account-setting/members-page/invite-modal/index.spec.tsx+++ b/web/app/components/header/account-setting/members-page/invite-modal/index.spec.tsx@@ -2,7 +2,7 @@ import type { InvitationResponse } from '@/models/common'import { render, screen, waitFor } from '@testing-library/react'import userEvent from '@testing-library/user-event'import { vi } from 'vitest'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { useProviderContextSelector } from '@/context/provider-context'import { inviteMember } from '@/service/common'import InviteModal from './index'diff --git a/web/app/components/header/account-setting/members-page/invite-modal/index.tsx b/web/app/components/header/account-setting/members-page/invite-modal/index.tsxindex a8c0da40bfa..8e4e47e0b89 100644--- a/web/app/components/header/account-setting/members-page/invite-modal/index.tsx+++ b/web/app/components/header/account-setting/members-page/invite-modal/index.tsx@@ -9,7 +9,7 @@ import { ReactMultiEmail } from 'react-multi-email'import { useContext } from 'use-context-selector'import Button from '@/app/components/base/button'import Modal from '@/app/components/base/modal'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { emailRegex } from '@/config'import { useLocale } from '@/context/i18n'import { useProviderContextSelector } from '@/context/provider-context'diff --git a/web/app/components/header/account-setting/members-page/operation/index.spec.tsx b/web/app/components/header/account-setting/members-page/operation/index.spec.tsxindex 661b2fbc83a..e5e7fac10f4 100644--- a/web/app/components/header/account-setting/members-page/operation/index.spec.tsx+++ b/web/app/components/header/account-setting/members-page/operation/index.spec.tsx@@ -2,7 +2,7 @@ import type { Member } from '@/models/common'import { render, screen, waitFor } from '@testing-library/react'import userEvent from '@testing-library/user-event'import { vi } from 'vitest'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import Operation from './index'const mockUpdateMemberRole = vi.fn()diff --git a/web/app/components/header/account-setting/members-page/operation/index.tsx b/web/app/components/header/account-setting/members-page/operation/index.tsxindex 88c8e250ea1..306a67a093e 100644--- a/web/app/components/header/account-setting/members-page/operation/index.tsx+++ b/web/app/components/header/account-setting/members-page/operation/index.tsx@@ -9,7 +9,7 @@ import {PortalToFollowElemContent,PortalToFollowElemTrigger,} from '@/app/components/base/portal-to-follow-elem'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { useProviderContext } from '@/context/provider-context'import { deleteMemberOrCancelInvitation, updateMemberRole } from '@/service/common'import { cn } from '@/utils/classnames'diff --git a/web/app/components/header/account-setting/members-page/transfer-ownership-modal/index.spec.tsx b/web/app/components/header/account-setting/members-page/transfer-ownership-modal/index.spec.tsxindex 11a0a2db4ab..4baa90a7fa9 100644--- a/web/app/components/header/account-setting/members-page/transfer-ownership-modal/index.spec.tsx+++ b/web/app/components/header/account-setting/members-page/transfer-ownership-modal/index.spec.tsx@@ -3,7 +3,7 @@ import type { ICurrentWorkspace } from '@/models/common'import { act, fireEvent, render, screen, waitFor } from '@testing-library/react'import userEvent from '@testing-library/user-event'import { vi } from 'vitest'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { useAppContext } from '@/context/app-context'import { ownershipTransfer, sendOwnerEmail, verifyOwnerEmail } from '@/service/common'import { useMembers } from '@/service/use-common'diff --git a/web/app/components/header/account-setting/members-page/transfer-ownership-modal/index.tsx b/web/app/components/header/account-setting/members-page/transfer-ownership-modal/index.tsxindex 21ea8aa1e93..c4f614737a1 100644--- a/web/app/components/header/account-setting/members-page/transfer-ownership-modal/index.tsx+++ b/web/app/components/header/account-setting/members-page/transfer-ownership-modal/index.tsx@@ -6,7 +6,7 @@ import { useContext } from 'use-context-selector'import Button from '@/app/components/base/button'import Input from '@/app/components/base/input'import Modal from '@/app/components/base/modal'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { useAppContext } from '@/context/app-context'import {ownershipTransfer,diff --git a/web/app/components/header/account-setting/model-provider-page/model-auth/hooks/use-auth.spec.tsx b/web/app/components/header/account-setting/model-provider-page/model-auth/hooks/use-auth.spec.tsxindex c2259f543c3..b637fed8945 100644--- a/web/app/components/header/account-setting/model-provider-page/model-auth/hooks/use-auth.spec.tsx+++ b/web/app/components/header/account-setting/model-provider-page/model-auth/hooks/use-auth.spec.tsx@@ -20,7 +20,7 @@ const mockAddModelCredential = vi.fn()const mockEditProviderCredential = vi.fn()const mockEditModelCredential = vi.fn()-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: () => ({ notify: mockNotify }),}))diff --git a/web/app/components/header/account-setting/model-provider-page/model-auth/hooks/use-auth.ts b/web/app/components/header/account-setting/model-provider-page/model-auth/hooks/use-auth.tsindex 3576c749b2d..4e01677b291 100644--- a/web/app/components/header/account-setting/model-provider-page/model-auth/hooks/use-auth.ts+++ b/web/app/components/header/account-setting/model-provider-page/model-auth/hooks/use-auth.ts@@ -12,7 +12,7 @@ import {useState,} from 'react'import { useTranslation } from 'react-i18next'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import {useModelModalHandler,useRefreshModel,diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/credential-panel.spec.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/credential-panel.spec.tsxindex 554efc93d2d..9f493d25e5e 100644--- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/credential-panel.spec.tsx+++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/credential-panel.spec.tsx@@ -24,7 +24,7 @@ vi.mock('@/config', async (importOriginal) => {}})-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: () => ({notify: mockNotify,}),diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/credential-panel.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/credential-panel.tsxindex c46f9d56bd1..efa768e7f58 100644--- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/credential-panel.tsx+++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/credential-panel.tsx@@ -3,7 +3,7 @@ import type {} from '../declarations'import { useMemo } from 'react'import { useTranslation } from 'react-i18next'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import { ConfigProvider } from '@/app/components/header/account-setting/model-provider-page/model-auth'import { useCredentialStatus } from '@/app/components/header/account-setting/model-provider-page/model-auth/hooks'import Indicator from '@/app/components/header/indicator'diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-modal.spec.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-modal.spec.tsxindex ea782346121..b945b50e9b5 100644--- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-modal.spec.tsx+++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-modal.spec.tsx@@ -43,7 +43,7 @@ let mockCredentialData: CredentialData | undefined = {current_credential_name: 'Default',}-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: () => ({notify: mockNotify,}),diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-modal.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-modal.tsxindex 93229f1257f..0009237edc9 100644--- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-modal.tsx+++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-modal.tsx@@ -12,7 +12,7 @@ import Button from '@/app/components/base/button'import Confirm from '@/app/components/base/confirm'import Loading from '@/app/components/base/loading'import Modal from '@/app/components/base/modal'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import { SwitchCredentialInLoadBalancing } from '@/app/components/header/account-setting/model-provider-page/model-auth'import {useGetModelCredential,diff --git a/web/app/components/header/account-setting/model-provider-page/system-model-selector/index.spec.tsx b/web/app/components/header/account-setting/model-provider-page/system-model-selector/index.spec.tsxindex 819bb711646..22186b34e11 100644--- a/web/app/components/header/account-setting/model-provider-page/system-model-selector/index.spec.tsx+++ b/web/app/components/header/account-setting/model-provider-page/system-model-selector/index.spec.tsx@@ -42,7 +42,7 @@ vi.mock('@/context/provider-context', () => ({}),}))-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: () => ({notify: mockNotify,}),diff --git a/web/app/components/header/account-setting/model-provider-page/system-model-selector/index.tsx b/web/app/components/header/account-setting/model-provider-page/system-model-selector/index.tsxindex 29c71e04fcb..5df062789b1 100644--- a/web/app/components/header/account-setting/model-provider-page/system-model-selector/index.tsx+++ b/web/app/components/header/account-setting/model-provider-page/system-model-selector/index.tsx@@ -12,7 +12,7 @@ import {PortalToFollowElemContent,PortalToFollowElemTrigger,} from '@/app/components/base/portal-to-follow-elem'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import Tooltip from '@/app/components/base/tooltip'import { useAppContext } from '@/context/app-context'import { useProviderContext } from '@/context/provider-context'diff --git a/web/app/components/header/account-setting/plugin-page/SerpapiPlugin.spec.tsx b/web/app/components/header/account-setting/plugin-page/SerpapiPlugin.spec.tsxindex de480d47a17..97a79815ff4 100644--- a/web/app/components/header/account-setting/plugin-page/SerpapiPlugin.spec.tsx+++ b/web/app/components/header/account-setting/plugin-page/SerpapiPlugin.spec.tsx@@ -1,6 +1,6 @@import type { PluginProvider } from '@/models/common'import { act, fireEvent, render, screen, waitFor } from '@testing-library/react'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import { useAppContext } from '@/context/app-context'import SerpapiPlugin from './SerpapiPlugin'import { updatePluginKey, validatePluginKey } from './utils'@@ -20,7 +20,7 @@ const mockEventEmitter = vi.hoisted(() => {}})-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: vi.fn(),}))diff --git a/web/app/components/header/account-setting/plugin-page/SerpapiPlugin.tsx b/web/app/components/header/account-setting/plugin-page/SerpapiPlugin.tsxindex f6909fad284..fe8832e84b6 100644--- a/web/app/components/header/account-setting/plugin-page/SerpapiPlugin.tsx+++ b/web/app/components/header/account-setting/plugin-page/SerpapiPlugin.tsx@@ -2,7 +2,7 @@ import type { Form, ValidateValue } from '../key-validator/declarations'import type { PluginProvider } from '@/models/common'import Image from 'next/image'import { useTranslation } from 'react-i18next'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import { useAppContext } from '@/context/app-context'import SerpapiLogo from '../../assets/serpapi.png'import KeyValidator from '../key-validator'diff --git a/web/app/components/header/account-setting/plugin-page/index.spec.tsx b/web/app/components/header/account-setting/plugin-page/index.spec.tsxindex 654292443f7..0654bb68aa5 100644--- a/web/app/components/header/account-setting/plugin-page/index.spec.tsx+++ b/web/app/components/header/account-setting/plugin-page/index.spec.tsx@@ -14,7 +14,7 @@ vi.mock('@/context/app-context', () => ({useAppContext: vi.fn(),}))-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: () => ({notify: vi.fn(),}),diff --git a/web/app/components/header/index.spec.tsx b/web/app/components/header/index.spec.tsxindex 2d5ce50fb86..36c85e6f082 100644--- a/web/app/components/header/index.spec.tsx+++ b/web/app/components/header/index.spec.tsx@@ -52,7 +52,7 @@ vi.mock('@/app/components/header/plan-badge', () => ({),}))-vi.mock('@/context/workspace-context', () => ({+vi.mock('@/context/workspace-context-provider', () => ({WorkspaceProvider: ({ children }: { children?: React.ReactNode }) => children,}))diff --git a/web/app/components/header/index.tsx b/web/app/components/header/index.tsxindex 210c62b6604..64498a82f83 100644--- a/web/app/components/header/index.tsx+++ b/web/app/components/header/index.tsx@@ -8,7 +8,7 @@ import { useAppContext } from '@/context/app-context'import { useGlobalPublicStore } from '@/context/global-public-context'import { useModalContext } from '@/context/modal-context'import { useProviderContext } from '@/context/provider-context'-import { WorkspaceProvider } from '@/context/workspace-context'+import { WorkspaceProvider } from '@/context/workspace-context-provider'import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'import { Plan } from '../billing/type'import AccountDropdown from './account-dropdown'diff --git a/web/app/components/plugins/plugin-auth/__tests__/authorized-in-node.spec.tsx b/web/app/components/plugins/plugin-auth/__tests__/authorized-in-node.spec.tsxindex 7e8208b995b..91ffbaa24a2 100644--- a/web/app/components/plugins/plugin-auth/__tests__/authorized-in-node.spec.tsx+++ b/web/app/components/plugins/plugin-auth/__tests__/authorized-in-node.spec.tsx@@ -42,7 +42,7 @@ vi.mock('@/context/app-context', () => ({}),}))-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: () => ({ notify: vi.fn() }),}))diff --git a/web/app/components/plugins/plugin-auth/__tests__/plugin-auth-in-agent.spec.tsx b/web/app/components/plugins/plugin-auth/__tests__/plugin-auth-in-agent.spec.tsxindex 6b66aca9ddf..901c3ab49a3 100644--- a/web/app/components/plugins/plugin-auth/__tests__/plugin-auth-in-agent.spec.tsx+++ b/web/app/components/plugins/plugin-auth/__tests__/plugin-auth-in-agent.spec.tsx@@ -42,7 +42,7 @@ vi.mock('@/context/app-context', () => ({}),}))-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: () => ({ notify: vi.fn() }),}))diff --git a/web/app/components/plugins/plugin-auth/authorize/__tests__/api-key-modal.spec.tsx b/web/app/components/plugins/plugin-auth/authorize/__tests__/api-key-modal.spec.tsxindex a99b3363d65..430149e50bd 100644--- a/web/app/components/plugins/plugin-auth/authorize/__tests__/api-key-modal.spec.tsx+++ b/web/app/components/plugins/plugin-auth/authorize/__tests__/api-key-modal.spec.tsx@@ -9,7 +9,7 @@ const mockAddPluginCredential = vi.fn().mockResolvedValue({})const mockUpdatePluginCredential = vi.fn().mockResolvedValue({})const mockFormValues = { isCheckValidated: true, values: { __name__: 'My Key', api_key: 'sk-123' } }-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: () => ({notify: mockNotify,}),diff --git a/web/app/components/plugins/plugin-auth/authorize/__tests__/authorize-components.spec.tsx b/web/app/components/plugins/plugin-auth/authorize/__tests__/authorize-components.spec.tsxindex 51aa287fea9..d120902e6db 100644--- a/web/app/components/plugins/plugin-auth/authorize/__tests__/authorize-components.spec.tsx+++ b/web/app/components/plugins/plugin-auth/authorize/__tests__/authorize-components.spec.tsx@@ -95,7 +95,7 @@ vi.mock('@/app/components/base/form/form-scenarios/auth', () => ({// Mock useToastContextconst mockNotify = vi.fn()-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: () => ({ notify: mockNotify }),}))diff --git a/web/app/components/plugins/plugin-auth/authorize/__tests__/oauth-client-settings.spec.tsx b/web/app/components/plugins/plugin-auth/authorize/__tests__/oauth-client-settings.spec.tsxindex 61920e2869f..f1b86f80eaf 100644--- a/web/app/components/plugins/plugin-auth/authorize/__tests__/oauth-client-settings.spec.tsx+++ b/web/app/components/plugins/plugin-auth/authorize/__tests__/oauth-client-settings.spec.tsx@@ -9,7 +9,7 @@ const mockDeletePluginOAuthCustomClient = vi.fn().mockResolvedValue({})const mockInvalidPluginOAuthClientSchema = vi.fn()const mockFormValues = { isCheckValidated: true, values: { __oauth_client__: 'custom', client_id: 'test-id' } }-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: () => ({notify: mockNotify,}),diff --git a/web/app/components/plugins/plugin-auth/authorize/api-key-modal.tsx b/web/app/components/plugins/plugin-auth/authorize/api-key-modal.tsxindex cc98ca3731e..d8ab1cafdd4 100644--- a/web/app/components/plugins/plugin-auth/authorize/api-key-modal.tsx+++ b/web/app/components/plugins/plugin-auth/authorize/api-key-modal.tsx@@ -16,7 +16,7 @@ import AuthForm from '@/app/components/base/form/form-scenarios/auth'import { FormTypeEnum } from '@/app/components/base/form/types'import Loading from '@/app/components/base/loading'import Modal from '@/app/components/base/modal/modal'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import { ReadmeEntrance } from '../../readme-panel/entrance'import { ReadmeShowType } from '../../readme-panel/store'import {diff --git a/web/app/components/plugins/plugin-auth/authorize/oauth-client-settings.tsx b/web/app/components/plugins/plugin-auth/authorize/oauth-client-settings.tsxindex 7eb22ee4aca..28989da77c4 100644--- a/web/app/components/plugins/plugin-auth/authorize/oauth-client-settings.tsx+++ b/web/app/components/plugins/plugin-auth/authorize/oauth-client-settings.tsx@@ -17,7 +17,7 @@ import { useTranslation } from 'react-i18next'import Button from '@/app/components/base/button'import AuthForm from '@/app/components/base/form/form-scenarios/auth'import Modal from '@/app/components/base/modal/modal'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import { ReadmeEntrance } from '../../readme-panel/entrance'import { ReadmeShowType } from '../../readme-panel/store'import {diff --git a/web/app/components/plugins/plugin-auth/authorized/__tests__/index.spec.tsx b/web/app/components/plugins/plugin-auth/authorized/__tests__/index.spec.tsxindex f56c8142220..a617c2543e6 100644--- a/web/app/components/plugins/plugin-auth/authorized/__tests__/index.spec.tsx+++ b/web/app/components/plugins/plugin-auth/authorized/__tests__/index.spec.tsx@@ -52,7 +52,7 @@ vi.mock('../../hooks/use-credential', () => ({// Mock toast contextconst mockNotify = vi.fn()-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: () => ({notify: mockNotify,}),diff --git a/web/app/components/plugins/plugin-auth/authorized/index.tsx b/web/app/components/plugins/plugin-auth/authorized/index.tsxindex ea58cd16c9a..daee3131ad0 100644--- a/web/app/components/plugins/plugin-auth/authorized/index.tsx+++ b/web/app/components/plugins/plugin-auth/authorized/index.tsx@@ -19,7 +19,7 @@ import {PortalToFollowElemContent,PortalToFollowElemTrigger,} from '@/app/components/base/portal-to-follow-elem'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import Indicator from '@/app/components/header/indicator'import { cn } from '@/utils/classnames'import Authorize from '../authorize'diff --git a/web/app/components/plugins/plugin-auth/hooks/__tests__/use-plugin-auth-action.spec.ts b/web/app/components/plugins/plugin-auth/hooks/__tests__/use-plugin-auth-action.spec.tsindex d31b29ab854..f7796236971 100644--- a/web/app/components/plugins/plugin-auth/hooks/__tests__/use-plugin-auth-action.spec.ts+++ b/web/app/components/plugins/plugin-auth/hooks/__tests__/use-plugin-auth-action.spec.ts@@ -11,7 +11,7 @@ const mockSetPluginDefaultCredential = vi.fn().mockResolvedValue({})const mockUpdatePluginCredential = vi.fn().mockResolvedValue({})const mockNotify = vi.fn()-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: () => ({notify: mockNotify,}),diff --git a/web/app/components/plugins/plugin-auth/hooks/use-plugin-auth-action.ts b/web/app/components/plugins/plugin-auth/hooks/use-plugin-auth-action.tsindex e9218e2d3dd..5628c76cc33 100644--- a/web/app/components/plugins/plugin-auth/hooks/use-plugin-auth-action.ts+++ b/web/app/components/plugins/plugin-auth/hooks/use-plugin-auth-action.ts@@ -5,7 +5,7 @@ import {useState,} from 'react'import { useTranslation } from 'react-i18next'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import {useDeletePluginCredentialHook,useSetPluginDefaultCredentialHook,diff --git a/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/__tests__/apikey-edit-modal.spec.tsx b/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/__tests__/apikey-edit-modal.spec.tsxindex af145df2da3..e0fb7455cef 100644--- a/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/__tests__/apikey-edit-modal.spec.tsx+++ b/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/__tests__/apikey-edit-modal.spec.tsx@@ -54,13 +54,16 @@ vi.mock('@/app/components/base/toast', async (importOriginal) => {default: {notify: (args: { type: string, message: string }) => mockToast(args),},- useToastContext: () => ({- notify: (args: { type: string, message: string }) => mockToast(args),- close: vi.fn(),- }),}})+vi.mock('@/app/components/base/toast/context', () => ({+ useToastContext: () => ({+ notify: (args: { type: string, message: string }) => mockToast(args),+ close: vi.fn(),+ }),+}))+const createSubscription = (overrides: Partial<TriggerSubscription> = {}): TriggerSubscription => ({id: 'sub-1',name: 'Subscription One',diff --git a/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/__tests__/manual-edit-modal.spec.tsx b/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/__tests__/manual-edit-modal.spec.tsxindex c6144542ab6..60a84282878 100644--- a/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/__tests__/manual-edit-modal.spec.tsx+++ b/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/__tests__/manual-edit-modal.spec.tsx@@ -37,13 +37,16 @@ vi.mock('@/app/components/base/toast', async (importOriginal) => {default: {notify: (args: { type: string, message: string }) => mockToast(args),},- useToastContext: () => ({- notify: (args: { type: string, message: string }) => mockToast(args),- close: vi.fn(),- }),}})+vi.mock('@/app/components/base/toast/context', () => ({+ useToastContext: () => ({+ notify: (args: { type: string, message: string }) => mockToast(args),+ close: vi.fn(),+ }),+}))+const createSubscription = (overrides: Partial<TriggerSubscription> = {}): TriggerSubscription => ({id: 'sub-1',name: 'Subscription One',diff --git a/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/__tests__/oauth-edit-modal.spec.tsx b/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/__tests__/oauth-edit-modal.spec.tsxindex 7bdcdbc936b..8835b466952 100644--- a/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/__tests__/oauth-edit-modal.spec.tsx+++ b/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/__tests__/oauth-edit-modal.spec.tsx@@ -37,13 +37,16 @@ vi.mock('@/app/components/base/toast', async (importOriginal) => {default: {notify: (args: { type: string, message: string }) => mockToast(args),},- useToastContext: () => ({- notify: (args: { type: string, message: string }) => mockToast(args),- close: vi.fn(),- }),}})+vi.mock('@/app/components/base/toast/context', () => ({+ useToastContext: () => ({+ notify: (args: { type: string, message: string }) => mockToast(args),+ close: vi.fn(),+ }),+}))+const createSubscription = (overrides: Partial<TriggerSubscription> = {}): TriggerSubscription => ({id: 'sub-1',name: 'Subscription One',diff --git a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/__tests__/tool-credentials-form.spec.tsx b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/__tests__/tool-credentials-form.spec.tsxindex 20655d01392..cb5b929d291 100644--- a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/__tests__/tool-credentials-form.spec.tsx+++ b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/__tests__/tool-credentials-form.spec.tsx@@ -12,6 +12,9 @@ vi.mock('@/utils/classnames', () => ({vi.mock('@/app/components/base/toast', () => ({default: { notify: vi.fn() },+}))++vi.mock('@/app/components/base/toast/context', () => ({useToastContext: () => ({ notify: vi.fn() }),}))diff --git a/web/app/components/plugins/plugin-page/__tests__/context.spec.tsx b/web/app/components/plugins/plugin-page/__tests__/context.spec.tsxindex ab0e35e0426..389c161e8af 100644--- a/web/app/components/plugins/plugin-page/__tests__/context.spec.tsx+++ b/web/app/components/plugins/plugin-page/__tests__/context.spec.tsx@@ -3,7 +3,8 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'// Import mocksimport { useGlobalPublicStore } from '@/context/global-public-context'-import { PluginPageContext, PluginPageContextProvider, usePluginPageContext } from '../context'+import { PluginPageContext, usePluginPageContext } from '../context'+import { PluginPageContextProvider } from '../context-provider'// Mock dependenciesvi.mock('nuqs', () => ({diff --git a/web/app/components/plugins/plugin-page/context.tsx b/web/app/components/plugins/plugin-page/context-provider.tsxsimilarity index 58%rename from web/app/components/plugins/plugin-page/context.tsxrename to web/app/components/plugins/plugin-page/context-provider.tsxindex 01ec5183472..83776b48f90 100644--- a/web/app/components/plugins/plugin-page/context.tsx+++ b/web/app/components/plugins/plugin-page/context-provider.tsx@@ -1,24 +1,20 @@'use client'-import type { ReactNode, RefObject } from 'react'+import type { ReactNode } from 'react'+import type { PluginPageTab } from './context'import type { FilterState } from './filter-management'-import { noop } from 'es-toolkit/function'import { parseAsStringEnum, useQueryState } from 'nuqs'import {useMemo,useRef,useState,} from 'react'-import {- createContext,- useContextSelector,-} from 'use-context-selector'import { useGlobalPublicStore } from '@/context/global-public-context'import { PLUGIN_PAGE_TABS_MAP, usePluginPageTabs } from '../hooks'import { PLUGIN_TYPE_SEARCH_MAP } from '../marketplace/constants'--export type PluginPageTab = typeof PLUGIN_PAGE_TABS_MAP[keyof typeof PLUGIN_PAGE_TABS_MAP]- | (typeof PLUGIN_TYPE_SEARCH_MAP)[keyof typeof PLUGIN_TYPE_SEARCH_MAP]+import {+ PluginPageContext,+} from './context'const PLUGIN_PAGE_TAB_VALUES: PluginPageTab[] = [PLUGIN_PAGE_TABS_MAP.plugins,@@ -29,42 +25,10 @@ const PLUGIN_PAGE_TAB_VALUES: PluginPageTab[] = [const parseAsPluginPageTab = parseAsStringEnum<PluginPageTab>(PLUGIN_PAGE_TAB_VALUES).withDefault(PLUGIN_PAGE_TABS_MAP.plugins)-export type PluginPageContextValue = {- containerRef: RefObject<HTMLDivElement | null>- currentPluginID: string | undefined- setCurrentPluginID: (pluginID?: string) => void- filters: FilterState- setFilters: (filter: FilterState) => void- activeTab: PluginPageTab- setActiveTab: (tab: PluginPageTab) => void- options: Array<{ value: string, text: string }>-}--const emptyContainerRef: RefObject<HTMLDivElement | null> = { current: null }--export const PluginPageContext = createContext<PluginPageContextValue>({- containerRef: emptyContainerRef,- currentPluginID: undefined,- setCurrentPluginID: noop,- filters: {- categories: [],- tags: [],- searchQuery: '',- },- setFilters: noop,- activeTab: PLUGIN_PAGE_TABS_MAP.plugins,- setActiveTab: noop,- options: [],-})-type PluginPageContextProviderProps = {children: ReactNode}-export function usePluginPageContext(selector: (value: PluginPageContextValue) => any) {- return useContextSelector(PluginPageContext, selector)-}-export const PluginPageContextProvider = ({children,}: PluginPageContextProviderProps) => {diff --git a/web/app/components/plugins/plugin-page/context.ts b/web/app/components/plugins/plugin-page/context.tsnew file mode 100644index 00000000000..04ab1eef199--- /dev/null+++ b/web/app/components/plugins/plugin-page/context.ts@@ -0,0 +1,46 @@+'use client'++import type { RefObject } from 'react'+import type { PLUGIN_TYPE_SEARCH_MAP } from '../marketplace/constants'+import type { FilterState } from './filter-management'+import { noop } from 'es-toolkit/function'+import {+ createContext,+ useContextSelector,+} from 'use-context-selector'+import { PLUGIN_PAGE_TABS_MAP } from '../hooks'++export type PluginPageTab = typeof PLUGIN_PAGE_TABS_MAP[keyof typeof PLUGIN_PAGE_TABS_MAP]+ | (typeof PLUGIN_TYPE_SEARCH_MAP)[keyof typeof PLUGIN_TYPE_SEARCH_MAP]++export type PluginPageContextValue = {+ containerRef: RefObject<HTMLDivElement | null>+ currentPluginID: string | undefined+ setCurrentPluginID: (pluginID?: string) => void+ filters: FilterState+ setFilters: (filter: FilterState) => void+ activeTab: PluginPageTab+ setActiveTab: (tab: PluginPageTab) => void+ options: Array<{ value: string, text: string }>+}++const emptyContainerRef: RefObject<HTMLDivElement | null> = { current: null }++export const PluginPageContext = createContext<PluginPageContextValue>({+ containerRef: emptyContainerRef,+ currentPluginID: undefined,+ setCurrentPluginID: noop,+ filters: {+ categories: [],+ tags: [],+ searchQuery: '',+ },+ setFilters: noop,+ activeTab: PLUGIN_PAGE_TABS_MAP.plugins,+ setActiveTab: noop,+ options: [],+})++export function usePluginPageContext(selector: (value: PluginPageContextValue) => any) {+ return useContextSelector(PluginPageContext, selector)+}diff --git a/web/app/components/plugins/plugin-page/index.tsx b/web/app/components/plugins/plugin-page/index.tsxindex bec1eb60ab8..6768361acfe 100644--- a/web/app/components/plugins/plugin-page/index.tsx+++ b/web/app/components/plugins/plugin-page/index.tsx@@ -28,10 +28,8 @@ import { PLUGIN_PAGE_TABS_MAP } from '../hooks'import InstallFromLocalPackage from '../install-plugin/install-from-local-package'import InstallFromMarketplace from '../install-plugin/install-from-marketplace'import { PLUGIN_TYPE_SEARCH_MAP } from '../marketplace/constants'-import {- PluginPageContextProvider,- usePluginPageContext,-} from './context'+import { usePluginPageContext } from './context'+import { PluginPageContextProvider } from './context-provider'import DebugInfo from './debug-info'import InstallPluginDropdown from './install-plugin-dropdown'import PluginTasks from './plugin-tasks'diff --git a/web/app/components/rag-pipeline/components/__tests__/update-dsl-modal.spec.tsx b/web/app/components/rag-pipeline/components/__tests__/update-dsl-modal.spec.tsxindex 2f9b2172bd3..98ad5f78f44 100644--- a/web/app/components/rag-pipeline/components/__tests__/update-dsl-modal.spec.tsx+++ b/web/app/components/rag-pipeline/components/__tests__/update-dsl-modal.spec.tsx@@ -20,7 +20,7 @@ vi.mock('use-context-selector', () => ({useContext: () => ({ notify: mockNotify }),}))-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({ToastContext: { Provider: ({ children }: PropsWithChildren) => children },}))diff --git a/web/app/components/rag-pipeline/components/rag-pipeline-header/__tests__/index.spec.tsx b/web/app/components/rag-pipeline/components/rag-pipeline-header/__tests__/index.spec.tsxindex 0b858eaaa77..00c989acb0d 100644--- a/web/app/components/rag-pipeline/components/rag-pipeline-header/__tests__/index.spec.tsx+++ b/web/app/components/rag-pipeline/components/rag-pipeline-header/__tests__/index.spec.tsx@@ -155,7 +155,7 @@ vi.mock('@/app/components/base/amplitude', () => ({}))const mockNotify = vi.fn()-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: () => ({notify: mockNotify,}),diff --git a/web/app/components/rag-pipeline/components/rag-pipeline-header/publisher/__tests__/index.spec.tsx b/web/app/components/rag-pipeline/components/rag-pipeline-header/publisher/__tests__/index.spec.tsxindex 6129d3fe734..9cd1af27364 100644--- a/web/app/components/rag-pipeline/components/rag-pipeline-header/publisher/__tests__/index.spec.tsx+++ b/web/app/components/rag-pipeline/components/rag-pipeline-header/publisher/__tests__/index.spec.tsx@@ -3,7 +3,7 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'import { fireEvent, render, screen, waitFor } from '@testing-library/react'import * as React from 'react'import { beforeEach, describe, expect, it, vi } from 'vitest'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import Publisher from '../index'import Popup from '../popup'diff --git a/web/app/components/rag-pipeline/components/rag-pipeline-header/publisher/__tests__/popup.spec.tsx b/web/app/components/rag-pipeline/components/rag-pipeline-header/publisher/__tests__/popup.spec.tsxindex 71707721a47..48282820d8e 100644--- a/web/app/components/rag-pipeline/components/rag-pipeline-header/publisher/__tests__/popup.spec.tsx+++ b/web/app/components/rag-pipeline/components/rag-pipeline-header/publisher/__tests__/popup.spec.tsx@@ -57,7 +57,7 @@ vi.mock('@/app/components/workflow/store', () => ({}),}))-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: () => ({ notify: mockNotify }),}))diff --git a/web/app/components/rag-pipeline/components/rag-pipeline-header/publisher/popup.tsx b/web/app/components/rag-pipeline/components/rag-pipeline-header/publisher/popup.tsxindex 2dd56b4277b..371e4fd7213 100644--- a/web/app/components/rag-pipeline/components/rag-pipeline-header/publisher/popup.tsx+++ b/web/app/components/rag-pipeline/components/rag-pipeline-header/publisher/popup.tsx@@ -24,7 +24,7 @@ import Confirm from '@/app/components/base/confirm'import Divider from '@/app/components/base/divider'import { SparklesSoft } from '@/app/components/base/icons/src/public/common'import PremiumBadge from '@/app/components/base/premium-badge'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import {useChecklistBeforePublish,} from '@/app/components/workflow/hooks'diff --git a/web/app/components/rag-pipeline/hooks/__tests__/index.spec.ts b/web/app/components/rag-pipeline/hooks/__tests__/index.spec.tsindex 4c60e5133c0..95fe763d61f 100644--- a/web/app/components/rag-pipeline/hooks/__tests__/index.spec.ts+++ b/web/app/components/rag-pipeline/hooks/__tests__/index.spec.ts@@ -31,7 +31,7 @@ vi.mock('@/app/components/workflow/store', () => ({}))const mockNotify = vi.fn()-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: () => ({notify: mockNotify,}),diff --git a/web/app/components/rag-pipeline/hooks/__tests__/use-DSL.spec.ts b/web/app/components/rag-pipeline/hooks/__tests__/use-DSL.spec.tsindex c0b983052d7..c5603f2fc7a 100644--- a/web/app/components/rag-pipeline/hooks/__tests__/use-DSL.spec.ts+++ b/web/app/components/rag-pipeline/hooks/__tests__/use-DSL.spec.ts@@ -3,7 +3,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import { useDSL } from '../use-DSL'const mockNotify = vi.fn()-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: () => ({ notify: mockNotify }),}))diff --git a/web/app/components/rag-pipeline/hooks/__tests__/use-update-dsl-modal.spec.ts b/web/app/components/rag-pipeline/hooks/__tests__/use-update-dsl-modal.spec.tsindex 942e337ad88..a50965fb3bd 100644--- a/web/app/components/rag-pipeline/hooks/__tests__/use-update-dsl-modal.spec.ts+++ b/web/app/components/rag-pipeline/hooks/__tests__/use-update-dsl-modal.spec.ts@@ -23,7 +23,7 @@ vi.mock('use-context-selector', () => ({useContext: () => ({ notify: mockNotify }),}))-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({ToastContext: {},}))diff --git a/web/app/components/rag-pipeline/hooks/use-DSL.ts b/web/app/components/rag-pipeline/hooks/use-DSL.tsindex 5c0f9def1c4..f45cf35bdfc 100644--- a/web/app/components/rag-pipeline/hooks/use-DSL.ts+++ b/web/app/components/rag-pipeline/hooks/use-DSL.ts@@ -3,7 +3,7 @@ import {useState,} from 'react'import { useTranslation } from 'react-i18next'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import {DSL_EXPORT_CHECK,} from '@/app/components/workflow/constants'diff --git a/web/app/components/rag-pipeline/hooks/use-update-dsl-modal.ts b/web/app/components/rag-pipeline/hooks/use-update-dsl-modal.tsindex 3b869374171..48d2bc78b48 100644--- a/web/app/components/rag-pipeline/hooks/use-update-dsl-modal.ts+++ b/web/app/components/rag-pipeline/hooks/use-update-dsl-modal.ts@@ -6,7 +6,7 @@ import {} from 'react'import { useTranslation } from 'react-i18next'import { useContext } from 'use-context-selector'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { WORKFLOW_DATA_UPDATE } from '@/app/components/workflow/constants'import { usePluginDependencies } from '@/app/components/workflow/plugin-dependency/hooks'import { useWorkflowStore } from '@/app/components/workflow/store'diff --git a/web/app/components/workflow-app/components/workflow-header/__tests__/features-trigger.spec.tsx b/web/app/components/workflow-app/components/workflow-header/__tests__/features-trigger.spec.tsxindex 4a7fd1275f8..2318a1c7bc1 100644--- a/web/app/components/workflow-app/components/workflow-header/__tests__/features-trigger.spec.tsx+++ b/web/app/components/workflow-app/components/workflow-header/__tests__/features-trigger.spec.tsx@@ -4,7 +4,7 @@ import type { App } from '@/types/app'import { render, screen, waitFor } from '@testing-library/react'import userEvent from '@testing-library/user-event'import { useStore as useAppStore } from '@/app/components/app/store'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { Plan } from '@/app/components/billing/type'import { BlockEnum, InputVarType } from '@/app/components/workflow/types'import FeaturesTrigger from '../features-trigger'diff --git a/web/app/components/workflow-app/components/workflow-header/features-trigger.tsx b/web/app/components/workflow-app/components/workflow-header/features-trigger.tsxindex d58eb6c669f..84603e9a13b 100644--- a/web/app/components/workflow-app/components/workflow-header/features-trigger.tsx+++ b/web/app/components/workflow-app/components/workflow-header/features-trigger.tsx@@ -17,7 +17,7 @@ import AppPublisher from '@/app/components/app/app-publisher'import { useStore as useAppStore } from '@/app/components/app/store'import Button from '@/app/components/base/button'import { useFeatures } from '@/app/components/base/features/hooks'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import { Plan } from '@/app/components/billing/type'import {useChecklist,diff --git a/web/app/components/workflow-app/hooks/use-DSL.ts b/web/app/components/workflow-app/hooks/use-DSL.tsindex 939e43b5546..918a60f185b 100644--- a/web/app/components/workflow-app/hooks/use-DSL.ts+++ b/web/app/components/workflow-app/hooks/use-DSL.ts@@ -4,7 +4,7 @@ import {} from 'react'import { useTranslation } from 'react-i18next'import { useStore as useAppStore } from '@/app/components/app/store'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import {DSL_EXPORT_CHECK,} from '@/app/components/workflow/constants'diff --git a/web/app/components/workflow/header/run-mode.tsx b/web/app/components/workflow/header/run-mode.tsxindex 63c48ff0dca..943af13a927 100644--- a/web/app/components/workflow/header/run-mode.tsx+++ b/web/app/components/workflow/header/run-mode.tsx@@ -5,7 +5,7 @@ import { useCallback, useEffect, useRef } from 'react'import { useTranslation } from 'react-i18next'import { trackEvent } from '@/app/components/base/amplitude'import { StopCircle } from '@/app/components/base/icons/src/vender/line/mediaAndDevices'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import { useWorkflowRun, useWorkflowRunValidation, useWorkflowStartRun } from '@/app/components/workflow/hooks'import ShortcutsName from '@/app/components/workflow/shortcuts-name'import { useStore } from '@/app/components/workflow/store'diff --git a/web/app/components/workflow/hooks/__tests__/use-checklist.spec.ts b/web/app/components/workflow/hooks/__tests__/use-checklist.spec.tsindex d72d001e0be..1b370551345 100644--- a/web/app/components/workflow/hooks/__tests__/use-checklist.spec.ts+++ b/web/app/components/workflow/hooks/__tests__/use-checklist.spec.ts@@ -82,7 +82,7 @@ vi.mock('../index', () => ({useNodesMetaData: () => ({ nodes: [], nodesMap: mockNodesMap }),}))-vi.mock('@/app/components/base/toast', () => ({+vi.mock('@/app/components/base/toast/context', () => ({useToastContext: () => ({ notify: vi.fn() }),}))diff --git a/web/app/components/workflow/hooks/use-checklist.ts b/web/app/components/workflow/hooks/use-checklist.tsindex 642179aed7f..dd1d012aed3 100644--- a/web/app/components/workflow/hooks/use-checklist.ts+++ b/web/app/components/workflow/hooks/use-checklist.ts@@ -22,7 +22,7 @@ import {import { useTranslation } from 'react-i18next'import { useEdges, useStoreApi } from 'reactflow'import { useStore as useAppStore } from '@/app/components/app/store'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import { ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'import { useModelList } from '@/app/components/header/account-setting/model-provider-page/hooks'import useNodes from '@/app/components/workflow/store/workflow/use-nodes'diff --git a/web/app/components/workflow/note-node/note-editor/plugins/link-editor-plugin/hooks.ts b/web/app/components/workflow/note-node/note-editor/plugins/link-editor-plugin/hooks.tsindex 3a084ef0afc..511940d1428 100644--- a/web/app/components/workflow/note-node/note-editor/plugins/link-editor-plugin/hooks.ts+++ b/web/app/components/workflow/note-node/note-editor/plugins/link-editor-plugin/hooks.ts@@ -15,7 +15,7 @@ import {useEffect,} from 'react'import { useTranslation } from 'react-i18next'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import { useNoteEditorStore } from '../../store'import { urlRegExp } from '../../utils'diff --git a/web/app/components/workflow/panel/chat-variable-panel/components/object-value-item.tsx b/web/app/components/workflow/panel/chat-variable-panel/components/object-value-item.tsxindex ef4b4d71a9a..74765c2b9e8 100644--- a/web/app/components/workflow/panel/chat-variable-panel/components/object-value-item.tsx+++ b/web/app/components/workflow/panel/chat-variable-panel/components/object-value-item.tsx@@ -5,7 +5,7 @@ import * as React from 'react'import { useCallback, useState } from 'react'import { useTranslation } from 'react-i18next'import { useContext } from 'use-context-selector'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import RemoveButton from '@/app/components/workflow/nodes/_base/components/remove-button'import VariableTypeSelector from '@/app/components/workflow/panel/chat-variable-panel/components/variable-type-select'import { ChatVarType } from '@/app/components/workflow/panel/chat-variable-panel/type'diff --git a/web/app/components/workflow/panel/chat-variable-panel/components/variable-modal.tsx b/web/app/components/workflow/panel/chat-variable-panel/components/variable-modal.tsxindex 5c07cca3df5..dd14bcf75a5 100644--- a/web/app/components/workflow/panel/chat-variable-panel/components/variable-modal.tsx+++ b/web/app/components/workflow/panel/chat-variable-panel/components/variable-modal.tsx@@ -7,7 +7,7 @@ import { useContext } from 'use-context-selector'import { v4 as uuid4 } from 'uuid'import Button from '@/app/components/base/button'import Input from '@/app/components/base/input'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/code-editor'import { CodeLanguage } from '@/app/components/workflow/nodes/code/types'import ArrayValueList from '@/app/components/workflow/panel/chat-variable-panel/components/array-value-list'diff --git a/web/app/components/workflow/panel/debug-and-preview/hooks.ts b/web/app/components/workflow/panel/debug-and-preview/hooks.tsindex b31673ee260..3481733cd2d 100644--- a/web/app/components/workflow/panel/debug-and-preview/hooks.ts+++ b/web/app/components/workflow/panel/debug-and-preview/hooks.ts@@ -26,7 +26,7 @@ import {getProcessedFiles,getProcessedFilesFromResponse,} from '@/app/components/base/file-uploader/utils'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import {CUSTOM_NODE,} from '@/app/components/workflow/constants'diff --git a/web/app/components/workflow/panel/env-panel/variable-modal.tsx b/web/app/components/workflow/panel/env-panel/variable-modal.tsxindex 0e120ac77c8..493a73405ab 100644--- a/web/app/components/workflow/panel/env-panel/variable-modal.tsx+++ b/web/app/components/workflow/panel/env-panel/variable-modal.tsx@@ -7,7 +7,7 @@ import { useContext } from 'use-context-selector'import { v4 as uuid4 } from 'uuid'import Button from '@/app/components/base/button'import Input from '@/app/components/base/input'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import Tooltip from '@/app/components/base/tooltip'import { useWorkflowStore } from '@/app/components/workflow/store'import { cn } from '@/utils/classnames'diff --git a/web/app/components/workflow/run/index.tsx b/web/app/components/workflow/run/index.tsxindex 441002c86c4..96acb1a0269 100644--- a/web/app/components/workflow/run/index.tsx+++ b/web/app/components/workflow/run/index.tsx@@ -6,7 +6,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react'import { useTranslation } from 'react-i18next'import { useContext } from 'use-context-selector'import Loading from '@/app/components/base/loading'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { WorkflowRunningStatus } from '@/app/components/workflow/types'import { fetchRunDetail, fetchTracingList } from '@/service/log'import { cn } from '@/utils/classnames'diff --git a/web/app/components/workflow/update-dsl-modal.tsx b/web/app/components/workflow/update-dsl-modal.tsxindex d33679ff1b3..08107a0c241 100644--- a/web/app/components/workflow/update-dsl-modal.tsx+++ b/web/app/components/workflow/update-dsl-modal.tsx@@ -24,7 +24,7 @@ import { useStore as useAppStore } from '@/app/components/app/store'import Button from '@/app/components/base/button'import Modal from '@/app/components/base/modal'import { FILE_EXTS } from '@/app/components/base/prompt-editor/constants'-import { ToastContext } from '@/app/components/base/toast'+import { ToastContext } from '@/app/components/base/toast/context'import { usePluginDependencies } from '@/app/components/workflow/plugin-dependency/hooks'import { useEventEmitterContextContext } from '@/context/event-emitter'import {diff --git a/web/app/education-apply/education-apply-page.tsx b/web/app/education-apply/education-apply-page.tsxindex 3f8d80a67eb..636a471d3de 100644--- a/web/app/education-apply/education-apply-page.tsx+++ b/web/app/education-apply/education-apply-page.tsx@@ -12,7 +12,7 @@ import {import { useTranslation } from 'react-i18next'import Button from '@/app/components/base/button'import Checkbox from '@/app/components/base/checkbox'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import { EDUCATION_VERIFYING_LOCALSTORAGE_ITEM } from '@/app/education-apply/constants'import { useDocLink } from '@/context/i18n'import { useProviderContext } from '@/context/provider-context'diff --git a/web/context/datasets-context.tsx b/web/context/datasets-context.tssimilarity index 100%rename from web/context/datasets-context.tsxrename to web/context/datasets-context.tsdiff --git a/web/context/event-emitter-provider.tsx b/web/context/event-emitter-provider.tsxnew file mode 100644index 00000000000..da8d2d78c2b--- /dev/null+++ b/web/context/event-emitter-provider.tsx@@ -0,0 +1,22 @@+'use client'++import type { ReactNode } from 'react'+import type { EventEmitterValue } from './event-emitter'+import { useEventEmitter } from 'ahooks'+import { EventEmitterContext } from './event-emitter'++type EventEmitterContextProviderProps = {+ children: ReactNode+}++export const EventEmitterContextProvider = ({+ children,+}: EventEmitterContextProviderProps) => {+ const eventEmitter = useEventEmitter<EventEmitterValue>()++ return (+ <EventEmitterContext.Provider value={{ eventEmitter }}>+ {children}+ </EventEmitterContext.Provider>+ )+}diff --git a/web/context/event-emitter.tsx b/web/context/event-emitter.tssimilarity index 53%rename from web/context/event-emitter.tsxrename to web/context/event-emitter.tsindex 14b81eacb6c..eb7794dfe12 100644--- a/web/context/event-emitter.tsx+++ b/web/context/event-emitter.ts@@ -1,7 +1,6 @@'use client'import type { EventEmitter } from 'ahooks/lib/useEventEmitter'-import { useEventEmitter } from 'ahooks'import { createContext, useContext } from 'use-context-selector'/**@@ -16,25 +15,10 @@ export type EventEmitterMessage = {export type EventEmitterValue = string | EventEmitterMessage-const EventEmitterContext = createContext<{ eventEmitter: EventEmitter<EventEmitterValue> | null }>({+export const EventEmitterContext = createContext<{ eventEmitter: EventEmitter<EventEmitterValue> | null }>({eventEmitter: null,})export const useEventEmitterContextContext = () => useContext(EventEmitterContext)-type EventEmitterContextProviderProps = {- children: React.ReactNode-}-export const EventEmitterContextProvider = ({- children,-}: EventEmitterContextProviderProps) => {- const eventEmitter = useEventEmitter<EventEmitterValue>()-- return (- <EventEmitterContext.Provider value={{ eventEmitter }}>- {children}- </EventEmitterContext.Provider>- )-}-export default EventEmitterContextdiff --git a/web/context/mitt-context-provider.tsx b/web/context/mitt-context-provider.tsxnew file mode 100644index 00000000000..b177694d8d6--- /dev/null+++ b/web/context/mitt-context-provider.tsx@@ -0,0 +1,19 @@+'use client'++import type { ReactNode } from 'react'+import { useMitt } from '@/hooks/use-mitt'+import { MittContext } from './mitt-context'++type MittProviderProps = {+ children: ReactNode+}++export const MittProvider = ({ children }: MittProviderProps) => {+ const mitt = useMitt()++ return (+ <MittContext.Provider value={mitt}>+ {children}+ </MittContext.Provider>+ )+}diff --git a/web/context/mitt-context.tsx b/web/context/mitt-context.tssimilarity index 66%rename from web/context/mitt-context.tsxrename to web/context/mitt-context.tsindex 4317fc56603..5c4a0771c53 100644--- a/web/context/mitt-context.tsx+++ b/web/context/mitt-context.ts@@ -1,6 +1,8 @@+'use client'++import type { useMitt } from '@/hooks/use-mitt'import { noop } from 'es-toolkit/function'import { createContext, useContext, useContextSelector } from 'use-context-selector'-import { useMitt } from '@/hooks/use-mitt'type ContextValueType = ReturnType<typeof useMitt>export const MittContext = createContext<ContextValueType>({@@ -8,16 +10,6 @@ export const MittContext = createContext<ContextValueType>({useSubscribe: noop,})-export const MittProvider = ({ children }: { children: React.ReactNode }) => {- const mitt = useMitt()-- return (- <MittContext.Provider value={mitt}>- {children}- </MittContext.Provider>- )-}-export const useMittContext = () => {return useContext(MittContext)}diff --git a/web/context/modal-context.tsx b/web/context/modal-context-provider.tsxsimilarity index 81%rename from web/context/modal-context.tsxrename to web/context/modal-context-provider.tsxindex ae1184e5bf6..8c64642f433 100644--- a/web/context/modal-context.tsx+++ b/web/context/modal-context-provider.tsx@@ -1,32 +1,20 @@'use client'-import type { Dispatch, SetStateAction } from 'react'-import type { TriggerEventsLimitModalPayload } from './hooks/use-trigger-events-limit-modal'+import type { ReactNode, SetStateAction } from 'react'+import type { ModalState, ModelModalType } from './modal-context'import type { OpeningStatement } from '@/app/components/base/features/types'import type { CreateExternalAPIReq } from '@/app/components/datasets/external-api/declarations'import type { AccountSettingTab } from '@/app/components/header/account-setting/constants'-import type {- ConfigurationMethodEnum,- Credential,- CustomConfigurationModelFixedFields,- CustomModel,- ModelModalModeEnum,- ModelProvider,-} from '@/app/components/header/account-setting/model-provider-page/declarations'import type { ModelLoadBalancingModalProps } from '@/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-modal'import type { UpdatePluginPayload } from '@/app/components/plugins/types'import type { InputVar } from '@/app/components/workflow/types'import type { ExpireNoticeModalPayloadProps } from '@/app/education-apply/expire-notice-modal'-import type {- ApiBasedExtension,- ExternalDataTool,-} from '@/models/common'+import type { ApiBasedExtension, ExternalDataTool } from '@/models/common'import type { ModerationConfig, PromptVariable } from '@/models/debug'-import { noop } from 'es-toolkit/function'import dynamic from 'next/dynamic'import { useCallback, useEffect, useRef, useState } from 'react'-import { createContext, useContext, useContextSelector } from 'use-context-selector'import {+DEFAULT_ACCOUNT_SETTING_TAB,isValidAccountSettingTab,} from '@/app/components/header/account-setting/constants'@@ -39,11 +27,10 @@ import {useAccountSettingModal,usePricingModal,} from '@/hooks/use-query-params'-+import { useTriggerEventsLimitModal } from './hooks/use-trigger-events-limit-modal'import {-- useTriggerEventsLimitModal,-} from './hooks/use-trigger-events-limit-modal'+ ModalContext,+} from './modal-context'const AccountSetting = dynamic(() => import('@/app/components/header/account-setting'), {ssr: false,@@ -86,72 +73,8 @@ const TriggerEventsLimitModal = dynamic(() => import('@/app/components/billing/tssr: false,})-export type ModalState<T> = {- payload: T- onCancelCallback?: () => void- onSaveCallback?: (newPayload?: T, formValues?: Record<string, any>) => void- onRemoveCallback?: (newPayload?: T, formValues?: Record<string, any>) => void- onEditCallback?: (newPayload: T) => void- onValidateBeforeSaveCallback?: (newPayload: T) => boolean- isEditMode?: boolean- datasetBindings?: { id: string, name: string }[]-}--export type ModelModalType = {- currentProvider: ModelProvider- currentConfigurationMethod: ConfigurationMethodEnum- currentCustomConfigurationModelFixedFields?: CustomConfigurationModelFixedFields- isModelCredential?: boolean- credential?: Credential- model?: CustomModel- mode?: ModelModalModeEnum-}--export type ModalContextState = {- setShowAccountSettingModal: Dispatch<SetStateAction<ModalState<AccountSettingTab> | null>>- setShowApiBasedExtensionModal: Dispatch<SetStateAction<ModalState<ApiBasedExtension> | null>>- setShowModerationSettingModal: Dispatch<SetStateAction<ModalState<ModerationConfig> | null>>- setShowExternalDataToolModal: Dispatch<SetStateAction<ModalState<ExternalDataTool> | null>>- setShowPricingModal: () => void- setShowAnnotationFullModal: () => void- setShowModelModal: Dispatch<SetStateAction<ModalState<ModelModalType> | null>>- setShowExternalKnowledgeAPIModal: Dispatch<SetStateAction<ModalState<CreateExternalAPIReq> | null>>- setShowModelLoadBalancingModal: Dispatch<SetStateAction<ModelLoadBalancingModalProps | null>>- setShowOpeningModal: Dispatch<SetStateAction<ModalState<OpeningStatement & {- promptVariables?: PromptVariable[]- workflowVariables?: InputVar[]- onAutoAddPromptVariable?: (variable: PromptVariable[]) => void- }> | null>>- setShowUpdatePluginModal: Dispatch<SetStateAction<ModalState<UpdatePluginPayload> | null>>- setShowEducationExpireNoticeModal: Dispatch<SetStateAction<ModalState<ExpireNoticeModalPayloadProps> | null>>- setShowTriggerEventsLimitModal: Dispatch<SetStateAction<ModalState<TriggerEventsLimitModalPayload> | null>>-}--const ModalContext = createContext<ModalContextState>({- setShowAccountSettingModal: noop,- setShowApiBasedExtensionModal: noop,- setShowModerationSettingModal: noop,- setShowExternalDataToolModal: noop,- setShowPricingModal: noop,- setShowAnnotationFullModal: noop,- setShowModelModal: noop,- setShowExternalKnowledgeAPIModal: noop,- setShowModelLoadBalancingModal: noop,- setShowOpeningModal: noop,- setShowUpdatePluginModal: noop,- setShowEducationExpireNoticeModal: noop,- setShowTriggerEventsLimitModal: noop,-})--export const useModalContext = () => useContext(ModalContext)--// Adding a dangling comma to avoid the generic parsing issue in tsx, see:-// https://github.com/microsoft/TypeScript/issues/15713-export const useModalContextSelector = <T,>(selector: (state: ModalContextState) => T): T =>- useContextSelector(ModalContext, selector)-type ModalContextProviderProps = {- children: React.ReactNode+ children: ReactNode}export const ModalContextProvider = ({children,diff --git a/web/context/modal-context.test.tsx b/web/context/modal-context.test.tsxindex a0f6ff35ecf..98f67a5473b 100644--- a/web/context/modal-context.test.tsx+++ b/web/context/modal-context.test.tsx@@ -2,7 +2,7 @@ import { act, screen, waitFor } from '@testing-library/react'import * as React from 'react'import { defaultPlan } from '@/app/components/billing/config'import { Plan } from '@/app/components/billing/type'-import { ModalContextProvider } from '@/context/modal-context'+import { ModalContextProvider } from '@/context/modal-context-provider'import { renderWithNuqs } from '@/test/nuqs-testing'vi.mock('@/config', async (importOriginal) => {diff --git a/web/context/modal-context.ts b/web/context/modal-context.tsnew file mode 100644index 00000000000..cc0ca28a42f--- /dev/null+++ b/web/context/modal-context.ts@@ -0,0 +1,92 @@+'use client'++import type { Dispatch, SetStateAction } from 'react'+import type { TriggerEventsLimitModalPayload } from './hooks/use-trigger-events-limit-modal'+import type { OpeningStatement } from '@/app/components/base/features/types'+import type { CreateExternalAPIReq } from '@/app/components/datasets/external-api/declarations'+import type { AccountSettingTab } from '@/app/components/header/account-setting/constants'+import type {+ ConfigurationMethodEnum,+ Credential,+ CustomConfigurationModelFixedFields,+ CustomModel,+ ModelModalModeEnum,+ ModelProvider,+} from '@/app/components/header/account-setting/model-provider-page/declarations'+import type { ModelLoadBalancingModalProps } from '@/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-modal'+import type { UpdatePluginPayload } from '@/app/components/plugins/types'+import type { InputVar } from '@/app/components/workflow/types'+import type { ExpireNoticeModalPayloadProps } from '@/app/education-apply/expire-notice-modal'+import type {+ ApiBasedExtension,+ ExternalDataTool,+} from '@/models/common'+import type { ModerationConfig, PromptVariable } from '@/models/debug'+import { noop } from 'es-toolkit/function'+import { createContext, useContext, useContextSelector } from 'use-context-selector'++export type ModalState<T> = {+ payload: T+ onCancelCallback?: () => void+ onSaveCallback?: (newPayload?: T, formValues?: Record<string, any>) => void+ onRemoveCallback?: (newPayload?: T, formValues?: Record<string, any>) => void+ onEditCallback?: (newPayload: T) => void+ onValidateBeforeSaveCallback?: (newPayload: T) => boolean+ isEditMode?: boolean+ datasetBindings?: { id: string, name: string }[]+}++export type ModelModalType = {+ currentProvider: ModelProvider+ currentConfigurationMethod: ConfigurationMethodEnum+ currentCustomConfigurationModelFixedFields?: CustomConfigurationModelFixedFields+ isModelCredential?: boolean+ credential?: Credential+ model?: CustomModel+ mode?: ModelModalModeEnum+}++export type ModalContextState = {+ setShowAccountSettingModal: Dispatch<SetStateAction<ModalState<AccountSettingTab> | null>>+ setShowApiBasedExtensionModal: Dispatch<SetStateAction<ModalState<ApiBasedExtension> | null>>+ setShowModerationSettingModal: Dispatch<SetStateAction<ModalState<ModerationConfig> | null>>+ setShowExternalDataToolModal: Dispatch<SetStateAction<ModalState<ExternalDataTool> | null>>+ setShowPricingModal: () => void+ setShowAnnotationFullModal: () => void+ setShowModelModal: Dispatch<SetStateAction<ModalState<ModelModalType> | null>>+ setShowExternalKnowledgeAPIModal: Dispatch<SetStateAction<ModalState<CreateExternalAPIReq> | null>>+ setShowModelLoadBalancingModal: Dispatch<SetStateAction<ModelLoadBalancingModalProps | null>>+ setShowOpeningModal: Dispatch<SetStateAction<ModalState<OpeningStatement & {+ promptVariables?: PromptVariable[]+ workflowVariables?: InputVar[]+ onAutoAddPromptVariable?: (variable: PromptVariable[]) => void+ }> | null>>+ setShowUpdatePluginModal: Dispatch<SetStateAction<ModalState<UpdatePluginPayload> | null>>+ setShowEducationExpireNoticeModal: Dispatch<SetStateAction<ModalState<ExpireNoticeModalPayloadProps> | null>>+ setShowTriggerEventsLimitModal: Dispatch<SetStateAction<ModalState<TriggerEventsLimitModalPayload> | null>>+}++export const ModalContext = createContext<ModalContextState>({+ setShowAccountSettingModal: noop,+ setShowApiBasedExtensionModal: noop,+ setShowModerationSettingModal: noop,+ setShowExternalDataToolModal: noop,+ setShowPricingModal: noop,+ setShowAnnotationFullModal: noop,+ setShowModelModal: noop,+ setShowExternalKnowledgeAPIModal: noop,+ setShowModelLoadBalancingModal: noop,+ setShowOpeningModal: noop,+ setShowUpdatePluginModal: noop,+ setShowEducationExpireNoticeModal: noop,+ setShowTriggerEventsLimitModal: noop,+})++export const useModalContext = () => useContext(ModalContext)++// Adding a dangling comma to avoid the generic parsing issue in tsx, see:+// https://github.com/microsoft/TypeScript/issues/15713+export const useModalContextSelector = <T>(selector: (state: ModalContextState) => T): T =>+ useContextSelector(ModalContext, selector)++export default ModalContextdiff --git a/web/context/provider-context.tsx b/web/context/provider-context-provider.tsxsimilarity index 70%rename from web/context/provider-context.tsxrename to web/context/provider-context-provider.tsxindex 2a71d9cf939..ce7f2ba40c2 100644--- a/web/context/provider-context.tsx+++ b/web/context/provider-context-provider.tsx@@ -1,14 +1,10 @@'use client'-import type { Plan, UsagePlanInfo, UsageResetInfo } from '@/app/components/billing/type'-import type { Model, ModelProvider } from '@/app/components/header/account-setting/model-provider-page/declarations'-import type { RETRIEVE_METHOD } from '@/types/app'+import type { ReactNode } from 'react'import { useQueryClient } from '@tanstack/react-query'import dayjs from 'dayjs'-import { noop } from 'es-toolkit/function'import { useEffect, useState } from 'react'import { useTranslation } from 'react-i18next'-import { createContext, useContext, useContextSelector } from 'use-context-selector'import Toast from '@/app/components/base/toast'import { setZendeskConversationFields } from '@/app/components/base/zendesk/utils'import { defaultPlan } from '@/app/components/billing/config'@@ -25,93 +21,13 @@ import {useModelProviders,useSupportRetrievalMethods,} from '@/service/use-common'-import {- useEducationStatus,-} from '@/service/use-education'--export type ProviderContextState = {- modelProviders: ModelProvider[]- refreshModelProviders: () => void- textGenerationModelList: Model[]- supportRetrievalMethods: RETRIEVE_METHOD[]- isAPIKeySet: boolean- plan: {- type: Plan- usage: UsagePlanInfo- total: UsagePlanInfo- reset: UsageResetInfo- }- isFetchedPlan: boolean- enableBilling: boolean- onPlanInfoChanged: () => void- enableReplaceWebAppLogo: boolean- modelLoadBalancingEnabled: boolean- datasetOperatorEnabled: boolean- enableEducationPlan: boolean- isEducationWorkspace: boolean- isEducationAccount: boolean- allowRefreshEducationVerify: boolean- educationAccountExpireAt: number | null- isLoadingEducationAccountInfo: boolean- isFetchingEducationAccountInfo: boolean- webappCopyrightEnabled: boolean- licenseLimit: {- workspace_members: {- size: number- limit: number- }- }- refreshLicenseLimit: () => void- isAllowTransferWorkspace: boolean- isAllowPublishAsCustomKnowledgePipelineTemplate: boolean- humanInputEmailDeliveryEnabled: boolean-}--export const baseProviderContextValue: ProviderContextState = {- modelProviders: [],- refreshModelProviders: noop,- textGenerationModelList: [],- supportRetrievalMethods: [],- isAPIKeySet: true,- plan: defaultPlan,- isFetchedPlan: false,- enableBilling: false,- onPlanInfoChanged: noop,- enableReplaceWebAppLogo: false,- modelLoadBalancingEnabled: false,- datasetOperatorEnabled: false,- enableEducationPlan: false,- isEducationWorkspace: false,- isEducationAccount: false,- allowRefreshEducationVerify: false,- educationAccountExpireAt: null,- isLoadingEducationAccountInfo: false,- isFetchingEducationAccountInfo: false,- webappCopyrightEnabled: false,- licenseLimit: {- workspace_members: {- size: 0,- limit: 0,- },- },- refreshLicenseLimit: noop,- isAllowTransferWorkspace: false,- isAllowPublishAsCustomKnowledgePipelineTemplate: false,- humanInputEmailDeliveryEnabled: false,-}--const ProviderContext = createContext<ProviderContextState>(baseProviderContextValue)--export const useProviderContext = () => useContext(ProviderContext)--// Adding a dangling comma to avoid the generic parsing issue in tsx, see:-// https://github.com/microsoft/TypeScript/issues/15713-export const useProviderContextSelector = <T,>(selector: (state: ProviderContextState) => T): T =>- useContextSelector(ProviderContext, selector)+import { useEducationStatus } from '@/service/use-education'+import { ProviderContext } from './provider-context'type ProviderContextProviderProps = {- children: React.ReactNode+ children: ReactNode}+export const ProviderContextProvider = ({children,}: ProviderContextProviderProps) => {@@ -262,5 +178,3 @@ export const ProviderContextProvider = ({</ProviderContext.Provider>)}--export default ProviderContextdiff --git a/web/context/provider-context.ts b/web/context/provider-context.tsnew file mode 100644index 00000000000..27c43e7c91f--- /dev/null+++ b/web/context/provider-context.ts@@ -0,0 +1,90 @@+'use client'++import type { Plan, UsagePlanInfo, UsageResetInfo } from '@/app/components/billing/type'+import type { Model, ModelProvider } from '@/app/components/header/account-setting/model-provider-page/declarations'+import type { RETRIEVE_METHOD } from '@/types/app'+import { noop } from 'es-toolkit/function'+import { createContext, useContext, useContextSelector } from 'use-context-selector'+import { defaultPlan } from '@/app/components/billing/config'++export type ProviderContextState = {+ modelProviders: ModelProvider[]+ refreshModelProviders: () => void+ textGenerationModelList: Model[]+ supportRetrievalMethods: RETRIEVE_METHOD[]+ isAPIKeySet: boolean+ plan: {+ type: Plan+ usage: UsagePlanInfo+ total: UsagePlanInfo+ reset: UsageResetInfo+ }+ isFetchedPlan: boolean+ enableBilling: boolean+ onPlanInfoChanged: () => void+ enableReplaceWebAppLogo: boolean+ modelLoadBalancingEnabled: boolean+ datasetOperatorEnabled: boolean+ enableEducationPlan: boolean+ isEducationWorkspace: boolean+ isEducationAccount: boolean+ allowRefreshEducationVerify: boolean+ educationAccountExpireAt: number | null+ isLoadingEducationAccountInfo: boolean+ isFetchingEducationAccountInfo: boolean+ webappCopyrightEnabled: boolean+ licenseLimit: {+ workspace_members: {+ size: number+ limit: number+ }+ }+ refreshLicenseLimit: () => void+ isAllowTransferWorkspace: boolean+ isAllowPublishAsCustomKnowledgePipelineTemplate: boolean+ humanInputEmailDeliveryEnabled: boolean+}++export const baseProviderContextValue: ProviderContextState = {+ modelProviders: [],+ refreshModelProviders: noop,+ textGenerationModelList: [],+ supportRetrievalMethods: [],+ isAPIKeySet: true,+ plan: defaultPlan,+ isFetchedPlan: false,+ enableBilling: false,+ onPlanInfoChanged: noop,+ enableReplaceWebAppLogo: false,+ modelLoadBalancingEnabled: false,+ datasetOperatorEnabled: false,+ enableEducationPlan: false,+ isEducationWorkspace: false,+ isEducationAccount: false,+ allowRefreshEducationVerify: false,+ educationAccountExpireAt: null,+ isLoadingEducationAccountInfo: false,+ isFetchingEducationAccountInfo: false,+ webappCopyrightEnabled: false,+ licenseLimit: {+ workspace_members: {+ size: 0,+ limit: 0,+ },+ },+ refreshLicenseLimit: noop,+ isAllowTransferWorkspace: false,+ isAllowPublishAsCustomKnowledgePipelineTemplate: false,+ humanInputEmailDeliveryEnabled: false,+}++export const ProviderContext = createContext<ProviderContextState>(baseProviderContextValue)++export const useProviderContext = () => useContext(ProviderContext)++// Adding a dangling comma to avoid the generic parsing issue in tsx, see:+// https://github.com/microsoft/TypeScript/issues/15713+export const useProviderContextSelector = <T>(selector: (state: ProviderContextState) => T): T =>+ useContextSelector(ProviderContext, selector)++export default ProviderContextdiff --git a/web/context/workspace-context-provider.tsx b/web/context/workspace-context-provider.tsxnew file mode 100644index 00000000000..afec62f7103--- /dev/null+++ b/web/context/workspace-context-provider.tsx@@ -0,0 +1,24 @@+'use client'++import type { ReactNode } from 'react'+import { useWorkspaces } from '@/service/use-common'+import { WorkspacesContext } from './workspace-context'++type WorkspaceProviderProps = {+ children: ReactNode+}++export const WorkspaceProvider = ({+ children,+}: WorkspaceProviderProps) => {+ const { data } = useWorkspaces()++ return (+ <WorkspacesContext.Provider value={{+ workspaces: data?.workspaces || [],+ }}+ >+ {children}+ </WorkspacesContext.Provider>+ )+}diff --git a/web/context/workspace-context.ts b/web/context/workspace-context.tsnew file mode 100644index 00000000000..e088d12f4e1--- /dev/null+++ b/web/context/workspace-context.ts@@ -0,0 +1,16 @@+'use client'++import type { IWorkspace } from '@/models/common'+import { createContext, useContext } from 'use-context-selector'++export type WorkspacesContextValue = {+ workspaces: IWorkspace[]+}++export const WorkspacesContext = createContext<WorkspacesContextValue>({+ workspaces: [],+})++export const useWorkspacesContext = () => useContext(WorkspacesContext)++export default WorkspacesContextdiff --git a/web/context/workspace-context.tsx b/web/context/workspace-context.tsxdeleted file mode 100644index 3834641bc15..00000000000--- a/web/context/workspace-context.tsx+++ /dev/null@@ -1,36 +0,0 @@-'use client'--import type { IWorkspace } from '@/models/common'-import { createContext, useContext } from 'use-context-selector'-import { useWorkspaces } from '@/service/use-common'--export type WorkspacesContextValue = {- workspaces: IWorkspace[]-}--const WorkspacesContext = createContext<WorkspacesContextValue>({- workspaces: [],-})--type IWorkspaceProviderProps = {- children: React.ReactNode-}--export const WorkspaceProvider = ({- children,-}: IWorkspaceProviderProps) => {- const { data } = useWorkspaces()-- return (- <WorkspacesContext.Provider value={{- workspaces: data?.workspaces || [],- }}- >- {children}- </WorkspacesContext.Provider>- )-}--export const useWorkspacesContext = () => useContext(WorkspacesContext)--export default WorkspacesContextdiff --git a/web/eslint-suppressions.json b/web/eslint-suppressions.jsonindex 08800843202..22f225d1d0e 100644--- a/web/eslint-suppressions.json+++ b/web/eslint-suppressions.json@@ -968,11 +968,6 @@"count": 6}},- "app/components/app/configuration/debug/debug-with-multiple-model/context.tsx": {- "react-refresh/only-export-components": {- "count": 1- }- },"app/components/app/configuration/debug/debug-with-multiple-model/debug-item.tsx": {"no-restricted-imports": {"count": 2@@ -1561,7 +1556,7 @@"count": 7}},- "app/components/base/chat/chat-with-history/context.tsx": {+ "app/components/base/chat/chat-with-history/context.ts": {"ts/no-explicit-any": {"count": 7}@@ -1715,11 +1710,6 @@"count": 1}},- "app/components/base/chat/chat/context.tsx": {- "react-refresh/only-export-components": {- "count": 1- }- },"app/components/base/chat/chat/hooks.ts": {"react-hooks-extra/no-direct-set-state-in-use-effect": {"count": 2@@ -1759,7 +1749,7 @@"count": 7}},- "app/components/base/chat/embedded-chatbot/context.tsx": {+ "app/components/base/chat/embedded-chatbot/context.ts": {"ts/no-explicit-any": {"count": 7}@@ -2763,7 +2753,7 @@"count": 2}},- "app/components/base/radio/context/index.tsx": {+ "app/components/base/radio/context/index.ts": {"ts/no-explicit-any": {"count": 1}@@ -2915,14 +2905,6 @@"count": 1}},- "app/components/base/toast/index.tsx": {- "react-refresh/only-export-components": {- "count": 2- },- "tailwindcss/enforce-consistent-class-order": {- "count": 2- }- },"app/components/base/video-gallery/VideoPlayer.tsx": {"react-hooks-extra/no-direct-set-state-in-use-effect": {"count": 1@@ -5683,10 +5665,7 @@"count": 1}},- "app/components/plugins/plugin-page/context.tsx": {- "react-refresh/only-export-components": {- "count": 2- },+ "app/components/plugins/plugin-page/context.ts": {"ts/no-explicit-any": {"count": 1}@@ -9571,16 +9550,6 @@"count": 5}},- "context/datasets-context.tsx": {- "react-refresh/only-export-components": {- "count": 1- }- },- "context/event-emitter.tsx": {- "react-refresh/only-export-components": {- "count": 1- }- },"context/external-api-panel-context.tsx": {"react-refresh/only-export-components": {"count": 1@@ -9601,8 +9570,8 @@"count": 3}},- "context/mitt-context.tsx": {- "react-refresh/only-export-components": {+ "context/modal-context-provider.tsx": {+ "ts/no-explicit-any": {"count": 3}},@@ -9611,18 +9580,12 @@"count": 3}},- "context/modal-context.tsx": {- "react-refresh/only-export-components": {- "count": 2- },+ "context/modal-context.ts": {"ts/no-explicit-any": {- "count": 5+ "count": 2}},- "context/provider-context.tsx": {- "react-refresh/only-export-components": {- "count": 3- },+ "context/provider-context-provider.tsx": {"ts/no-explicit-any": {"count": 1}@@ -9632,11 +9595,6 @@"count": 1}},- "context/workspace-context.tsx": {- "react-refresh/only-export-components": {- "count": 1- }- },"hooks/use-async-window-open.spec.ts": {"ts/no-explicit-any": {"count": 6diff --git a/web/hooks/use-import-dsl.ts b/web/hooks/use-import-dsl.tsindex ba33db1e845..454f580b429 100644--- a/web/hooks/use-import-dsl.ts+++ b/web/hooks/use-import-dsl.ts@@ -10,7 +10,7 @@ import {useState,} from 'react'import { useTranslation } from 'react-i18next'-import { useToastContext } from '@/app/components/base/toast'+import { useToastContext } from '@/app/components/base/toast/context'import { usePluginDependencies } from '@/app/components/workflow/plugin-dependency/hooks'import { NEED_REFRESH_APP_LIST_KEY } from '@/config'import { useSelector } from '@/context/app-context'