Skip to content

feat: drag and drop workspaces into or out of workspace groups - #56

Open
isavage wants to merge 1 commit into
L13:masterfrom
isavage:ft/drag-n-drop
Open

isavage wants to merge 1 commit into
L13:masterfrom
isavage:ft/drag-n-drop

Conversation

@isavage

@isavage isavage commented Sep 18, 2026

Copy link
Copy Markdown

What does this PR do?

Adds drag-and-drop support to the Workspaces view so workspaces can be organized into custom workspace groups without opening the Add to Group / Edit Workspaces menus.

Behaviour (scoped to custom workspace groups only):

  • Drag one or more workspaces and drop them onto a workspace group → they are added to that group.
  • Drop them onto a project that is already inside a group → they join that same group (VS Code highlights the deepest node under the cursor, so this makes dropping into a group reliable).
  • Drop them onto a project outside of all groups, or into empty tree space → they are removed from their current group.
  • Dropping onto any other node (tags, root/type groups, the Tags header) is ignored, so a stray drop never silently un-groups a workspace.

Auto-sorted groups, favorites and tags are intentionally left untouched.

Implementation notes

  • WorkspacesProvider now implements vscode.TreeDragAndDropController<WorkspacesTreeItems> and is wired up via dragAndDropController in createTreeView.
  • Uses a single custom MIME type (application/vnd.code.tree.l13ProjectsWorkspaces) carrying the dragged project paths as JSON, so multi-select drags work.
  • WorkspaceGroupsState gains batch helpers addWorkspaces() / removeWorkspaces() that mirror the existing single-item methods: de-duplicate against the target group, remove each path from any other group, re-sort, save, and fire the existing change events so the tree refreshes.
  • While testing the out-of-group → group direction I hit a real bug in the existing addWorkspace(): it mutated the group object passed in from the tree item, which is a fresh deserialized copy from globalState, not the object inside the saved array. The change was therefore persisted against an orphan. It now looks the group up by id first. The same lookup is used in addWorkspaces().

Type / engine handling — please review

TreeDragAndDropController requires VS Code 1.66, so engines.vscode is bumped to ^1.66.0.

However, bumping @types/vscode past 1.56 changes TreeItem.iconPath, which breaks ~20 existing assignments across the tree items (string paths are no longer assignable to Uri-only IconPath). Rather than churn every tree item in a feature PR, this branch keeps @types/vscode at 1.56.0 and declares only the missing drag-and-drop types in a local module augmentation (src/@types/vscode.d.ts, excluded from lint).

Happy to instead upgrade @types/vscode and convert the icon paths to vscode.Uri in a follow-up if you'd prefer that approach.

Checklist

  • gulp build passes (0 errors, 0 warnings)
  • Existing test suite passes (273 passing)
  • README.md documents the new interaction
  • CHANGELOG.md updated under [Unreleased]
  • Manually verified: into group, between groups, out of group, multi-select

Notes

  • No version bump in package.json — left at 2.0.0 for you to decide the release number.

- Implement TreeDragAndDropController in WorkspacesProvider
- Drop onto a workspace group (or a project inside one) assigns the dragged workspaces to that group
- Drop onto a project outside all groups or empty tree space removes them from their group
- Add batch addWorkspaces/removeWorkspaces helpers to WorkspaceGroupsState
- Fix stale group reference in addWorkspace (lookup by id)
- Bump engine to ^1.66.0 (required for the DnD API) and declare the missing types via a local module augmentation to keep @types/vscode at 1.56.0
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