Skip to content

feat(desktop): add sorting to resource usage popover#3036

Merged
Kitenite merged 1 commit into
mainfrom
add-resource-usage-sorting
Mar 30, 2026
Merged

feat(desktop): add sorting to resource usage popover#3036
Kitenite merged 1 commit into
mainfrom
add-resource-usage-sorting

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Mar 30, 2026

Summary

  • Adds a sort dropdown to the resource usage popover header (next to the refresh button) with four options: Memory (default, high→low), CPU (high→low), Name (A→Z), and Sidebar order (matches left sidebar visual ordering)
  • Sorting applies to both project groups and individual workspaces within each group
  • Uses lightweight useLiveQuery calls on sidebar collections for the sidebar order option

Test plan

  • Open the resource usage popover via the CPU chip button in the top bar
  • Verify the sort dropdown appears next to the refresh button showing "Memory" by default
  • Switch between Memory, CPU, Name, and Sidebar order — confirm workspaces reorder correctly
  • Verify the sort dropdown menu closes properly and doesn't interfere with the popover
  • Confirm the refresh button still works as expected

Summary by cubic

Add a sort dropdown to the resource usage popover so you can sort projects and workspaces by Memory (default), CPU, Name, or Sidebar order. This makes it easier to spot heavy usage and mirror the left sidebar without affecting the refresh button.

  • New Features
    • Sort dropdown in the popover header (Memory high→low by default; also CPU, Name A→Z, Sidebar order).
    • Sorting applies to both project groups and their workspaces.
    • "Sidebar order" mirrors the left sidebar using useLiveQuery from @tanstack/react-db over v2SidebarProjects and v2WorkspaceLocalState.

Written for commit a24c62b. Summary will update on new commits.

Summary by CodeRabbit

  • New Features
    • Added workspace sorting to the Resource Usage dashboard. Users can now sort resource consumption data by memory usage, CPU usage, alphabetical name, or sidebar order through a new dropdown menu in the header. The existing refresh functionality remains intact and accessible.

Add a sort dropdown to the resource usage screen with four options:
Memory (default, descending), CPU (descending), Name (alphabetical),
and Sidebar order (matching the left sidebar's visual ordering).
Sorting applies to both project groups and workspaces within each group.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 30, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 061f4652-3917-473a-a567-0f769614c8e3

📥 Commits

Reviewing files that changed from the base of the PR and between 3194568 and a24c62b.

📒 Files selected for processing (3)
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/TopBar/components/ResourceConsumption/ResourceConsumption.tsx
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/TopBar/components/ResourceConsumption/components/WorkspaceResourceSection/WorkspaceResourceSection.tsx
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/TopBar/components/ResourceConsumption/types.ts

📝 Walkthrough

Walkthrough

These changes implement a workspace and project sorting feature in the Resource Consumption component. A sort dropdown control was added to the header, offering options to sort by memory, CPU, name, or sidebar order. New sorting functions were introduced to reorder both workspaces and project groups based on the selected option, utilizing live sidebar ordering data.

Changes

Cohort / File(s) Summary
Sorting Logic Implementation
apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/TopBar/components/ResourceConsumption/components/WorkspaceResourceSection/WorkspaceResourceSection.tsx
Expanded props to accept sortOption, sidebarProjectOrder, and sidebarWorkspaceOrder. Implemented sortWorkspaces() and sortProjectGroups() functions to reorder workspaces and project groups based on memory, CPU, name, or sidebar criteria. Updated component to apply sorting before rendering.
Sort Control UI
apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/TopBar/components/ResourceConsumption/ResourceConsumption.tsx
Added sortOption state and dropdown menu (DropdownMenuRadioGroup) in header. Integrated useLiveQuery to fetch sidebar order data for projects and workspaces. Replaced header layout with combined sort dropdown and refresh button. Passed sorting configuration props to WorkspaceResourceSection.
Type Definition
apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/TopBar/components/ResourceConsumption/types.ts
Added new exported type SortOption with allowed values: memory, cpu, name, or sidebar.

Sequence Diagram

sequenceDiagram
    actor User
    participant RC as ResourceConsumption
    participant WRS as WorkspaceResourceSection
    participant SortFns as Sorting Functions

    User->>RC: Select sort option from dropdown
    RC->>RC: Update sortOption state
    RC->>RC: Fetch sidebar order via useLiveQuery
    RC->>WRS: Pass sortOption + sidebar order props
    WRS->>SortFns: Call sortProjectGroups()
    SortFns->>SortFns: Reorder project groups by selected criteria
    WRS->>SortFns: Call sortWorkspaces() per project
    SortFns->>SortFns: Reorder workspaces by selected criteria
    WRS->>WRS: Render sorted workspaces and projects
    WRS-->>User: Display sorted resource usage
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Hop, hop, organizing with care!
Workspaces sorted through the air—
By memory, CPU, name or sidebar stack,
Order restored, no chaos to track!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-resource-usage-sorting

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Kitenite Kitenite merged commit 30b2f31 into main Mar 30, 2026
6 of 7 checks passed
@Kitenite Kitenite deleted the add-resource-usage-sorting branch March 30, 2026 20:01
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 3 files

@github-actions
Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch
  • ⚠️ Electric Fly.io app

Thank you for your contribution! 🎉

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