From e0b233414bc6b67243167c498d405398a5f6695f Mon Sep 17 00:00:00 2001 From: Lafnaps <177272356+Lafnaps@users.noreply.github.com> Date: Sat, 1 Aug 2026 15:37:16 +0300 Subject: [PATCH] fix(ui): keep unread badges, mention toggles, and pending switches across a channel rename --- static/chat.js | 19 +++++++++++++++++++ static/index.html | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/static/chat.js b/static/chat.js index 338653c..bf77096 100644 --- a/static/chat.js +++ b/static/chat.js @@ -527,6 +527,23 @@ function connectWebSocket() { }); _showNextPendingName(); } else if (event.type === 'channel_renamed') { + // Migrate per-channel client state to the new name + const channelIndex = channelList.indexOf(event.old_name); + if (channelIndex !== -1) { + channelList = [...channelList]; + channelList[channelIndex] = event.new_name; + } + if (channelUnread[event.old_name] !== undefined) { + channelUnread[event.new_name] = channelUnread[event.old_name]; + delete channelUnread[event.old_name]; + } + if (_channelMentions[event.old_name] !== undefined) { + _channelMentions[event.new_name] = _channelMentions[event.old_name]; + delete _channelMentions[event.old_name]; + } + if (pendingChannelSwitch === event.old_name) { + pendingChannelSwitch = event.new_name; + } // Migrate data-channel on existing DOM elements const container = document.getElementById('messages'); for (const el of container.children) { @@ -545,6 +562,8 @@ function connectWebSocket() { localStorage.setItem('agentchattr-channel', event.new_name); Store.set('activeChannel', event.new_name); } + filterMessagesByChannel(); + renderChannelTabs(); } else if (event.type === 'edit') { // A message was edited/demoted — re-render it in place const updatedMsg = event.message; diff --git a/static/index.html b/static/index.html index f015bf4..0e0d862 100644 --- a/static/index.html +++ b/static/index.html @@ -345,6 +345,6 @@