Skip to content

Add the ability to reorder favorited collab channels#52649

Merged
JosephTLyons merged 15 commits intomainfrom
fix-favorite-channel-reordering
Mar 30, 2026
Merged

Add the ability to reorder favorited collab channels#52649
JosephTLyons merged 15 commits intomainfrom
fix-favorite-channel-reordering

Conversation

@JosephTLyons
Copy link
Copy Markdown
Collaborator

@JosephTLyons JosephTLyons commented Mar 29, 2026

Currently, if you try to re-order a favorite, the favorite will not reorder, but the actual channels will.

reorder_favorites_bug.mov

Additionally, a new bug seems to be that if you reorder channels, focus jumps to a favorite:

reordering_non_favorites_bug.mov

This PR allows for re-ordering of favorites independent of the actual channels, and fixes the focusing bug

reorder_favorites_fix.mov

I didn't feel comfortable adding just the functionality/fixes alone, so I added a function to represent the state of the collab panel as a list of strings, like how testing around the project panel is, and wrote a few tests to ensure the behavior was pinned down.

The tests cover testing:

  • Favoriting/unfavoriting
  • Reordering favorites without impacting order of channels in the channels list
  • Reordering channels in the channels list without impacting order of favorites

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content is consistent with the UI/UX checklist
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Closes #ISSUE

Release Notes:

  • Added the ability to reorder favorited collab channels.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Mar 29, 2026
@zed-community-bot zed-community-bot bot added the staff Pull requests authored by a current member of Zed staff label Mar 29, 2026
@JosephTLyons JosephTLyons marked this pull request as ready for review March 29, 2026 08:00
@zed-codeowner-coordinator zed-codeowner-coordinator bot requested review from a team, kubkon and reflectronic and removed request for a team March 29, 2026 08:01
…rdering

- Add is_favorite field to ListEntry::Channel to distinguish favorite
  entries from normal channel entries
- Update PartialEq to include is_favorite so selection restoration after
  reorder finds the correct entry instead of jumping to the favorites
  section
- Allow reordering favorites independently via opt+up/down by swapping
  positions in the local favorite_channels vec
- Switch favorite_channels from sorted (binary_search) to user-ordered
  (linear search) to support custom ordering
- Add entries_as_strings() method on CollabPanel for snapshot-style
  test assertions, gated behind cfg(test/test-support)
- Add test_favorite_channels: tests favoriting, reordering favorites,
  boundary no-ops, and unfavoriting while asserting the Channels section
  never changes
- Add test_reorder_channels_does_not_affect_favorites: tests server-side
  channel reorder while asserting the Favorites section is unchanged
Drive tests through SelectNext, SelectPrevious, ToggleSelectedChannelFavorite,
MoveChannelUp, and MoveChannelDown to exercise the real user flow. Selection
is now tracked and asserted at each step.
When a selected favorite was unfavorited, the selection was lost because
the PartialEq change made favorite and non-favorite entries distinct.
Now toggle_favorite_channel detects this case and moves the selection to
the same channel in the Channels section.
On main, toggle_favorite_channel delegates to the channel store which
notifies observers. The panel's observer calls update_entries, but this
is deferred until after toggle_favorite_channel returns. The selection
fix for unfavoriting needs entries to be rebuilt before checking
self.selection.is_none(), so we call update_entries explicitly.
@JosephTLyons JosephTLyons force-pushed the fix-favorite-channel-reordering branch from 8f970d3 to 20f99e4 Compare March 30, 2026 12:27
When update_entries can't find the previously selected entry, clamp
to the same index instead of leaving selection as None. This handles
entry removal generically (including unfavoriting) without needing
special-case logic in toggle_favorite_channel.
@JosephTLyons JosephTLyons enabled auto-merge (squash) March 30, 2026 13:00
@JosephTLyons JosephTLyons merged commit 6431558 into main Mar 30, 2026
30 checks passed
@JosephTLyons JosephTLyons deleted the fix-favorite-channel-reordering branch March 30, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants