Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jul 20, 2025

Summary

This PR implements mode sorting by usage frequency as requested in #5975. The most frequently used modes will now appear at the top of the mode selection list, making it easier for users to quickly access their preferred modes.

Changes

  • Added mode usage tracking: Added modeUsageFrequency field to the global state schema to track how often each mode is used
  • Track usage on mode switch: Updated handleModeSwitch in ClineProvider to increment usage count when switching modes
  • Sort modes by frequency: Modified ModesView component to sort modes by usage frequency in descending order
  • Maintain stable ordering: When modes have equal usage frequency, they maintain their original order
  • Added comprehensive tests: Added tests for both the usage tracking logic and the sorting functionality

Implementation Details

  • Usage frequency is stored as a simple object mapping mode slugs to usage counts
  • The sorting algorithm prioritizes frequently used modes while maintaining stable ordering for modes with equal usage
  • Modes with no usage data appear after modes that have been used
  • The implementation is backward compatible - existing installations will start with no usage data and build it over time

Testing

  • Added tests in ClineProvider.spec.ts to verify mode usage tracking
  • Added tests in ModesView.spec.tsx to verify sorting behavior
  • All existing tests continue to pass

Fixes #5975


Important

This PR sorts modes by usage frequency, updating state management and UI components to enhance user experience.

  • Behavior:
    • Modes are sorted by usage frequency in ModesView.tsx, with most used modes appearing first.
    • Modes with equal frequency maintain original order.
    • Modes with no usage data appear last.
  • State Management:
    • Added modeUsageFrequency to ExtensionState in ExtensionStateContext.tsx.
    • Updated handleModeSwitch in ClineProvider.ts to track mode usage.
  • Testing:
    • Added tests in ModesView.spec.tsx for sorting logic.
    • Added tests in ClineProvider.spec.ts for usage tracking.
  • Misc:
    • Updated global-settings.ts to include modeUsageFrequency.

This description was created by Ellipsis for cdfd4f9. You can customize this summary. It will automatically update as commits are pushed.

- Add modeUsageFrequency tracking to global state schema
- Track mode usage when switching modes in ClineProvider
- Update ModesView to sort modes by usage frequency (descending)
- Add modeUsageFrequency to ExtensionState and context
- Add comprehensive tests for mode usage tracking and sorting

Fixes #5975
@roomote roomote bot requested review from cte, jr and mrubens as code owners July 20, 2025 04:18
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Jul 20, 2025
@roomote roomote bot mentioned this pull request Jul 20, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 20, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Jul 22, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jul 22, 2025
@daniel-lxs
Copy link
Member

I feel like it might be better to simply let the user order the modes in the modes list.

@daniel-lxs daniel-lxs closed this Jul 23, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jul 23, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Prelim Review] to Done in Roo Code Roadmap Jul 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request PR - Needs Preliminary Review size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Sort modes by usage frequency

4 participants