From 56b7bfb187b2439cd8a84a7683cf8d09990a7b08 Mon Sep 17 00:00:00 2001 From: Russell Ballestrini Date: Wed, 3 Jun 2026 10:43:15 -0400 Subject: [PATCH] zebra-spaces: send 'bye' on explicit leave so server skips hiccup grace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Matches signal commit 0547b4c. The leave button now sends a 'bye' message before closing the WS — the server distinguishes a strong leave from a hiccup, and we want the strong-leave path here. Without the bye, an explicit leave would defer peer-left for 8s and other peers would see the user's tiles + mesh PCs linger. --- web/zebra-spaces.html | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/web/zebra-spaces.html b/web/zebra-spaces.html index 88fc1f1..3f21c53 100644 --- a/web/zebra-spaces.html +++ b/web/zebra-spaces.html @@ -3813,7 +3813,16 @@ $('btn-leave').addEventListener('click', async () => { try { sessionStorage.removeItem(ACTIVE_CAM_KEY); } catch(_){} if (sigReconnect){ clearTimeout(sigReconnect); sigReconnect = null; } for (const u of [...peers.keys()]) tearPeer(u); - if (ws){ try { ws.close(); } catch(_){} ws = null; } + /* send 'bye' BEFORE closing the WS — server distinguishes a strong + * leave (user clicked leave / closed tab) from a hiccup disconnect + * (refresh, network blip). On bye, the server broadcasts peer-left + * immediately; without it, the server defers the broadcast behind an + * 8s grace so a refresh can rejoin invisibly. */ + if (ws){ + try { ws.send(JSON.stringify({ type: 'bye' })); } catch(_){} + try { ws.close(); } catch(_){} + ws = null; + } await sfuUnpublish(); await sfuUnpublishScreen(); await sfuUnpublishCamera(); await sfuUnsubscribe(); dropMic(); members.clear(); handraise.clear(); myUUID=''; myRole=''; hostUUID=''; outstandingInvite=null; @@ -3845,8 +3854,8 @@ logLine('', 'ready — pick a handle, type a rendezvous code, enter the space');