@@ -18,12 +18,14 @@ import useCaptureEvent from "@/hooks/useCaptureEvent";
1818import { LangfuseWeb } from "langfuse" ;
1919import { env } from "@sourcebot/shared/client" ;
2020import isEqual from "fast-deep-equal/react" ;
21+ import { FileSource } from "../../types" ;
2122
2223interface AnswerCardProps {
2324 answerText : string ;
2425 messageId : string ;
2526 chatId : string ;
2627 traceId ?: string ;
28+ sources ?: FileSource [ ] ;
2729}
2830
2931const langfuseWeb = ( env . NEXT_PUBLIC_SOURCEBOT_CLOUD_ENVIRONMENT !== undefined && env . NEXT_PUBLIC_LANGFUSE_PUBLIC_KEY ) ? new LangfuseWeb ( {
@@ -35,7 +37,8 @@ const AnswerCardComponent = forwardRef<HTMLDivElement, AnswerCardProps>(({
3537 answerText,
3638 messageId,
3739 chatId,
38- traceId,
40+ traceId,
41+ sources,
3942} , forwardedRef ) => {
4043 const markdownRendererRef = useRef < HTMLDivElement > ( null ) ;
4144 const { tocItems, activeId } = useExtractTOCItems ( { target : markdownRendererRef . current } ) ;
@@ -51,13 +54,13 @@ const AnswerCardComponent = forwardRef<HTMLDivElement, AnswerCardProps>(({
5154 ) ;
5255
5356 const onCopyAnswer = useCallback ( ( ) => {
54- const markdownText = convertLLMOutputToPortableMarkdown ( answerText ) ;
57+ const markdownText = convertLLMOutputToPortableMarkdown ( answerText , { sources } ) ;
5558 navigator . clipboard . writeText ( markdownText ) ;
5659 toast ( {
5760 description : "✅ Copied to clipboard" ,
5861 } ) ;
5962 return true ;
60- } , [ answerText , toast ] ) ;
63+ } , [ answerText , sources , toast ] ) ;
6164
6265 const onFeedback = useCallback ( async ( feedbackType : 'like' | 'dislike' ) => {
6366 setIsSubmittingFeedback ( true ) ;
0 commit comments