From dbde827f756ffeddebb6aac998ad5973723ef9aa Mon Sep 17 00:00:00 2001 From: prosolis <5590409+prosolis@users.noreply.github.com> Date: Tue, 14 Jul 2026 19:32:08 -0700 Subject: [PATCH] games: the chat line that shows up once, not twice MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Your own message came back twice — once from the POST that sent it, once echoed over your own SSE stream — so the felt printed it on the rail twice. Drop any chat id already seen; reset the seen-set when the log is cleared (unseated, and on a full chat reload). Claude-Session: https://claude.ai/code/session_013M5nD7PgUboJXoDcYHzpuJ --- internal/web/static/js/holdem.js | 9 +++++++++ internal/web/static/js/uno.js | 10 +++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/internal/web/static/js/holdem.js b/internal/web/static/js/holdem.js index 8ee12b2..9cdd199 100644 --- a/internal/web/static/js/holdem.js +++ b/internal/web/static/js/holdem.js @@ -62,6 +62,7 @@ var chatSection = root.querySelector("[data-chat]"); var chatLog = root.querySelector("[data-chat-log]"); + var chatSeen = {}; // chat line ids already on the rail, to drop echoed duplicates var chatForm = root.querySelector("[data-chat-form]"); var chatInput = root.querySelector("[data-chat-input]"); var lobbyWrap = root.querySelector("[data-lobby-wrap]"); @@ -734,6 +735,7 @@ function unseated() { disconnectLive(); if (chatLog) chatLog.innerHTML = ""; + chatSeen = {}; } function connectLive() { @@ -775,6 +777,7 @@ .then(function (data) { if (!data || !chatLog) return; chatLog.innerHTML = ""; + chatSeen = {}; (data.chat || []).forEach(addChat); }) .catch(function () {}); @@ -782,6 +785,12 @@ function addChat(line) { if (!chatLog || !line) return; + // Your own line comes back twice — once from the POST that sent it, once + // echoed over your own stream — so drop any id already on the rail. + if (line.id) { + if (chatSeen[line.id]) return; + chatSeen[line.id] = true; + } var row = document.createElement("div"); row.className = "pete-chat-line" + (line.mine ? " pete-chat-mine" : ""); var who = document.createElement("span"); diff --git a/internal/web/static/js/uno.js b/internal/web/static/js/uno.js index 58ecb52..72619ec 100644 --- a/internal/web/static/js/uno.js +++ b/internal/web/static/js/uno.js @@ -66,6 +66,7 @@ var tableMsg = root.querySelector("[data-table-msg]"); var chatLog = root.querySelector("[data-chat-log]"); + var chatSeen = {}; // chat line ids already on the rail, to drop echoed duplicates var chatForm = root.querySelector("[data-chat-form]"); var chatInput = root.querySelector("[data-chat-input]"); @@ -785,7 +786,7 @@ // ---- the live stream ------------------------------------------------------- function seated() { loadChat(); connectLive(); } - function unseated() { disconnectLive(); if (chatLog) chatLog.innerHTML = ""; } + function unseated() { disconnectLive(); if (chatLog) chatLog.innerHTML = ""; chatSeen = {}; } function connectLive() { if (stream || !window.EventSource) return; @@ -818,6 +819,7 @@ .then(function (data) { if (!data || !chatLog) return; chatLog.innerHTML = ""; + chatSeen = {}; (data.chat || []).forEach(addChat); }) .catch(function () {}); @@ -825,6 +827,12 @@ function addChat(line) { if (!chatLog || !line) return; + // Your own line comes back twice — once from the POST that sent it, once + // echoed over your own stream — so drop any id already on the rail. + if (line.id) { + if (chatSeen[line.id]) return; + chatSeen[line.id] = true; + } var row = document.createElement("div"); row.className = "pete-chat-line" + (line.mine ? " pete-chat-mine" : ""); var who = document.createElement("span");