From e3211dd5368f2e09442b322423f43cc7be83bb91 Mon Sep 17 00:00:00 2001 From: MarekWo Date: Tue, 9 Jun 2026 18:07:04 +0200 Subject: [PATCH] fix(channels): don't render raw-resend button against a _pending_ id MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The optimistic-send path renders the bubble with msg.id = "_pending_" before the API confirms. The previous PR baked that string straight into onclick="resendChannelMessageRaw(_pending_, this)" — an undefined identifier — so the first click after sending threw ReferenceError and nothing happened. Skip the raw-resend button entirely while msg.id is non-numeric, then run a one-shot refreshMessagesMeta([real_id]) right after the optimistic id swap so the button shows up immediately even on channels where no echoes arrive (so the existing echo-driven inject path never fires). Co-Authored-By: Claude Opus 4.7 --- app/static/js/app.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/static/js/app.js b/app/static/js/app.js index 3c30982..0c442f5 100644 --- a/app/static/js/app.js +++ b/app/static/js/app.js @@ -1354,7 +1354,7 @@ function createMessageElement(msg) { - ${window.deviceCaps?.supports_raw_resend ? ` + ${window.deviceCaps?.supports_raw_resend && typeof msg.id === 'number' ? ` @@ -1464,7 +1464,14 @@ async function sendMessage() { // Replace optimistic ID with real DB id so echo WebSocket updates work if (data.id) { const wrapper = document.querySelector(`.message-wrapper[data-msg-id="${optimisticId}"]`); - if (wrapper) wrapper.dataset.msgId = data.id; + if (wrapper) { + wrapper.dataset.msgId = data.id; + // Inject the post-send action buttons (analyzer, raw resend) + // now — refreshMessagesMeta would otherwise skip this message + // until the first echo arrives, which never happens on + // channels with no repeaters in range. + refreshMessagesMeta([data.id]); + } } // Use server timestamp to prevent poll-triggered reload due to clock skew if (data.timestamp) {