Skip to content

fix(desktop): align v2 sidebar shortcuts with rendered project order#4193

Merged
saddlepaddle merged 1 commit into
mainfrom
fix-project-switcher-orde
May 7, 2026
Merged

fix(desktop): align v2 sidebar shortcuts with rendered project order#4193
saddlepaddle merged 1 commit into
mainfrom
fix-project-switcher-orde

Conversation

@saddlepaddle
Copy link
Copy Markdown
Collaborator

@saddlepaddle saddlepaddle commented May 7, 2026

Summary

  • Project shortcuts (⌘1–⌘9) were indexed off the live-query groups, so after a drag reorder they kept the original order until the persisted tabOrder write round-tripped — pressing ⌘1/⌘2/⌘3 jumped 1 → 3 → 2.
  • Drive useDashboardSidebarShortcuts off orderedGroups (the same locally-applied order the sidebar renders) so shortcuts track the visible layout immediately.

Test plan

  • Open desktop app with ≥3 projects, drag a project to a new position
  • Verify ⌘1 / ⌘2 / ⌘3 jump to the workspaces in the visible top-to-bottom order, not the pre-drag order
  • Verify shortcut labels next to each workspace match the new order

Summary by cubic

Fixes v2 sidebar shortcuts (⌘1–⌘9) to follow the visible project order immediately after drag reordering. Shortcuts and labels now match the rendered layout by using orderedGroups instead of live groups.

  • Bug Fixes
    • Drive useDashboardSidebarShortcuts from orderedGroups so shortcuts reflect the locally rendered order.
    • Prevents jumps like 1 → 3 → 2 after reordering; labels and navigation now match top-to-bottom order.

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

Summary by CodeRabbit

  • Bug Fixes
    • Fixed sidebar shortcut labels to remain synchronized with the reordered project list when users reorganize items.

Project shortcuts (⌘1–⌘9) were indexed off the live-query groups, so
after a drag reorder they kept the original order until the persisted
tabOrder write round-tripped — pressing ⌘1/⌘2/⌘3 jumped 1 → 3 → 2.
Drive shortcuts off orderedGroups (the same locally-applied order the
sidebar renders) so they track the visible layout immediately.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 7, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ea810c3c-6938-4a94-ac87-a7c33c1ebdbd

📥 Commits

Reviewing files that changed from the base of the PR and between cd55568 and ed12852.

📒 Files selected for processing (1)
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/DashboardSidebar.tsx

📝 Walkthrough

Walkthrough

DashboardSidebar refactors initialization order so that workspaceShortcutLabels is computed after orderedGroups and derived from the reordered groups list, ensuring shortcut labels reflect the current drag-drop-reordered sidebar state.

Changes

Sidebar Shortcut Label Ordering

Layer / File(s) Summary
Shortcut Label Derivation
apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/DashboardSidebar.tsx
Move workspaceShortcutLabels initialization after orderedGroups is computed and derive it from orderedGroups instead of groups.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 Labels were lost in the shuffled reorder,
Now they follow the drag-drop border,
Groups align with their ordered kin,
Shortcuts sync with a logical spin! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: aligning sidebar shortcuts with the rendered project order after drag reordering.
Description check ✅ Passed The description includes a clear summary of the bug, the fix approach, and a comprehensive test plan, though it lacks explicit sections matching the template.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 fix-project-switcher-orde

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.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 7, 2026

Greptile Summary

This PR fixes a shortcut-order mismatch in the desktop sidebar: keyboard shortcuts (⌘1–⌘9, PREV/NEXT workspace) were derived from the raw server-backed groups array instead of orderedGroups, the locally-sorted list that the DnD layer renders. After a drag reorder, shortcuts reflected the old server order until the persisted write round-tripped.

  • useDashboardSidebarShortcuts is now called with orderedGroups so shortcut targets and labels are immediately consistent with the visible layout after any drag.
  • PREV_WORKSPACE / NEXT_WORKSPACE navigation also benefits since they traverse the same flattenedWorkspaces derived from the passed-in array.

Confidence Score: 5/5

Safe to merge — the change is a single two-line move of one hook call, and the hook it now receives (orderedGroups) is the same memoized value already used to render the sidebar list.

The fix is minimal and correct: orderedGroups is already computed before the hook call and represents the drag-aware order that the renderer uses, so shortcuts and navigation now stay in sync with what the user sees. No new state, no new side-effects, and no other call sites are affected.

No files require special attention.

Important Files Changed

Filename Overview
apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/DashboardSidebar.tsx Moves useDashboardSidebarShortcuts call to receive orderedGroups (the locally-sorted list used by the DnD renderer) instead of the raw server-backed groups, so ⌘1–⌘9, PREV_WORKSPACE, and NEXT_WORKSPACE all track the visible order immediately after a drag.

Sequence Diagram

sequenceDiagram
    participant User
    participant DashboardSidebar
    participant DndContext
    participant projectOrder_state as projectOrder (state)
    participant orderedGroups_memo as orderedGroups (memo)
    participant useDashboardSidebarShortcuts

    User->>DndContext: drag project to new position
    DndContext->>DashboardSidebar: onDragEnd(active, over)
    DashboardSidebar->>projectOrder_state: setProjectOrder(arrayMove(...))
    projectOrder_state-->>orderedGroups_memo: recompute (same render cycle)
    orderedGroups_memo-->>useDashboardSidebarShortcuts: updated order passed in
    useDashboardSidebarShortcuts-->>User: ⌘1–⌘9 / labels now reflect visible order immediately

    Note over DashboardSidebar,useDashboardSidebarShortcuts: Before fix: shortcuts read raw groups (server order). After fix: shortcuts read orderedGroups (local drag order)
Loading

Reviews (1): Last reviewed commit: "fix(desktop): align v2 sidebar shortcuts..." | Re-trigger Greptile

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 1 file

@saddlepaddle saddlepaddle merged commit 3ee7fee into main May 7, 2026
10 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch

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