Spaces:
Sleeping
Sleeping
Commit ·
1434869
1
Parent(s): 88bc1d5
Show genuine real-time connected device count in badge
Browse files531 unmodified lines532533534535536537538288 unmodified lines82782882983083183283383483583683783883995 unmodified lines935936937938939940941942943944945946531 unmodified lines<span class="brand-title">FALL</span></a><div class="nav-pills"><span class="pill-badge"><span class="pulse-dot"></span> <span id="sync-text">Synchronized</span></span><span class="fuel-pill">⛽ <span id="top-fuel-bal">50.0000</span> FUEL</span></div></header>288 unmodified linesws = new WebSocket(`${proto}//${window.location.host}/ws`);ws.onopen = () => {document.getElementById('sync-text').innerText = 'Synchronized';};ws.onmessage = (event) => {const data = JSON.parse(event.data);if (data.type === 'token') {if (currentAiBubbleContent) {currentAiBubbleContent.textContent += data.token;chatBox.scrollTop = chatBox.scrollHeight;95 unmodified linesasync def websocket_endpoint(websocket: WebSocket):await websocket.accept()connected_clients.append(websocket)try:while True:await websocket.receive_text()except WebSocketDisconnect:if websocket in connected_clients:connected_clients.remove(websocket)@app.post("/api/trigger")async def trigger_swarm_inference(req: Request):531 unmodified lines532533534535536537538288 unmodified lines82782882983083183283383483583683783883984084184284384484584684795 unmodified lines943944945946947948949950951952953954955956531 unmodified lines<span class="brand-title">FALL</span></a><div class="nav-pills"><span class="pill-badge"><span class="pulse-dot" id="pulse-dot"></span> <span id="sync-text">Connecting...</span></span><span class="fuel-pill">⛽ <span id="top-fuel-bal">50.0000</span> FUEL</span></div></header>288 unmodified linesws = new WebSocket(`${proto}//${window.location.host}/ws`);ws.onopen = () => {document.getElementById('sync-text').innerText = 'Connected';};ws.onclose = () => {document.getElementById('sync-text').innerText = 'Disconnected';setTimeout(connectWS, 2000);};ws.onmessage = (event) => {const data = JSON.parse(event.data);if (data.type === 'client_count') {const count = data.count || 1;document.getElementById('sync-text').innerText = count > 1 ? `Connected (${count} devices)` : 'Connected (1 device)';} else if (data.type === 'token') {if (currentAiBubbleContent) {currentAiBubbleContent.textContent += data.token;chatBox.scrollTop = chatBox.scrollHeight;95 unmodified linesasync def websocket_endpoint(websocket: WebSocket):await websocket.accept()connected_clients.append(websocket)await broadcast_event({"type": "client_count", "count": len(connected_clients)})try:while True:await websocket.receive_text()except WebSocketDisconnect:if websocket in connected_clients:connected_clients.remove(websocket)await broadcast_event({"type": "client_count", "count": len(connected_clients)})@app.post("/api/trigger")async def trigger_swarm_inference(req: Request):
scripts/run_client_ui.py+13-3