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 2 commits 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.
ApprovabilityVerdict: Needs human review This PR introduces a new user-facing feature (drag-and-drop thread reordering) with new state management and UI interactions across multiple components. New capabilities of this scope warrant human review. You can customize Macroscope's approvability policy. Learn more. |
Cursor Bugbot flagged that helpers picking a thread via sortThreads still used raw store order under manual sort, so the delete-fallback navigation and "open project from search" could jump to a thread that isn't first in the sidebar's manual list. - getLatestThreadForProject / getFallbackThreadIdAfterDelete now accept the manual order (scoped thread keys) and apply orderItemsByPreferredIds when sort is "manual", matching the sidebar's on-screen order - move orderItemsByPreferredIds into lib/threadSort (re-exported from Sidebar.logic) so the lib helper can use it without an import cycle - callers (useThreadActions, CommandPalette) pass the flattened threadOrderByProject; the per-project filter means only the relevant project's keys match Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

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 ordering and localStorage persistence; navigation/delete fallbacks are aligned with manual order but do not touch server auth or data.
Overview
Adds manual thread sort so users can drag thread rows within a project to define sidebar order, with the same persistence model as manual project reorder.
Contracts & sorting:
SidebarThreadSortOrdergains"manual".orderItemsByPreferredIdsmoves tothreadSort.ts; manual mode keeps store order and callers apply persisted scoped thread keys.getLatestThreadForProjectand post-delete fallback navigation use that order so “open project” and delete routing match the first visible thread.Persistence:
uiStateStoreaddsthreadOrderByProjectandreorderThreads, saved tolocalStorage;syncThreadsprunes removed threads.Sidebar UX: When sort is manual, per-project
DndContext/SortableContextenables vertical drag on rows (grab cursor, drop highlight), suppresses clicks during/after drag, and shows the full thread list (no “Show more” truncation). Thread-jump indices and prewarm lists follow the same manual ordering.Call sites: Command palette project open paths pass flattened manual order into
getLatestThreadForProject.Reviewed by Cursor Bugbot for commit 1ed1189. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add drag-and-drop manual reordering of threads within sidebar projects
'manual'sort mode toSidebarThreadSortOrderand areorderThreadsreducer inuiStateStore.tsthat persists per-project thread order to localStorage.SortableThreadItemcomponent using@dnd-kit, enabling vertical drag-and-drop reordering within each project inSidebar.tsx.sortThreadsandgetLatestThreadForProjectinthreadSort.tsso manual mode preserves input order and resolves "latest" thread by manual position rather than timestamp.syncThreadsprunes stale thread keys from the saved order automatically when threads are removed.Macroscope summarized 1ed1189.