Skip to content

Revert "opt: auto reorder channels, close #822 (#1005)"#1055

Merged
looplj merged 1 commit intorelease/v0.9.xfrom
dev
Mar 13, 2026
Merged

Revert "opt: auto reorder channels, close #822 (#1005)"#1055
looplj merged 1 commit intorelease/v0.9.xfrom
dev

Conversation

@looplj
Copy link
Copy Markdown
Owner

@looplj looplj commented Mar 13, 2026

This reverts commit 0594f3a.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request serves to revert a previous optimization that aimed to automatically reorder channels. By undoing the changes from commit 0594f3a, it restores the channel ordering functionality to its state before the automatic reordering was implemented. This ensures that channel weights are managed through a more explicit, relative calculation rather than a broad redistribution.

Highlights

  • Reverted Channel Reordering Logic: The pull request reverts the automatic channel reordering logic introduced in a previous commit, restoring the prior method of calculating channel ordering weights.
  • Removed redistributeWeights Function: The redistributeWeights function, which was responsible for automatically assigning weights across all channels, has been removed.
  • Reintroduced Relative Weight Calculation: The calculateRelativeWeight function, along with WEIGHT_PRECISION and formatWeight, has been reintroduced to handle more granular weight calculations when channels are moved or their weights are adjusted.
Changelog
  • frontend/src/features/channels/components/channels-bulk-ordering-dialog.tsx
    • Removed the redistributeWeights function.
    • Reintroduced WEIGHT_PRECISION, formatWeight, and calculateRelativeWeight for precise weight handling.
    • Updated channel movement and weight update logic to utilize calculateRelativeWeight instead of redistributeWeights.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request reverts a previous optimization for channel reordering. The redistributeWeights function, which re-calculated all channel weights on every move, is removed. It is replaced by a calculateRelativeWeight function that calculates a new weight for a moved item based on its immediate neighbors. While this is more performant, the implementation of calculateRelativeWeight has a flaw where it can cause weight collisions when items are moved, which may lead to a degradation of the ordering logic over time.

Comment on lines +24 to 38
const calculateRelativeWeight = (prev?: number, next?: number) => {
if (prev == null && next == null) {
return clampWeight(1);
}
if (prev == null) {
return clampWeight((next ?? 0) + 1);
}
if (next == null) {
return clampWeight(prev - 1);
}
if (prev === next) {
return clampWeight(prev);
}
return clampWeight(Math.floor((prev + next) / 2));
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The logic in calculateRelativeWeight can lead to weight collisions in several scenarios, which may degrade the ordering functionality over time as items clump together with the same weight.

  1. Middle items: When an item is moved between two items with consecutive integer weights (e.g., 10 and 9), Math.floor((10 + 9) / 2) results in 9, causing a collision with the lower-weighted item.
  2. Top item: When moving an item to the top of the list, if the current top item already has MAX_WEIGHT (100), the new item will also be assigned a weight of 100.
  3. Bottom item: Similarly, when moving an item to the bottom, if the current last item has MIN_WEIGHT (0), the new item will also get a weight of 0.

While this implementation might be an intentional trade-off (e.g., for performance, after reverting a full redistribution strategy), it's worth considering if these collisions are acceptable. Using floating-point weights would be a robust way to solve this, if feasible within the design.

@looplj looplj merged commit 67d3623 into release/v0.9.x Mar 13, 2026
2 checks passed
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