From cff6a488f8af58947b8a38c867c12e5932931909 Mon Sep 17 00:00:00 2001 From: KVOJJJin Date: Fri, 25 Jul 2025 08:48:47 +0800 Subject: [PATCH] fix: unexpected redirection when landing at workflow (#22932) --- .../app/(appDetailLayout)/[appId]/layout-main.tsx | 7 ++----- web/app/components/app/configuration/index.tsx | 6 ++++-- web/app/components/workflow-app/index.tsx | 4 +++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/layout-main.tsx b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/layout-main.tsx index 7d5d4cb52..6b3807f1c 100644 --- a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/layout-main.tsx +++ b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/layout-main.tsx @@ -42,7 +42,7 @@ const AppDetailLayout: FC = (props) => { const pathname = usePathname() const media = useBreakpoints() const isMobile = media === MediaType.mobile - const { isCurrentWorkspaceEditor, isLoadingCurrentWorkspace } = useAppContext() + const { isCurrentWorkspaceEditor, isLoadingCurrentWorkspace, currentWorkspace } = useAppContext() const { appDetail, setAppDetail, setAppSiderbarExpand } = useStore(useShallow(state => ({ appDetail: state.appDetail, setAppDetail: state.setAppDetail, @@ -106,7 +106,6 @@ const AppDetailLayout: FC = (props) => { // if ((appDetail.mode === 'advanced-chat' || appDetail.mode === 'workflow') && (pathname).endsWith('workflow')) // setAppSiderbarExpand('collapse') } - // eslint-disable-next-line react-hooks/exhaustive-deps }, [appDetail, isMobile]) useEffect(() => { @@ -120,11 +119,10 @@ const AppDetailLayout: FC = (props) => { }).finally(() => { setIsLoadingAppDetail(false) }) - // eslint-disable-next-line react-hooks/exhaustive-deps }, [appId, pathname]) useEffect(() => { - if (!appDetailRes || isLoadingCurrentWorkspace || isLoadingAppDetail) + if (!appDetailRes || !currentWorkspace.id || isLoadingCurrentWorkspace || isLoadingAppDetail) return const res = appDetailRes // redirection @@ -143,7 +141,6 @@ const AppDetailLayout: FC = (props) => { setAppDetail({ ...res, enable_sso: false }) setNavigation(getNavigations(appId, isCurrentWorkspaceEditor, res.mode)) } - // eslint-disable-next-line react-hooks/exhaustive-deps }, [appDetailRes, isCurrentWorkspaceEditor, isLoadingAppDetail, isLoadingCurrentWorkspace]) useUnmount(() => { diff --git a/web/app/components/app/configuration/index.tsx b/web/app/components/app/configuration/index.tsx index 02f1928ec..42affb055 100644 --- a/web/app/components/app/configuration/index.tsx +++ b/web/app/components/app/configuration/index.tsx @@ -82,6 +82,7 @@ import { supportFunctionCall } from '@/utils/tool-call' import { MittProvider } from '@/context/mitt-context' import { fetchAndMergeValidCompletionParams } from '@/utils/completion-params' import Toast from '@/app/components/base/toast' +import { useAppContext } from '@/context/app-context' type PublishConfig = { modelConfig: ModelConfig @@ -91,6 +92,8 @@ type PublishConfig = { const Configuration: FC = () => { const { t } = useTranslation() const { notify } = useContext(ToastContext) + const { isLoadingCurrentWorkspace, currentWorkspace } = useAppContext() + const { appDetail, showAppConfigureFeaturesModal, setAppSiderbarExpand, setShowAppConfigureFeaturesModal } = useAppStore(useShallow(state => ({ appDetail: state.appDetail, setAppSiderbarExpand: state.setAppSiderbarExpand, @@ -693,7 +696,6 @@ const Configuration: FC = () => { setHasFetchedDetail(true) }) })() - // eslint-disable-next-line react-hooks/exhaustive-deps }, [appId]) const promptEmpty = (() => { @@ -843,7 +845,7 @@ const Configuration: FC = () => { setAppSiderbarExpand('collapse') } - if (isLoading) { + if (isLoading || isLoadingCurrentWorkspace || !currentWorkspace.id) { return
diff --git a/web/app/components/workflow-app/index.tsx b/web/app/components/workflow-app/index.tsx index 471d4de0d..8895253a9 100644 --- a/web/app/components/workflow-app/index.tsx +++ b/web/app/components/workflow-app/index.tsx @@ -19,6 +19,7 @@ import { FeaturesProvider } from '@/app/components/base/features' import type { Features as FeaturesData } from '@/app/components/base/features/types' import { FILE_EXTS } from '@/app/components/base/prompt-editor/constants' import { fetchFileUploadConfig } from '@/service/common' +import { useAppContext } from '@/context/app-context' import WorkflowWithDefaultContext from '@/app/components/workflow' import { WorkflowContextProvider, @@ -31,6 +32,7 @@ const WorkflowAppWithAdditionalContext = () => { data, isLoading, } = useWorkflowInit() + const { isLoadingCurrentWorkspace, currentWorkspace } = useAppContext() const { data: fileUploadConfigResponse } = useSWR({ url: '/files/upload' }, fetchFileUploadConfig) const nodesData = useMemo(() => { @@ -46,7 +48,7 @@ const WorkflowAppWithAdditionalContext = () => { return [] }, [data]) - if (!data || isLoading) { + if (!data || isLoading || isLoadingCurrentWorkspace || !currentWorkspace.id) { return (