Skip to content

fix(ui): keep unread badges, mention toggles, and pending switches across a channel rename - #86

Open
Lafnaps wants to merge 1 commit into
bcurts:mainfrom
Lafnaps:fix/ui-channel-rename-state
Open

fix(ui): keep unread badges, mention toggles, and pending switches across a channel rename#86
Lafnaps wants to merge 1 commit into
bcurts:mainfrom
Lafnaps:fix/ui-channel-rename-state

Conversation

@Lafnaps

@Lafnaps Lafnaps commented Aug 1, 2026

Copy link
Copy Markdown

Rename a channel that has unread messages and its badge disappears. Reproducible on current main: let #foo accumulate unreads while you sit in #general, rename it to #bar from the tab — the badge is gone although the messages are still unread.

The channel_renamed handler in chat.js migrates DOM data-channel attributes, lastMessageDates, and activeChannel, but four pieces of state stay keyed under the old name: channelUnread (the count survives, invisible, under a key nothing reads anymore), _channelMentions (the per-channel mention toggle silently resets), channelList, and pendingChannelSwitch (a queued switch to the old name can never match again). The settings frame that accompanies a rename replaces channelList eventually, but it can't migrate unread/mention state it knows nothing about.

The handler now rekeys all four, retargets a pending switch to the new name so it can still resolve, and finishes with filterMessagesByChannel() + renderChannelTabs() so the tab re-renders with its migrated badge immediately. No protocol changes, no server changes; ?v= bumped for chat.js.

There's no JS harness in the repo, so this was verified against a live server with a scripted browser (fresh data dir, one registered agent posting into the renamed channel), running the same scenario on this branch and on main:

  • three unreads in #foo (badge "3"), rename to #bar → badge "3" on the #bar tab; on main the badge disappears and the count stays stranded under foo.
  • a mention toggle remembered for #foo is remembered for #bar after the rename; on main it resets.
  • a pending switch aimed at #foo gets retargeted to #bar; on main it stays aimed at a name that no longer exists.
  • no console errors on the patched page.

Python suite untouched by this change (static/ isn't imported): 81 passed before and after.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant