diff --git a/src/widgets/copilot/components/Messages/IncomingMsg.tsx b/src/widgets/copilot/components/Messages/IncomingMsg.tsx index 7af3653..a1cd691 100644 --- a/src/widgets/copilot/components/Messages/IncomingMsg.tsx +++ b/src/widgets/copilot/components/Messages/IncomingMsg.tsx @@ -74,6 +74,8 @@ const IncomingMsg = memo( const audioTrack = output_audio[0]; const videoTrack = output_video[0]; const isStreaming = type !== STREAM_MESSAGE_TYPES.FINAL_RESPONSE; + + // Parse the response text and format it - customised links, sources, etc. const parsedElements = formatTextResponse( props.data, props?.linkColor, diff --git a/src/widgets/copilot/components/Messages/helpers.tsx b/src/widgets/copilot/components/Messages/helpers.tsx index 6407778..2d30514 100644 --- a/src/widgets/copilot/components/Messages/helpers.tsx +++ b/src/widgets/copilot/components/Messages/helpers.tsx @@ -179,7 +179,7 @@ export const getReactParserOptions = (data: any): HTMLReactParserOptions => ({ }, transform(reactNode, domNode) { if (domNode.type === "text" && data.showSources) { - return customizedReferences(reactNode, domNode, data); + return customizedSources(reactNode, domNode, data); } // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-expect-error @@ -228,7 +228,7 @@ const customizedLinks = (reactNode: any, domNode: any, data: any) => { ); }; -const customizedReferences = (reactNode: any, domNode: any, data: any) => { +const customizedSources = (reactNode: any, domNode: any, data: any) => { if (!domNode) return domNode; let text = domNode.data || ""; @@ -259,10 +259,11 @@ const customizedReferences = (reactNode: any, domNode: any, data: any) => { return ( {text}{" "} - - - -
+ {!!references.length && ( + + + + )}
); };