feat(sidebar): drag-and-drop reordering of threads within a project#3069
feat(sidebar): drag-and-drop reordering of threads within a project#3069TheIcarusWings wants to merge 1 commit into
Conversation
Add a "Manual" thread sort mode that lets you drag a thread row to reorder it among the other threads in the same project, mirroring the existing project-reorder pattern. - contracts: add "manual" to SidebarThreadSortOrder - threadSort: sortThreads returns input order for "manual" so a user-defined order can be layered on top (matches sortProjectsForSidebar) - uiStateStore: persist threadOrderByProject directly (thread keys are stable, no id->cwd remapping); add reorderThreads action and prune stale keys / empty projects in syncThreads - Sidebar: per-project DndContext + SortableContext + SortableThreadItem when manual sort is active; suppress click/multi-select/rename during drag; apply the order via orderItemsByPreferredIds and auto-expand the full list Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 83326f5. Configure here.
| // user-defined order on top via `orderItemsByPreferredIds`. | ||
| if (sortOrder === "manual") { | ||
| return [...threads]; | ||
| } |
There was a problem hiding this comment.
Manual sort ignores persisted order
Medium Severity
With sidebarThreadSortOrder set to manual, helpers that pick a thread via sortThreads still use raw store order instead of threadOrderByProject. Delete fallback and opening a project from search can navigate to a thread that is not first in the sidebar’s manual list.
Reviewed by Cursor Bugbot for commit 83326f5. Configure here.
ApprovabilityVerdict: Needs human review This PR introduces a complete new feature (drag-and-drop thread reordering) with new components, state management, and persistence logic. New user-facing features warrant human review. Additionally, there's an unresolved comment identifying a potential bug with manual sort order handling. You can customize Macroscope's approvability policy. Learn more. |


What
Adds drag-and-drop reordering of threads within their project in the sidebar — grab a thread row and move it among the other threads in the same project. This is reordering within one project, not moving threads between projects. It mirrors the existing project-reorder pattern (same
@dnd-kitsetup, same client-side persistence model).Changes
"manual"toSidebarThreadSortOrder(alongsideupdated_at/created_at), matchingSidebarProjectSortOrder. New "Manual" option in the "Sort threads" menu.sortThreadsreturns input order for"manual", so the user-defined order is layered on top viaorderItemsByPreferredIds(same shape assortProjectsForSidebar).threadOrderByProject: Record<projectKey, threadKey[]>. BecausescopedThreadKeyis stable, it persists directly tolocalStorage(no id→cwd remapping like projects need). NewreorderThreadsaction;syncThreadsprunes stale thread keys and drops emptied projects.DndContext+SortableContext+SortableThreadItemrendered only when manual sort is active (non-DnD fallback otherwise).dragInProgress/suppressClickAfterDragrefs guard click, cmd/shift multi-select and rename so they don't fire on a drag. Manual mode auto-expands the full list (skips preview slicing / "Show more") so the whole list is reorderable; auto-animate stays attached.The order map is keyed per project now but keyed so it extends naturally to user-defined groups once folders land.
Verification
tsgo --noEmitpasses (web + contracts).🤖 Generated with Claude Code
Note
Low Risk
Client-only sidebar UX and localStorage; follows the existing project manual-sort pattern with unit tests for store and persistence.
Overview
Adds manual thread sorting in the sidebar: a new Manual option under sort threads (contracts +
sortThreads), with drag-and-drop reordering within each project when that mode is active.Persistence:
threadOrderByProjectinuiStateStore(per logical project key),reorderThreads, localStorage round-trip, andsyncThreadspruning of removed threads/projects.UI: Per-project
@dnd-kit(SortableThreadItem, row drag handles, click suppression after drag, renamepointerDownguard). Manual mode shows the full thread list (no preview / Show more) and keeps thread-jump / prewarm order aligned with the visible list in the rootSidebar.Reviewed by Cursor Bugbot for commit 83326f5. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add drag-and-drop manual reordering of threads within a project in the sidebar
'manual'sort order option toSidebarThreadSortOrderin settings.ts; thread rows become draggable with visual feedback when this mode is active.DndContext/SortableContext(via a newSortableThreadItemcomponent) with vertical constraints and custom collision detection when manual sorting is enabled.threadOrderByProjectvialocalStorage;syncThreadsprunes stale entries when threads are deleted.handleThreadClicksuppresses navigation during and immediately after a drag, which could feel unresponsive if drag detection fires on short taps.Macroscope summarized 83326f5.