"use client"; import React, { useState } from 'react'; import { Bug, ChevronDown, ChevronUp, Copy, Trash2 } from 'lucide-react'; import { useDebug, DebugEntry } from '@/contexts/DebugContext'; interface DebugPanelProps { /** Optional: Filter to show only specific entry ID */ entryId?: string; /** Optional: Show inline next to content (default: false, shows as floating panel) */ inline?: boolean; } export default function DebugPanel({ entryId, inline = false }: DebugPanelProps) { const { isDebugMode, entries, clearEntries } = useDebug(); const [isExpanded, setIsExpanded] = useState(false); const [selectedEntry, setSelectedEntry] = useState(null); if (!isDebugMode) return null; const displayEntries = entryId ? entries.filter(e => e.id === entryId) : entries; const latestEntry = displayEntries[displayEntries.length - 1]; const copyToClipboard = (text: string) => { navigator.clipboard.writeText(text); }; const formatTimestamp = (timestamp: number) => { const date = new Date(timestamp); return date.toLocaleTimeString(); }; // Inline mode: Show icon next to content if (inline && latestEntry) { return (
{selectedEntry?.id === latestEntry.id && (
setSelectedEntry(null)}>
e.stopPropagation()}> setSelectedEntry(null)} />
)}
); } // Floating panel mode: Show all entries return (
{isExpanded && (
LLM Interactions
{entries.length === 0 ? (
No debug entries yet
) : (
{entries.map((entry) => ( ))}
)}
)}
{selectedEntry && (
setSelectedEntry(null)}>
e.stopPropagation()}> setSelectedEntry(null)} />
)}
); } function DebugEntryDetail({ entry, onClose }: { entry: DebugEntry; onClose: () => void }) { const copyToClipboard = (text: string) => { navigator.clipboard.writeText(text); }; return (

{entry.action}

{entry.type === 'tutor' ? '🎓 Tutor' : '📊 Analysis'} • {new Date(entry.timestamp).toLocaleString()}

Prompt

                    {entry.prompt}
                
{entry.response && (

Response

                        {entry.response}
                    
)} {entry.metadata && Object.keys(entry.metadata).length > 0 && (

Metadata

                        {JSON.stringify(entry.metadata, null, 2)}
                    
)}
); }