|
1 | 1 | import { useState, useRef, useEffect } from 'react'; |
2 | | -import { Send, Loader2, Lightbulb } from 'lucide-react'; |
| 2 | +import { Send, Loader2, Lightbulb, ChevronRight } from 'lucide-react'; |
3 | 3 | import { Button } from '@/components/ui/button'; |
4 | 4 | import { Textarea } from '@/components/ui/textarea'; |
5 | 5 | import { ScrollArea } from '@/components/ui/scroll-area'; |
6 | 6 | import { Card } from '@/components/ui/card'; |
7 | 7 | import { Badge } from '@/components/ui/badge'; |
| 8 | +import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible'; |
8 | 9 | import { Message } from '@/types/chat'; |
9 | 10 | import { sendChatMessage, sendChatMessageStream } from '@/services/api'; |
10 | 11 | import { useSettings } from '@/hooks/use-settings'; |
@@ -198,16 +199,28 @@ export function ChatInterface({ onCitationClick }: ChatInterfaceProps) { |
198 | 199 | {message.citations && message.citations.length > 0 && ( |
199 | 200 | <div className="mt-3 pt-3 border-t border-border/50"> |
200 | 201 | <p className="text-xs font-medium mb-2 opacity-70">Citations:</p> |
201 | | - <div className="flex flex-wrap gap-2"> |
| 202 | + <div className="space-y-2"> |
202 | 203 | {message.citations.map((citation, idx) => ( |
203 | | - <Badge |
204 | | - key={idx} |
205 | | - variant="secondary" |
206 | | - className="cursor-pointer hover:bg-secondary/80 transition-colors" |
207 | | - onClick={() => onCitationClick(citation.page + 4, citation.position)} |
208 | | - > |
209 | | - Page {citation.page + 4}: {citation.text} |
210 | | - </Badge> |
| 204 | + <Collapsible key={idx} className="border rounded-md"> |
| 205 | + <CollapsibleTrigger className="w-full flex items-center justify-between p-2 hover:bg-secondary/50 transition-colors rounded-t-md [&[data-state=open]>div>svg]:rotate-90"> |
| 206 | + <div className="flex items-center gap-2"> |
| 207 | + <ChevronRight className="h-4 w-4 transition-transform duration-200" /> |
| 208 | + <Badge |
| 209 | + variant="secondary" |
| 210 | + className="cursor-pointer" |
| 211 | + onClick={(e) => { |
| 212 | + e.stopPropagation(); |
| 213 | + onCitationClick(citation.page + 4, citation.position); |
| 214 | + }} |
| 215 | + > |
| 216 | + Page {citation.page + 4} |
| 217 | + </Badge> |
| 218 | + </div> |
| 219 | + </CollapsibleTrigger> |
| 220 | + <CollapsibleContent className="px-4 pb-2 pt-1"> |
| 221 | + <p className="text-sm text-muted-foreground">{citation.text}</p> |
| 222 | + </CollapsibleContent> |
| 223 | + </Collapsible> |
211 | 224 | ))} |
212 | 225 | </div> |
213 | 226 | </div> |
|
0 commit comments