Spaces:
Sleeping
Sleeping
Ken Sang Tang commited on
Create test-events.html
Browse files- templates/test-events.html +55 -0
templates/test-events.html
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<title>Task SSE Debug Viewer</title>
|
| 6 |
+
<style>
|
| 7 |
+
body { font-family: sans-serif; padding: 20px; }
|
| 8 |
+
textarea { width: 100%; height: 300px; }
|
| 9 |
+
input { width: 400px; }
|
| 10 |
+
</style>
|
| 11 |
+
</head>
|
| 12 |
+
<body>
|
| 13 |
+
<h1>🧪 SSE Task Event Stream Viewer</h1>
|
| 14 |
+
|
| 15 |
+
<label for="taskId">Enter Task ID:</label>
|
| 16 |
+
<input id="taskId" type="text" placeholder="Paste task ID here" />
|
| 17 |
+
<button onclick="startListening()">Start Listening</button>
|
| 18 |
+
|
| 19 |
+
<h2>📡 Event Stream</h2>
|
| 20 |
+
<textarea id="log" readonly></textarea>
|
| 21 |
+
|
| 22 |
+
<script>
|
| 23 |
+
let eventSource;
|
| 24 |
+
function startListening() {
|
| 25 |
+
const taskId = document.getElementById("taskId").value.trim();
|
| 26 |
+
if (!taskId) return alert("Please enter a task ID");
|
| 27 |
+
|
| 28 |
+
const logArea = document.getElementById("log");
|
| 29 |
+
logArea.value = "";
|
| 30 |
+
const url = `/tasks/${taskId}/events`;
|
| 31 |
+
|
| 32 |
+
if (eventSource) eventSource.close();
|
| 33 |
+
eventSource = new EventSource(url);
|
| 34 |
+
|
| 35 |
+
eventSource.onmessage = (e) => {
|
| 36 |
+
logArea.value += `📩 message: ${e.data}\n`;
|
| 37 |
+
logArea.scrollTop = logArea.scrollHeight;
|
| 38 |
+
};
|
| 39 |
+
|
| 40 |
+
eventSource.onerror = (e) => {
|
| 41 |
+
logArea.value += `❌ error connecting or stream ended\n`;
|
| 42 |
+
eventSource.close();
|
| 43 |
+
};
|
| 44 |
+
|
| 45 |
+
const events = ["think", "tool", "act", "run", "result", "error", "status", "complete"];
|
| 46 |
+
events.forEach(evt => {
|
| 47 |
+
eventSource.addEventListener(evt, (e) => {
|
| 48 |
+
logArea.value += `📡 ${evt}: ${e.data}\n`;
|
| 49 |
+
logArea.scrollTop = logArea.scrollHeight;
|
| 50 |
+
});
|
| 51 |
+
});
|
| 52 |
+
}
|
| 53 |
+
</script>
|
| 54 |
+
</body>
|
| 55 |
+
</html>
|