fix(sidebar): sort projects by creation time and auto-scroll while dragging - #1272
Open
130rockirt wants to merge 1 commit into
Open
fix(sidebar): sort projects by creation time and auto-scroll while dragging#1272130rockirt wants to merge 1 commit into
130rockirt wants to merge 1 commit into
Conversation
…agging Project groups now sort newest-first by workspace folder creation time (birthtime via a new workspace:creation-times IPC, mtime fallback on filesystems without birthtime); undated projects sink below dated ones and keep the legacy active-first/name order. Explicit drag ordering saved in kun.sidebarOrder.v1 still wins. HTML5 drag-and-drop never scrolls containers, so rows outside the viewport were unreachable drop targets. Sidebar scroll containers marked data-kun-drag-scroll now auto-scroll while the dragged pointer hovers near their top/bottom edge, via document-level capture listeners that survive row-level stopPropagation and always stop on dragend/drop. Also extract preload dataMigration and the worktree-discovery effect into their own modules to stay under the 700-line file gate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix two sidebar project-list issues:
Sort projects by creation date (newest first). The project list previously fell back to alphabetical order (
localeCompareon paths). Now the sidebar reads each workspace folder's filesystem creation time (birthtime, withmtimefallback for filesystems without birthtime support) via a new boundedworkspace:creation-timesIPC channel and sorts project groups newest-first. Projects whose creation time is unavailable sink below dated projects and keep the legacy active-first/name order relative to each other. Explicit user drag ordering (saved inkun.sidebarOrder.v1) still wins when present.Auto-scroll while dragging. HTML5 drag-and-drop never scrolls containers, so when a project list is taller than the sidebar, dragging a row (e.g. dragging
zhihuto abovekunat the top) could not reach targets outside the viewport. Scroll containers markeddata-kun-drag-scrollnow auto-scroll when the dragged pointer hovers near their top/bottom edge (capture-phase document listeners, so row-levelstopPropagationin drop-position handlers cannot silence it;dragend/dropalways stop the scroller).Changes
src/main/ipc: newworkspace:creation-timeshandler +workspaceCreationTimesPayloadSchema(max 256 roots, strict, trimmed paths).src/shared/kun-gui-api*:WorkspaceCreationTimeEntrytype +getWorkspaceCreationTimessurface.src/preload: exposegetWorkspaceCreationTimes; extractdataMigrationinto its own module to keepindex.tsunder the 700-line file gate.src/renderer/.../sidebar-project-selectors.ts:compareWorkspacePathsByCreation— newest-first by creation time, undated projects sink, tie/unknown falls back to legacy comparator.src/renderer/.../sidebar-project-creation-times.ts:useSidebarWorkspaceCreationTimeshook (identity-keyed, deduped, keeps stale map while refetching to avoid double reshuffle).src/renderer/.../sidebar-worktree-discovery.ts: extractuseSidebarWorktreeDiscoveryhook fromSidebarProjectsSection(keeps the file under the 700-line gate after wiring creation times).src/renderer/.../sidebar-drag-auto-scroll.ts: edge-proximity velocity + rAF scroller + document-level capture registration;Sidebar.tsxregisters it once, projects list container opts in via the attribute.Tests
sidebar-project-selectors.creation-order.test.ts(ordering, case-insensitive key matching, undated sink, tie active-first, legacy fallback),sidebar-drag-auto-scroll.test.ts(velocity ramp/clamp/minimum, continuous scrolling, stop on middle/drop/dragend, capture-phase),workspace:creation-timeshandler test (real tmpdir, missing path → null, schema rejection), schema test.npm run typecheck✅npm run check:file-lines✅npx eslinton all touched files ✅npm run test: all sidebar/preload/IPC/shared tests pass. 20 pre-existing failures insrc/mainsymlink/daemon/migration/installer suites reproduce on a cleanorigin/developcheckout (Windows sandbox, e.g.daemon-runtime.test.tsfails identically on develop) and are unrelated to this change.