1
1
import { useAssistantToolUI } from "@assistant-ui/react" ;
2
2
import { Card , CardContent , CardHeader , CardTitle } from "./ui/card" ;
3
- import { BookOpenText , Plus , SquareArrowOutUpRight } from "lucide-react" ;
4
- import {
5
- TooltipProvider ,
6
- TooltipTrigger ,
7
- TooltipContent ,
8
- Tooltip ,
9
- } from "./ui/tooltip" ;
3
+ import { BookOpenText , Plus } from "lucide-react" ;
10
4
import { Sheet , SheetContent , SheetTrigger } from "./ui/sheet" ;
5
+ import { DocumentDialog } from "./DocumentDialog" ;
11
6
12
7
type Document = {
13
8
page_content : string ;
@@ -36,42 +31,6 @@ const DocumentCard = ({ document }: { document: Document }) => {
36
31
) ;
37
32
} ;
38
33
39
- const DocumentCardTooltip = ( { document } : { document : Document } ) => {
40
- const description =
41
- document . metadata . description && document . metadata . description !== ""
42
- ? document . metadata . description
43
- : document . page_content . slice ( 0 , 250 ) ;
44
-
45
- return (
46
- < TooltipProvider >
47
- < Tooltip defaultOpen delayDuration = { 0 } >
48
- < TooltipTrigger asChild >
49
- < DocumentCard document = { document } />
50
- </ TooltipTrigger >
51
- < TooltipContent className = "flex flex-col max-w-[600px] whitespace-pre-wrap" >
52
- < div className = "flex flex-col gap-1" >
53
- < p className = "font-medium text-gray-300" >
54
- { document . metadata . title }
55
- </ p >
56
- < div className = "flex flex-wrap justify-start" >
57
- < a
58
- href = { document . metadata . source }
59
- target = "_blank"
60
- rel = "noopener noreferrer"
61
- className = "flex items-center text-blue-400 hover:text-blue-300 transition-colors duration-200 break-all"
62
- >
63
- Source{ " " }
64
- < SquareArrowOutUpRight className = "ml-1 h-4 w-4 flex-shrink-0" />
65
- </ a >
66
- </ div >
67
- < p className = "text-xs font-light text-gray-400" > { description } </ p >
68
- </ div >
69
- </ TooltipContent >
70
- </ Tooltip >
71
- </ TooltipProvider >
72
- ) ;
73
- } ;
74
-
75
34
export const useSelectedDocumentsUI = ( ) =>
76
35
useAssistantToolUI ( {
77
36
toolName : "selected_documents" ,
@@ -92,9 +51,10 @@ export const useSelectedDocumentsUI = () =>
92
51
</ span >
93
52
< div className = "flex flex-wrap items-center justify-start gap-2" >
94
53
{ displayedDocuments . map ( ( document , docIndex ) => (
95
- < DocumentCardTooltip
96
- key = { `final-document -${ docIndex } ` }
54
+ < DocumentDialog
55
+ key = { `all-documents -${ docIndex } ` }
97
56
document = { document }
57
+ trigger = { < DocumentCard document = { document } /> }
98
58
/>
99
59
) ) }
100
60
{ remainingDocuments . length > 0 && (
@@ -114,9 +74,10 @@ export const useSelectedDocumentsUI = () =>
114
74
</ h2 >
115
75
< div className = "flex flex-wrap gap-2" >
116
76
{ documents . map ( ( document , docIndex ) => (
117
- < DocumentCardTooltip
77
+ < DocumentDialog
118
78
key = { `all-documents-${ docIndex } ` }
119
79
document = { document }
80
+ trigger = { < DocumentCard document = { document } /> }
120
81
/>
121
82
) ) }
122
83
</ div >
0 commit comments