Spaces:
Sleeping
Sleeping
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Task SSE Debug Viewer</title> | |
| <style> | |
| body { font-family: sans-serif; padding: 20px; } | |
| textarea { width: 100%; height: 300px; } | |
| input { width: 400px; } | |
| </style> | |
| </head> | |
| <body> | |
| <h1>π§ͺ SSE Task Event Stream Viewer</h1> | |
| <label for="taskId">Enter Task ID:</label> | |
| <input id="taskId" type="text" placeholder="Paste task ID here" /> | |
| <button onclick="startListening()">Start Listening</button> | |
| <h2>π‘ Event Stream</h2> | |
| <textarea id="log" readonly></textarea> | |
| <script> | |
| let eventSource; | |
| function startListening() { | |
| const taskId = document.getElementById("taskId").value.trim(); | |
| if (!taskId) return alert("Please enter a task ID"); | |
| const logArea = document.getElementById("log"); | |
| logArea.value = ""; | |
| const url = `/tasks/${taskId}/events`; | |
| if (eventSource) eventSource.close(); | |
| eventSource = new EventSource(url); | |
| eventSource.onmessage = (e) => { | |
| logArea.value += `π© message: ${e.data}\n`; | |
| logArea.scrollTop = logArea.scrollHeight; | |
| }; | |
| eventSource.onerror = (e) => { | |
| logArea.value += `β error connecting or stream ended\n`; | |
| eventSource.close(); | |
| }; | |
| const events = ["think", "tool", "act", "run", "result", "error", "status", "complete"]; | |
| events.forEach(evt => { | |
| eventSource.addEventListener(evt, (e) => { | |
| logArea.value += `π‘ ${evt}: ${e.data}\n`; | |
| logArea.scrollTop = logArea.scrollHeight; | |
| }); | |
| }); | |
| } | |
| </script> | |
| </body> | |
| </html> | |