From 9bfacb9167652cfd607202f1c172a2359ef613fd Mon Sep 17 00:00:00 2001 From: heheer Date: Mon, 22 Dec 2025 16:37:19 +0800 Subject: [PATCH] fix --- .../ChatBox/components/QuoteList.tsx | 2 +- .../ChatBox/components/ResponseTags.tsx | 15 ++++++--------- .../core/chat/components/AIResponseBox.tsx | 12 ++++++------ .../app/src/components/core/dataset/QuoteItem.tsx | 6 +++--- .../app/detail/HTTPTools/ChatTest.tsx | 2 +- .../app/detail/Logs/DetailLogsModal.tsx | 2 +- .../app/detail/MCPTools/ChatTest.tsx | 2 +- .../app/detail/SimpleApp/ChatTest.tsx | 2 +- .../detail/WorkflowComponents/Flow/ChatTest.tsx | 2 +- .../chat/ChatWindow/AppChatWindow.tsx | 6 +++--- .../chat/ChatWindow/HomeChatWindow.tsx | 9 +++++---- .../src/pageComponents/dataset/detail/Test.tsx | 2 +- projects/app/src/pages/chat/index.tsx | 2 +- projects/app/src/pages/chat/share.tsx | 12 ++++++------ .../src/web/core/chat/context/chatItemContext.tsx | 8 ++++---- 15 files changed, 41 insertions(+), 43 deletions(-) diff --git a/projects/app/src/components/core/chat/ChatContainer/ChatBox/components/QuoteList.tsx b/projects/app/src/components/core/chat/ChatContainer/ChatBox/components/QuoteList.tsx index 6d9115dac..f76b2cc67 100644 --- a/projects/app/src/components/core/chat/ChatContainer/ChatBox/components/QuoteList.tsx +++ b/projects/app/src/components/core/chat/ChatContainer/ChatBox/components/QuoteList.tsx @@ -87,7 +87,7 @@ const QuoteList = React.memo(function QuoteList({ > v.isShowQuote); + const isShowCite = useContextSelector(ChatItemContext, (v) => v.isShowCite); const { totalQuoteList: quoteList = [], llmModuleAccount = 0, historyPreviewLength = 0, toolCiteLinks = [] } = useMemo(() => { - if (!isResponseDetail) + if (!isShowCite) return { totalQuoteList: [], llmModuleAccount: 0, @@ -64,16 +64,13 @@ const ResponseTags = ({ toolCiteLinks: [] }; return addStatisticalDataToHistoryItem(historyItem); - }, [historyItem, isResponseDetail]); + }, [historyItem, isShowCite]); const [quoteFolded, setQuoteFolded] = useState(true); const chatType = useContextSelector(ChatBoxContext, (v) => v.chatType); - const notSharePage = useMemo( - () => chatType !== 'share' && isResponseDetail, - [chatType, isResponseDetail] - ); + const notSharePage = useMemo(() => chatType !== 'share' && isShowCite, [chatType, isShowCite]); const { isOpen: isOpenWholeModal, @@ -92,7 +89,7 @@ const ResponseTags = ({ : true; const citationRenderList: CitationRenderItem[] = useMemo(() => { - if (!isResponseDetail) return []; + if (!isShowCite) return []; // Dataset citations const datasetItems = Object.values( quoteList.reduce((acc: Record, cur) => { @@ -131,7 +128,7 @@ const ResponseTags = ({ })); return [...datasetItems, ...linkItems]; - }, [quoteList, toolCiteLinks, onOpenCiteModal, isResponseDetail]); + }, [quoteList, toolCiteLinks, onOpenCiteModal, isShowCite]); const notEmptyTags = notSharePage || quoteList.length > 0 || (isPc && durationSeconds > 0); diff --git a/projects/app/src/components/core/chat/components/AIResponseBox.tsx b/projects/app/src/components/core/chat/components/AIResponseBox.tsx index 62503e54a..1a05f0692 100644 --- a/projects/app/src/components/core/chat/components/AIResponseBox.tsx +++ b/projects/app/src/components/core/chat/components/AIResponseBox.tsx @@ -106,16 +106,16 @@ const RenderText = React.memo(function RenderText({ const appId = useContextSelector(WorkflowRuntimeContext, (v) => v.appId); const chatId = useContextSelector(WorkflowRuntimeContext, (v) => v.chatId); const outLinkAuthData = useContextSelector(WorkflowRuntimeContext, (v) => v.outLinkAuthData); - const isShowQuote = useContextSelector(ChatItemContext, (v) => v.isShowQuote); + const isShowCite = useContextSelector(ChatItemContext, (v) => v.isShowCite); const source = useMemo(() => { if (!text) return ''; - if (isShowQuote) { + if (isShowCite) { return text; } - return removeDatasetCiteText(text, isShowQuote); - }, [text, isShowQuote]); + return removeDatasetCiteText(text, isShowCite); + }, [text, isShowCite]); const chatAuthData = useCreation(() => { return { appId, chatId, chatItemDataId, ...outLinkAuthData }; @@ -336,7 +336,7 @@ const AIResponseBox = ({ isChatting: boolean; onOpenCiteModal?: (e?: OnOpenCiteModalProps) => void; }) => { - const isShowQuote = useContextSelector(ChatItemContext, (v) => v.isShowQuote); + const showRunningStatus = useContextSelector(ChatItemContext, (v) => v.showRunningStatus); if (value.type === ChatItemValueTypeEnum.text && value.text) { return ( @@ -357,7 +357,7 @@ const AIResponseBox = ({ /> ); } - if (value.type === ChatItemValueTypeEnum.tool && value.tools && isShowQuote) { + if (value.type === ChatItemValueTypeEnum.tool && value.tools && showRunningStatus) { return ; } if (value.type === ChatItemValueTypeEnum.interactive && value.interactive) { diff --git a/projects/app/src/components/core/dataset/QuoteItem.tsx b/projects/app/src/components/core/dataset/QuoteItem.tsx index bbf79e9d2..3e8bcaaf2 100644 --- a/projects/app/src/components/core/dataset/QuoteItem.tsx +++ b/projects/app/src/components/core/dataset/QuoteItem.tsx @@ -91,13 +91,13 @@ export const formatScore = (score: ScoreItemType[]) => { const QuoteItem = ({ quoteItem, - canViewSource, + canDownloadSource, canEditData, canEditDataset, ...RawSourceBoxProps }: { quoteItem: SearchDataResponseItemType; - canViewSource?: boolean; + canDownloadSource?: boolean; canEditData?: boolean; canEditDataset?: boolean; } & Omit) => { @@ -208,7 +208,7 @@ const QuoteItem = ({ collectionId={quoteItem.collectionId} sourceName={quoteItem.sourceName} sourceId={quoteItem.sourceId} - canView={canViewSource} + canView={canDownloadSource} {...RawSourceBoxProps} /> diff --git a/projects/app/src/pageComponents/app/detail/HTTPTools/ChatTest.tsx b/projects/app/src/pageComponents/app/detail/HTTPTools/ChatTest.tsx index 5a3027adf..2dd30e33c 100644 --- a/projects/app/src/pageComponents/app/detail/HTTPTools/ChatTest.tsx +++ b/projects/app/src/pageComponents/app/detail/HTTPTools/ChatTest.tsx @@ -206,7 +206,7 @@ const Render = ({ diff --git a/projects/app/src/pageComponents/app/detail/Logs/DetailLogsModal.tsx b/projects/app/src/pageComponents/app/detail/Logs/DetailLogsModal.tsx index 7ff91369e..091aa4300 100644 --- a/projects/app/src/pageComponents/app/detail/Logs/DetailLogsModal.tsx +++ b/projects/app/src/pageComponents/app/detail/Logs/DetailLogsModal.tsx @@ -265,7 +265,7 @@ const Render = (props: Props) => { diff --git a/projects/app/src/pageComponents/app/detail/MCPTools/ChatTest.tsx b/projects/app/src/pageComponents/app/detail/MCPTools/ChatTest.tsx index 5c816be25..d516eb47b 100644 --- a/projects/app/src/pageComponents/app/detail/MCPTools/ChatTest.tsx +++ b/projects/app/src/pageComponents/app/detail/MCPTools/ChatTest.tsx @@ -183,7 +183,7 @@ const Render = ({ diff --git a/projects/app/src/pageComponents/app/detail/SimpleApp/ChatTest.tsx b/projects/app/src/pageComponents/app/detail/SimpleApp/ChatTest.tsx index 3898f2b6e..1c7e81ccb 100644 --- a/projects/app/src/pageComponents/app/detail/SimpleApp/ChatTest.tsx +++ b/projects/app/src/pageComponents/app/detail/SimpleApp/ChatTest.tsx @@ -119,7 +119,7 @@ const Render = ({ appForm, setRenderEdit }: Props) => { diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/ChatTest.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/ChatTest.tsx index 4c2ad4304..fb0567076 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/ChatTest.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/ChatTest.tsx @@ -207,7 +207,7 @@ const Render = (Props: Props) => { diff --git a/projects/app/src/pageComponents/chat/ChatWindow/AppChatWindow.tsx b/projects/app/src/pageComponents/chat/ChatWindow/AppChatWindow.tsx index 55821c9bb..e0251ab60 100644 --- a/projects/app/src/pageComponents/chat/ChatWindow/AppChatWindow.tsx +++ b/projects/app/src/pageComponents/chat/ChatWindow/AppChatWindow.tsx @@ -45,7 +45,7 @@ const AppChatWindow = ({ myApps }: Props) => { const onUpdateHistoryTitle = useContextSelector(ChatContext, (v) => v.onUpdateHistoryTitle); const isPlugin = useContextSelector(ChatItemContext, (v) => v.isPlugin); - const showRunningStatus = useContextSelector(ChatItemContext, (v) => v.showRunningStatus); + const isShowCite = useContextSelector(ChatItemContext, (v) => v.isShowCite); const onChangeChatId = useContextSelector(ChatContext, (v) => v.onChangeChatId); const chatBoxData = useContextSelector(ChatItemContext, (v) => v.chatBoxData); const datasetCiteData = useContextSelector(ChatItemContext, (v) => v.datasetCiteData); @@ -108,7 +108,7 @@ const AppChatWindow = ({ myApps }: Props) => { responseChatItemId, appId, chatId, - retainDatasetCite: showRunningStatus + retainDatasetCite: isShowCite }, abortCtrl: controller, onMessage: generatingMessage @@ -124,7 +124,7 @@ const AppChatWindow = ({ myApps }: Props) => { return { responseText, isNewChat: forbidLoadChat.current }; }, - [appId, chatId, onUpdateHistoryTitle, setChatBoxData, forbidLoadChat, showRunningStatus] + [appId, chatId, onUpdateHistoryTitle, setChatBoxData, forbidLoadChat, isShowCite] ); return ( diff --git a/projects/app/src/pageComponents/chat/ChatWindow/HomeChatWindow.tsx b/projects/app/src/pageComponents/chat/ChatWindow/HomeChatWindow.tsx index 0fe97468f..062b176a8 100644 --- a/projects/app/src/pageComponents/chat/ChatWindow/HomeChatWindow.tsx +++ b/projects/app/src/pageComponents/chat/ChatWindow/HomeChatWindow.tsx @@ -84,7 +84,7 @@ const HomeChatWindow = ({ myApps }: Props) => { const datasetCiteData = useContextSelector(ChatItemContext, (v) => v.datasetCiteData); const setChatBoxData = useContextSelector(ChatItemContext, (v) => v.setChatBoxData); const resetVariables = useContextSelector(ChatItemContext, (v) => v.resetVariables); - const showRunningStatus = useContextSelector(ChatItemContext, (v) => v.showRunningStatus); + const isShowCite = useContextSelector(ChatItemContext, (v) => v.isShowCite); const pane = useContextSelector(ChatSettingContext, (v) => v.pane); const chatSettings = useContextSelector(ChatSettingContext, (v) => v.chatSettings); @@ -218,7 +218,7 @@ const HomeChatWindow = ({ myApps }: Props) => { responseChatItemId, appId, chatId, - retainDatasetCite: showRunningStatus + retainDatasetCite: isShowCite }, abortCtrl: controller, onMessage: generatingMessage @@ -266,7 +266,7 @@ const HomeChatWindow = ({ myApps }: Props) => { appId, appName: t('chat:home.chat_app'), chatId, - retainDatasetCite: showRunningStatus, + retainDatasetCite: isShowCite, ...form2AppWorkflow(formData, t) }, onMessage: generatingMessage, @@ -397,7 +397,8 @@ const HomeChatWindow = ({ myApps }: Props) => { setSelectedToolIds, setChatBoxData, isPc, - isQuickApp + isQuickApp, + isShowCite ] ); diff --git a/projects/app/src/pageComponents/dataset/detail/Test.tsx b/projects/app/src/pageComponents/dataset/detail/Test.tsx index 61e59c82f..6e66e5757 100644 --- a/projects/app/src/pageComponents/dataset/detail/Test.tsx +++ b/projects/app/src/pageComponents/dataset/detail/Test.tsx @@ -449,7 +449,7 @@ const TestResults = React.memo(function TestResults({ {datasetTestItem?.results.map((item, index) => ( - + ))} diff --git a/projects/app/src/pages/chat/index.tsx b/projects/app/src/pages/chat/index.tsx index 7b5c4bd39..536b4d19d 100644 --- a/projects/app/src/pages/chat/index.tsx +++ b/projects/app/src/pages/chat/index.tsx @@ -150,7 +150,7 @@ const Render = (props: { showRouteToDatasetDetail={isStandalone !== '1'} showRunningStatus={props.showRunningStatus} canDownloadSource={props.canDownloadSource} - isShowQuote={props.showCite} + isShowCite={props.showCite} isShowFullText={props.showFullText} > diff --git a/projects/app/src/pages/chat/share.tsx b/projects/app/src/pages/chat/share.tsx index 2b29260c3..7763606a6 100644 --- a/projects/app/src/pages/chat/share.tsx +++ b/projects/app/src/pages/chat/share.tsx @@ -54,7 +54,7 @@ type Props = { authToken: string; customUid: string; canDownloadSource: boolean; - isShowQuote: boolean; + isShowCite: boolean; isShowFullText: boolean; showRunningStatus: boolean; }; @@ -95,7 +95,7 @@ const OutLink = (props: Props) => { const setChatBoxData = useContextSelector(ChatItemContext, (v) => v.setChatBoxData); const datasetCiteData = useContextSelector(ChatItemContext, (v) => v.datasetCiteData); const setCiteModalData = useContextSelector(ChatItemContext, (v) => v.setCiteModalData); - const canDownloadSource = useContextSelector(ChatItemContext, (v) => v.canDownloadSource); + const isShowCite = useContextSelector(ChatItemContext, (v) => v.isShowCite); const chatRecords = useContextSelector(ChatRecordContext, (v) => v.chatRecords); const totalRecordsCount = useContextSelector(ChatRecordContext, (v) => v.totalRecordsCount); @@ -175,7 +175,7 @@ const OutLink = (props: Props) => { responseChatItemId, chatId: completionChatId, ...outLinkAuthData, - retainDatasetCite: canDownloadSource + retainDatasetCite: isShowCite }, onMessage: generatingMessage, abortCtrl: controller @@ -213,7 +213,7 @@ const OutLink = (props: Props) => { chatId, customVariables, outLinkAuthData, - canDownloadSource, + isShowCite, onUpdateHistoryTitle, setChatBoxData, forbidLoadChat, @@ -389,7 +389,7 @@ const Render = (props: Props) => { @@ -433,7 +433,7 @@ export async function getServerSideProps(context: any) { appAvatar: app?.associatedApp?.avatar ?? '', appIntro: app?.associatedApp?.intro ?? 'AI', canDownloadSource: app?.canDownloadSource ?? false, - isShowQuote: app?.showCite ?? false, + isShowCite: app?.showCite ?? false, isShowFullText: app?.showFullText ?? false, showRunningStatus: app?.showRunningStatus ?? false, shareId: shareId ?? '', diff --git a/projects/app/src/web/core/chat/context/chatItemContext.tsx b/projects/app/src/web/core/chat/context/chatItemContext.tsx index c272170f9..4bb873e89 100644 --- a/projects/app/src/web/core/chat/context/chatItemContext.tsx +++ b/projects/app/src/web/core/chat/context/chatItemContext.tsx @@ -14,7 +14,7 @@ import { type OutLinkChatAuthProps } from '@fastgpt/global/support/permission/ch type ContextProps = { showRouteToDatasetDetail: boolean; canDownloadSource: boolean; - isShowQuote: boolean; + isShowCite: boolean; isShowFullText: boolean; showRunningStatus: boolean; }; @@ -121,7 +121,7 @@ const ChatItemContextProvider = ({ children, showRouteToDatasetDetail, canDownloadSource, - isShowQuote, + isShowCite, isShowFullText, showRunningStatus }: { @@ -197,7 +197,7 @@ const ChatItemContextProvider = ({ clearChatRecords, showRouteToDatasetDetail, canDownloadSource, - isShowQuote, + isShowCite, isShowFullText, showRunningStatus, @@ -215,7 +215,7 @@ const ChatItemContextProvider = ({ clearChatRecords, showRouteToDatasetDetail, canDownloadSource, - isShowQuote, + isShowCite, showRunningStatus, isShowFullText, datasetCiteData,