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

View File

@@ -29,6 +29,8 @@ import { useTranslation } from 'next-i18next';
import { eventBus, EventNameEnum } from '@/web/common/utils/eventbus';
import { SelectOptionsComponent, FormInputComponent } from './Interactive/InteractiveComponents';
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 = {
w: 'auto',
@@ -88,9 +90,17 @@ const RenderText = React.memo(function RenderText({
text
}: {
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
// if (!source && !isLastChild) return null;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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