gui: fix channel sort order (#17) #20

Merged
restitux merged 4 commits from fix-channel-order into main 2026-01-25 19:10:18 +00:00
Owner

Summary

Channel ordering is currently broken as described in #17. This change makes sorting work correctly and cleans up the logic a bit.

Changes

  • creates a ChannelsState wrapper struct to handle this behavior
  • moves the logic for handling ChannelState processing, including data update and parent-child tree sorting, into the impl for ChannelsState
  • moves the logic for handling ChannelRemove into this impl

Parent child sorting properly applies the position values, which are arbitrary integers that are supposed to be sorted in numerical order. Lexicographical sorting is use for tiebreaking, which lines up (at least in my testing) with the official client's behavior. We may handle some lexicographical edge cases differently (spaces, symbols, etc) but 1. the Desktop client compliance is best effort and 2. users should use the position fields instead of relying on text sort order. Some compatibility is still helpful for matching temporary channel positioning, especially for servers with automated channel creation workflows.

This code is a bit complicated, as the mumble protocol makes no guarantees which order the channels will be sent. It ended up being simpler to just bulk recreate the children anytime any channel update is sent. I don't expect this to ever have performance issues, though maybe someday some server with 10,000 channels will send us a bug report 😆

Testing

I tested this change by creating a bunch of channel with various sort orders and names. I compared the behavior with the official desktop client and our client seemed to follow along.

# Summary Channel ordering is currently broken as described in #17. This change makes sorting work correctly and cleans up the logic a bit. # Changes - creates a `ChannelsState` wrapper struct to handle this behavior - moves the logic for handling `ChannelState` processing, including data update and parent-child tree sorting, into the impl for `ChannelsState` - moves the logic for handling `ChannelRemove` into this impl Parent child sorting properly applies the position values, which are arbitrary integers that are supposed to be sorted in numerical order. Lexicographical sorting is use for tiebreaking, which lines up (at least in my testing) with the official client's behavior. We may handle some lexicographical edge cases differently (spaces, symbols, etc) but 1. the Desktop client compliance is best effort and 2. users should use the position fields instead of relying on text sort order. Some compatibility is still helpful for matching temporary channel positioning, especially for servers with automated channel creation workflows. This code is a bit complicated, as the mumble protocol makes no guarantees which order the channels will be sent. It ended up being simpler to just bulk recreate the children anytime any channel update is sent. I don't expect this to ever have performance issues, though maybe someday some server with 10,000 channels will send us a bug report 😆 # Testing I tested this change by creating a bunch of channel with various sort orders and names. I compared the behavior with the official desktop client and our client seemed to follow along.
restitux added 2 commits 2026-01-25 09:30:52 +00:00
gui: fix channel ordering
Build Mumble Web 2 / linux_build (push) Successful in 1m25s
Build Mumble Web 2 / windows_build (push) Successful in 2m41s
Build Mumble Web 2 / android_build (push) Successful in 5m58s
53a0ad0125
cleanup and fix sorting
Build Mumble Web 2 / linux_build (push) Successful in 1m26s
Build Mumble Web 2 / windows_build (push) Successful in 2m45s
Build Mumble Web 2 / android_build (push) Successful in 5m55s
8fcf780beb
liamwarfield reviewed 2026-01-25 16:45:21 +00:00
liamwarfield left a comment
Owner

Overall LGTM.

Overall LGTM.
@@ -94,8 +86,121 @@ pub struct Chat {
}
#[derive(Default)]
Owner

Note unrelated to this PR: We should consider adding derive(Debug) to a lot of our structs to make logging easier in the future.

Note unrelated to this PR: We should consider adding `derive(Debug)` to a lot of our structs to make logging easier in the future.
restitux marked this conversation as resolved
gui/src/app.rs Outdated
@@ -98,0 +95,4 @@
}
impl ChannelState {
pub fn update_from_ChannelState(
Owner

Nit: not snake case

Nit: not snake case
restitux marked this conversation as resolved
gui/src/app.rs Outdated
@@ -99,0 +145,4 @@
let mut to_sort: Vec<(ChannelId, Option<ChannelId>, i32, String)> = Vec::new();
for (id, state) in self.channels.iter() {
// Hnadle channels with no parent (the root channel)
Owner

Nit: Hnadle -> Handle

Nit: Hnadle -> Handle
restitux marked this conversation as resolved
restitux added 1 commit 2026-01-25 18:35:31 +00:00
change to snake case
Build Mumble Web 2 / android_build (push) Has been cancelled
Build Mumble Web 2 / windows_build (push) Has been cancelled
Build Mumble Web 2 / linux_build (push) Has been cancelled
61eea0a858
restitux added 1 commit 2026-01-25 18:35:56 +00:00
typo fix
Build Mumble Web 2 / linux_build (push) Successful in 1m25s
Build Mumble Web 2 / windows_build (push) Successful in 2m41s
Build Mumble Web 2 / android_build (push) Successful in 5m57s
b22bdff949
restitux merged commit feaa9f2bda into main 2026-01-25 19:10:18 +00:00
restitux deleted branch fix-channel-order 2026-01-25 19:10:18 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mumble/mumble-web2#20