fix(desktop,host-service): name worktree folders after the project, and explain locked sidebar drags
Summary
- New worktrees land at
<base>/<project name>/<branch>instead of<base>/<project uuid>/<branch>. - Dragging a sidebar row while the list is sorted or filtered now raises a toast that says why and fixes it in one click, instead of silently doing nothing.
- Adds a regression test pinning that creating a workspace never renumbers a dragged order.
Why / Context
Two reports from one customer (macOS arm64, 1.26.0 and 1.28.0).
UUID worktree folder. They set a worktree location and a custom branch prefix and expected {worktrees path}/{prefix}/{branch}, but got a UUID folder. v1 built <base>/<project.name>/<branch>; the v2 host-service builder used the project id. Related: SUPER-2146.
"Creating a worktree re-sorts my sidebar." I could not find a code path that does this. On 1.26.0, 1.28.0 and main, all three placement paths (writeWorkspacePaneLayout, ensureSidebarWorkspaceRecord, usePlaceWorktreesInSidebar) prepend the new row and leave every other tabOrder untouched, and nothing sorts rows by name. What I did find is a real UX hole that fits the report: under "Last active" or "Date created", row drags are disabled and a disabled dnd-kit sortable emits nothing, so a drag attempt looks like the sidebar ignoring you. This PR closes that hole and pins the create behaviour with a test. It does not claim to fix the original report.
How It Works
Path builder (worktree-paths.ts)
resolveProjectWorktreesFolderderives the folder from the project name: reserved and control characters become-, whitespace collapses, leading/trailing dots and spaces are trimmed, capped at 80 chars.- If another project on the host has the same name (case-insensitive, for APFS), each takes a
-<first 8 of id>suffix so their branches cannot collide. A name that sanitizes to nothing falls back to the id. - Existing worktrees keep the absolute path they were created with.
isInsideProjectWorktreesRoot, which guards the directrmin workspace cleanup, now accepts the name folder, the suffixed form, and the legacy id folder, so worktrees from older releases stay deletable. The symlink and traversal checks are unchanged.
Blocked-drag notice (useBlockedDragNotice)
- Inert sortables carry a
data-sidebar-drag-blockedmarker. One delegatedpointerdownlistener ondocumentwatches for a press on a marked row that moves 5px or more, the same distance as the mouse sensor's activation constraint, so a click never counts. - The toast uses a fixed id, so repeated attempts reuse it, and it is dismissed once rows are draggable again. A filter outranks a sort as the stated reason.
- "Manual order" is safe to offer: sort modes are a derived view and never rewrite the stored drag order.
- The listener is only attached while rows are locked.
Screenshots
Dev app from this branch, real mouse input over CDP, including a 55s recording of every case: https://app.superset.sh/page/sidebar-drag-notice-ma3tlf
Manual QA Checklist
Verified in the dev app over CDP (37 real rows), with console.error hooked and empty throughout:
- Manual order: 0 locked rows, no toast
- Choose "Last active" from the sort menu: 34 rows locked
- Click a locked row: opens the workspace, no toast
- Drag a locked workspace row: toast "Switch to manual order to rearrange the sidebar"
- Drag a locked Sessions row right after: still one toast, not stacked
- Click "Manual order": sort returns to Manual, 0 locked rows, toast dismissed
- Filter by "hiring", drag a row: toast "Clear the filter to rearrange the sidebar"
- Click "Clear filter": input emptied, 0 locked rows, toast dismissed
- Drag a folder header under a sort: same toast
- Collapse the sidebar under a sort and drag an icon row: same toast
- Drag a project header under a filter: filter toast
Not exercised:
- Creating a worktree in the app and confirming the new on-disk path
- Deleting a worktree that lives under a legacy
<base>/<uuid>/folder
Testing
bun run typecheckinapps/desktopandpackages/host-service: both exit 0bunx biome checkon the touched directories: cleanbun run check:i18n: exit 0, 0 missing in all 16 locales (2 new strings translated; button labels reuse existing "Manual order" and "Clear filter")bun testDashboardSidebar + workspace-creates: 190 pass, 0 failbun test worktree-paths.test.ts test/workspace-cleanup.test.ts: 47 pass, 0 fail (the first CI run failed 7 destroy tests because that fixture's project row had noname; fixed in ae740e3307)writeWorkspacePaneLayout.test.tsmutation-checked: breaking the prepend fails 3 of 5 tests
Design Decisions
- No second, per-project sort control. A global Manual / Last active / Date created menu already ships; the gap was the silent dead drag, not a missing control.
- Project name, not a new "folder name" setting. Matches v1 and needs no host.db migration. SUPER-1418 (option to drop the project folder entirely) is left for its own change since it does need one.
- Delegated listener over per-row handlers. Rows gain no handlers or re-renders, and nothing runs while every row is draggable.
Known Limitations
- Renaming a project changes the folder for new worktrees only; existing ones stay where they are. If such a worktree later needs the fallback direct removal (project repo missing, or git already unregistered it), the guard does not recognise the old-name folder, so the folder is left on disk with a warning instead of being deleted. The normal
git worktree removepath is unaffected. Fixing this properly means persisting the creation-time folder, which needs a host.db migration. - Adding a second project with the same name switches both to the suffixed folder for new worktrees.
- There is no standing visual cue that rows are locked under a sort; the toast appears only on a drag attempt.
Risks / Rollout
- Risk: low. The path change affects only newly created worktrees, and the cleanup guard is widened only to folders derived from the same project row.
- Rollback: revert. Worktrees created under name folders remain usable, since paths are stored absolute, but the narrower guard would then skip direct removal for them and leave a warning instead.
Summary by CodeRabbit
- New Features
- Sidebar drag attempts now explain when filtering or non-manual sorting prevents rearrangement.
- Worktree folders now use sanitized project names, handle naming conflicts, and remain compatible with existing folders.
- Bug Fixes
- Improved workspace and worktree path handling during creation and cleanup.
- Preserved workspace ordering when adding projects.
- Localization
- Added sidebar rearrangement guidance in supported languages.
- Tests
- Added coverage for blocked dragging, workspace ordering, and worktree path safety.
Summary by cubic
New worktrees now land at <base>/<project name>/<branch> instead of <base>/<project uuid>/<branch>, and dragging a sidebar row locked by a sort or filter now shows a toast explaining why, with a one-click fix, instead of silently doing nothing.
Worktree paths
- Matches v1 and addresses SUPER-2146: the folder is the sanitized project name; same-name projects on one host get a short id suffix, Windows device names (CON, NUL, COM1, …) get a leading underscore, and unusable names fall back to the id.
- Only newly created worktrees move; existing ones keep their paths, and cleanup still recognizes the name, suffixed, and legacy id folders so older worktrees stay deletable.
Sidebar drag notice
- A delegated listener fires on a press-and-move past the drag threshold on a marked row, so clicks never trigger it; repeated attempts reuse one toast, dismissed when rows are draggable again.
- The toast action switches to manual order or clears the filter; new strings are translated in all 16 locales.
- Adds regression tests pinning that creating a workspace never renumbers a dragged order.