fix share link chat quote number (#4690)

* fix share link chat quote number

* fix ts

* usememo
This commit is contained in:
heheer
2025-04-28 10:33:33 +08:00
committed by GitHub
parent d6fed3d23a
commit cc01aa4ab8
12 changed files with 39 additions and 8 deletions

View File

@@ -251,6 +251,7 @@ const ChatItem = (props: Props) => {
chatId: chatId, chatId: chatId,
chatItemDataId: chat.dataId, chatItemDataId: chat.dataId,
collectionId: collectionId, collectionId: collectionId,
collectionIdList,
sourceId: sourceId || '', sourceId: sourceId || '',
sourceName: sourceName || '', sourceName: sourceName || '',
datasetId: datasetId || '', datasetId: datasetId || '',
@@ -272,11 +273,12 @@ const ChatItem = (props: Props) => {
); );
useEffect(() => { useEffect(() => {
if (chat.obj !== ChatRoleEnum.AI) return;
eventBus.on(EventNameEnum.openQuoteReader, handleOpenQuoteReader); eventBus.on(EventNameEnum.openQuoteReader, handleOpenQuoteReader);
return () => { return () => {
eventBus.off(EventNameEnum.openQuoteReader); eventBus.off(EventNameEnum.openQuoteReader);
}; };
}, [handleOpenQuoteReader]); }, [chat.obj, handleOpenQuoteReader]);
return ( return (
<Box <Box

View File

@@ -29,6 +29,8 @@ import { useTranslation } from 'next-i18next';
import { eventBus, EventNameEnum } from '@/web/common/utils/eventbus'; import { eventBus, EventNameEnum } from '@/web/common/utils/eventbus';
import { SelectOptionsComponent, FormInputComponent } from './Interactive/InteractiveComponents'; import { SelectOptionsComponent, FormInputComponent } from './Interactive/InteractiveComponents';
import { extractDeepestInteractive } from '@fastgpt/global/core/workflow/runtime/utils'; import { extractDeepestInteractive } from '@fastgpt/global/core/workflow/runtime/utils';
import { useContextSelector } from 'use-context-selector';
import { ChatItemContext } from '@/web/core/chat/context/chatItemContext';
const accordionButtonStyle = { const accordionButtonStyle = {
w: 'auto', w: 'auto',
@@ -88,9 +90,17 @@ const RenderText = React.memo(function RenderText({
text text
}: { }: {
showAnimation: boolean; showAnimation: boolean;
text?: string; text: string;
}) { }) {
let source = text || ''; const isResponseDetail = useContextSelector(ChatItemContext, (v) => v.isResponseDetail);
const source = useMemo(() => {
if (!text) return '';
// Remove quote references if not showing response detail
return isResponseDetail ? text : text.replace(/\[[a-f0-9]{24}\]\(QUOTE\)/g, '');
}, [text, isResponseDetail]);
// First empty line // First empty line
// if (!source && !isLastChild) return null; // if (!source && !isLastChild) return null;

View File

@@ -213,6 +213,7 @@ const Render = (props: Props) => {
showRouteToAppDetail={true} showRouteToAppDetail={true}
showRouteToDatasetDetail={true} showRouteToDatasetDetail={true}
isShowReadRawSource={true} isShowReadRawSource={true}
isResponseDetail={true}
// isShowFullText={true} // isShowFullText={true}
showNodeStatus showNodeStatus
> >

View File

@@ -152,6 +152,7 @@ const Render = ({ currentTool, url }: { currentTool: ToolType | null; url: strin
showRouteToAppDetail={true} showRouteToAppDetail={true}
showRouteToDatasetDetail={true} showRouteToDatasetDetail={true}
isShowReadRawSource={true} isShowReadRawSource={true}
isResponseDetail={true}
// isShowFullText={true} // isShowFullText={true}
showNodeStatus showNodeStatus
> >

View File

@@ -119,6 +119,7 @@ const Render = ({ appForm, setRenderEdit }: Props) => {
showRouteToAppDetail={true} showRouteToAppDetail={true}
showRouteToDatasetDetail={true} showRouteToDatasetDetail={true}
isShowReadRawSource={true} isShowReadRawSource={true}
isResponseDetail={true}
// isShowFullText={true} // isShowFullText={true}
showNodeStatus showNodeStatus
> >

View File

@@ -195,6 +195,7 @@ const Render = (Props: Props) => {
showRouteToAppDetail={true} showRouteToAppDetail={true}
showRouteToDatasetDetail={true} showRouteToDatasetDetail={true}
isShowReadRawSource={true} isShowReadRawSource={true}
isResponseDetail={true}
// isShowFullText={true} // isShowFullText={true}
showNodeStatus showNodeStatus
> >

View File

@@ -35,9 +35,9 @@ async function handler(
? await authApp({ req, appId: parentId, per: TeamAppCreatePermissionVal, authToken: true }) ? await authApp({ req, appId: parentId, per: TeamAppCreatePermissionVal, authToken: true })
: await authUserPer({ req, authToken: true, per: TeamAppCreatePermissionVal }); : await authUserPer({ req, authToken: true, per: TeamAppCreatePermissionVal });
await mongoSessionRun(async (session) => { const httpPluginId = await mongoSessionRun(async (session) => {
// create http plugin folder // create http plugin folder
const httpPluginIid = await onCreateApp({ const httpPluginId = await onCreateApp({
parentId, parentId,
name, name,
avatar, avatar,
@@ -51,7 +51,7 @@ async function handler(
// compute children plugins // compute children plugins
const childrenPlugins = await httpApiSchema2Plugins({ const childrenPlugins = await httpApiSchema2Plugins({
parentId: httpPluginIid, parentId: httpPluginId,
apiSchemaStr: pluginData.apiSchemaStr, apiSchemaStr: pluginData.apiSchemaStr,
customHeader: pluginData.customHeaders customHeader: pluginData.customHeaders
}); });
@@ -65,10 +65,13 @@ async function handler(
session session
}); });
} }
return httpPluginId;
}); });
pushTrack.createApp({ pushTrack.createApp({
type: AppTypeEnum.httpPlugin, type: AppTypeEnum.httpPlugin,
appId: httpPluginId,
uid: userId, uid: userId,
teamId, teamId,
tmbId tmbId

View File

@@ -35,7 +35,7 @@ async function handler(
? await authApp({ req, appId: parentId, per: TeamAppCreatePermissionVal, authToken: true }) ? await authApp({ req, appId: parentId, per: TeamAppCreatePermissionVal, authToken: true })
: await authUserPer({ req, authToken: true, per: TeamAppCreatePermissionVal }); : await authUserPer({ req, authToken: true, per: TeamAppCreatePermissionVal });
await mongoSessionRun(async (session) => { const mcpToolsId = await mongoSessionRun(async (session) => {
const mcpToolsId = await onCreateApp({ const mcpToolsId = await onCreateApp({
name, name,
avatar, avatar,
@@ -60,10 +60,13 @@ async function handler(
session session
}); });
} }
return mcpToolsId;
}); });
pushTrack.createApp({ pushTrack.createApp({
type: AppTypeEnum.toolSet, type: AppTypeEnum.toolSet,
appId: mcpToolsId,
uid: userId, uid: userId,
teamId, teamId,
tmbId tmbId

View File

@@ -294,6 +294,7 @@ const Render = (props: { appId: string; isStandalone?: string }) => {
showRouteToAppDetail={isStandalone !== '1'} showRouteToAppDetail={isStandalone !== '1'}
showRouteToDatasetDetail={isStandalone !== '1'} showRouteToDatasetDetail={isStandalone !== '1'}
isShowReadRawSource={true} isShowReadRawSource={true}
isResponseDetail={true}
// isShowFullText={true} // isShowFullText={true}
showNodeStatus showNodeStatus
> >

View File

@@ -50,6 +50,7 @@ type Props = {
authToken: string; authToken: string;
customUid: string; customUid: string;
showRawSource: boolean; showRawSource: boolean;
responseDetail: boolean;
// showFullText: boolean; // showFullText: boolean;
showNodeStatus: boolean; showNodeStatus: boolean;
}; };
@@ -369,6 +370,7 @@ const Render = (props: Props) => {
showRouteToAppDetail={false} showRouteToAppDetail={false}
showRouteToDatasetDetail={false} showRouteToDatasetDetail={false}
isShowReadRawSource={props.showRawSource} isShowReadRawSource={props.showRawSource}
isResponseDetail={props.responseDetail}
// isShowFullText={props.showFullText} // isShowFullText={props.showFullText}
showNodeStatus={props.showNodeStatus} showNodeStatus={props.showNodeStatus}
> >
@@ -395,7 +397,7 @@ export async function getServerSideProps(context: any) {
{ {
shareId shareId
}, },
'appId showRawSource showNodeStatus' 'appId showRawSource showNodeStatus responseDetail'
) )
.populate<{ associatedApp: AppSchema }>('associatedApp', 'name avatar intro') .populate<{ associatedApp: AppSchema }>('associatedApp', 'name avatar intro')
.lean(); .lean();
@@ -412,6 +414,7 @@ export async function getServerSideProps(context: any) {
appAvatar: app?.associatedApp?.avatar ?? '', appAvatar: app?.associatedApp?.avatar ?? '',
appIntro: app?.associatedApp?.intro ?? 'AI', appIntro: app?.associatedApp?.intro ?? 'AI',
showRawSource: app?.showRawSource ?? false, showRawSource: app?.showRawSource ?? false,
responseDetail: app?.responseDetail ?? false,
// showFullText: app?.showFullText ?? false, // showFullText: app?.showFullText ?? false,
showNodeStatus: app?.showNodeStatus ?? false, showNodeStatus: app?.showNodeStatus ?? false,
shareId: shareId ?? '', shareId: shareId ?? '',

View File

@@ -314,6 +314,7 @@ const Render = (props: Props) => {
showRouteToAppDetail={false} showRouteToAppDetail={false}
showRouteToDatasetDetail={false} showRouteToDatasetDetail={false}
isShowReadRawSource={true} isShowReadRawSource={true}
isResponseDetail={true}
// isShowFullText={true} // isShowFullText={true}
showNodeStatus showNodeStatus
> >

View File

@@ -15,6 +15,7 @@ type ContextProps = {
showRouteToAppDetail: boolean; showRouteToAppDetail: boolean;
showRouteToDatasetDetail: boolean; showRouteToDatasetDetail: boolean;
isShowReadRawSource: boolean; isShowReadRawSource: boolean;
isResponseDetail: boolean;
// isShowFullText: boolean; // isShowFullText: boolean;
showNodeStatus: boolean; showNodeStatus: boolean;
}; };
@@ -115,6 +116,7 @@ const ChatItemContextProvider = ({
showRouteToAppDetail, showRouteToAppDetail,
showRouteToDatasetDetail, showRouteToDatasetDetail,
isShowReadRawSource, isShowReadRawSource,
isResponseDetail,
// isShowFullText, // isShowFullText,
showNodeStatus showNodeStatus
}: { }: {
@@ -177,6 +179,7 @@ const ChatItemContextProvider = ({
showRouteToAppDetail, showRouteToAppDetail,
showRouteToDatasetDetail, showRouteToDatasetDetail,
isShowReadRawSource, isShowReadRawSource,
isResponseDetail,
// isShowFullText, // isShowFullText,
showNodeStatus, showNodeStatus,
@@ -195,6 +198,7 @@ const ChatItemContextProvider = ({
showRouteToAppDetail, showRouteToAppDetail,
showRouteToDatasetDetail, showRouteToDatasetDetail,
isShowReadRawSource, isShowReadRawSource,
isResponseDetail,
// isShowFullText, // isShowFullText,
showNodeStatus, showNodeStatus,
quoteData, quoteData,