diff --git a/frontend/src/components/source/SourceInsightDialog.tsx b/frontend/src/components/source/SourceInsightDialog.tsx index 6103e7d..9946277 100644 --- a/frontend/src/components/source/SourceInsightDialog.tsx +++ b/frontend/src/components/source/SourceInsightDialog.tsx @@ -2,9 +2,12 @@ import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog' import { Badge } from '@/components/ui/badge' +import { Button } from '@/components/ui/button' +import { FileText } from 'lucide-react' import ReactMarkdown from 'react-markdown' import remarkGfm from 'remark-gfm' import { useInsight } from '@/lib/hooks/use-insights' +import { useModalManager } from '@/lib/hooks/use-modal-manager' interface SourceInsightDialogProps { open: boolean @@ -14,10 +17,13 @@ interface SourceInsightDialogProps { insight_type?: string content?: string created?: string + source_id?: string } } export function SourceInsightDialog({ open, onOpenChange, insight }: SourceInsightDialogProps) { + const { openModal } = useModalManager() + // Ensure insight ID has 'source_insight:' prefix for API calls const insightIdWithPrefix = insight?.id ? (insight.id.includes(':') ? insight.id : `source_insight:${insight.id}`) @@ -28,17 +34,39 @@ export function SourceInsightDialog({ open, onOpenChange, insight }: SourceInsig // Use fetched data if available, otherwise fall back to passed-in insight const displayInsight = fetchedInsight ?? insight + // Get source_id from fetched data (preferred) or passed-in insight + const sourceId = fetchedInsight?.source_id ?? insight?.source_id + + const handleViewSource = () => { + if (sourceId) { + openModal('source', sourceId) + } + } + return ( Source Insight - {displayInsight?.insight_type && ( - - {displayInsight.insight_type} - - )} +
+ {displayInsight?.insight_type && ( + + {displayInsight.insight_type} + + )} + {sourceId && ( + + )} +