Spaces:
Runtime error
Runtime error
da03
commited on
Commit
·
38d7454
1
Parent(s):
cd4cdde
- dispatcher.py +4 -3
- static/index.html +3 -3
dispatcher.py
CHANGED
|
@@ -237,7 +237,7 @@ class SessionManager:
|
|
| 237 |
"type": "queue_update",
|
| 238 |
"position": i + 1,
|
| 239 |
"total_waiting": len(self.session_queue),
|
| 240 |
-
"
|
| 241 |
"active_sessions": active_sessions_count
|
| 242 |
})
|
| 243 |
except Exception as e:
|
|
@@ -355,8 +355,9 @@ async def websocket_endpoint(websocket: WebSocket):
|
|
| 355 |
try:
|
| 356 |
data = await websocket.receive_json()
|
| 357 |
|
| 358 |
-
# Update activity
|
| 359 |
-
|
|
|
|
| 360 |
|
| 361 |
# Handle different message types
|
| 362 |
if data.get("type") == "heartbeat":
|
|
|
|
| 237 |
"type": "queue_update",
|
| 238 |
"position": i + 1,
|
| 239 |
"total_waiting": len(self.session_queue),
|
| 240 |
+
"estimated_wait_seconds": estimated_wait,
|
| 241 |
"active_sessions": active_sessions_count
|
| 242 |
})
|
| 243 |
except Exception as e:
|
|
|
|
| 355 |
try:
|
| 356 |
data = await websocket.receive_json()
|
| 357 |
|
| 358 |
+
# Update activity only for real user inputs, not auto inputs
|
| 359 |
+
if not data.get("is_auto_input", False):
|
| 360 |
+
await session_manager.handle_user_activity(session_id)
|
| 361 |
|
| 362 |
# Handle different message types
|
| 363 |
if data.get("type") == "heartbeat":
|
static/index.html
CHANGED
|
@@ -280,9 +280,9 @@
|
|
| 280 |
console.log("Server detected user activity, resetting timeout");
|
| 281 |
stopTimeoutCountdown();
|
| 282 |
} else if (data.type === "queue_update") {
|
| 283 |
-
console.log(`Queue update: Position ${data.position}/${data.total_waiting}, estimated wait: ${data.
|
| 284 |
-
const
|
| 285 |
-
const waitText =
|
| 286 |
showConnectionStatus(
|
| 287 |
`Position ${data.position} in queue`,
|
| 288 |
`Estimated wait time: ${waitText}`
|
|
|
|
| 280 |
console.log("Server detected user activity, resetting timeout");
|
| 281 |
stopTimeoutCountdown();
|
| 282 |
} else if (data.type === "queue_update") {
|
| 283 |
+
console.log(`Queue update: Position ${data.position}/${data.total_waiting}, estimated wait: ${data.estimated_wait_seconds.toFixed(1)} seconds`);
|
| 284 |
+
const waitSeconds = Math.ceil(data.estimated_wait_seconds);
|
| 285 |
+
const waitText = waitSeconds === 1 ? "1 second" : `${waitSeconds} seconds`;
|
| 286 |
showConnectionStatus(
|
| 287 |
`Position ${data.position} in queue`,
|
| 288 |
`Estimated wait time: ${waitText}`
|