MCPcopy Create free account
hub / github.com/cyberagiinc/DevDocs / DebugOutput

Function DebugOutput

components/DebugOutput.tsx:10–185  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8import PlayArrowIcon from '@mui/icons-material/PlayArrow'
9
10export default function DebugOutput() {
11 const [output, setOutput] = useState<string>('')
12 const [error, setError] = useState<string | null>(null)
13 const [isLoading, setIsLoading] = useState(false)
14 const [lastUpdated, setLastUpdated] = useState<Date | null>(null)
15 const [scriptContent, setScriptContent] = useState<string | null>(null)
16 const [showScript, setShowScript] = useState(false)
17
18 // Function to fetch the script content
19 const fetchScriptContent = async () => {
20 try {
21 const response = await fetch('/api/script-content?name=debug_crawl4ai.sh')
22
23 if (!response.ok) {
24 console.error('Failed to fetch script content:', response.statusText)
25 return
26 }
27
28 const data = await response.json()
29
30 if (data.success && data.content) {
31 setScriptContent(data.content)
32 } else {
33 console.error('Invalid script content response:', data.error || 'Unknown error')
34 }
35 } catch (error) {
36 console.error('Error fetching script content:', error)
37 }
38 }
39
40 const fetchDebugOutput = async () => {
41 setIsLoading(true)
42 setError(null)
43
44 try {
45 const response = await fetch('/api/debug')
46
47 if (!response.ok) {
48 const errorData = await response.json()
49 throw new Error(errorData.error || 'Failed to fetch debug output')
50 }
51
52 const data = await response.json()
53
54 if (!data.success) {
55 throw new Error(data.error || 'Failed to execute debug script')
56 }
57
58 setOutput(data.output || 'No output returned')
59 if (data.error) {
60 setError(data.error)
61 }
62 setLastUpdated(new Date())
63 } catch (error) {
64 console.error('Error fetching debug output:', error)
65 setError(error instanceof Error ? error.message : 'Failed to fetch debug output')
66 setOutput('')
67

Callers

nothing calls this directly

Calls 1

fetchDebugOutputFunction · 0.85

Tested by

no test coverage detected