Skip to content

sessions: reorder sessions by drag and drop in workspace, repository and environment sections - #344939

Merged
Sandeep Somavarapu (sandy081) merged 3 commits into
mainfrom
sandy081/agents/fix-session-reordering-workspace
Oct 29, 2026
Merged

Sandeep Somavarapu (sandy081) merged 3 commits into
mainfrom
sandy081/agents/fix-session-reordering-workspace

Conversation

@sandy081

@sandy081 Sandeep Somavarapu (sandy081) commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Problem

In the Agents window, dragging a session by its edge works in Pinned and custom groups but not in a workspace folder of the sessions list. This happens with Move Chats drag and drop on (chat.agentHost.moveChats.enabled). In a workspace folder, every drop on another session's row moved the dragged session into that session instead of reordering it, including the top quarter and the bottom quarter of the section's last row.

Root cause

getSessionsListSessionDrop places a session before/after the target only when isManuallyOrdered() is true. SessionsList answered that through isInManuallyOrderedSection, which only counted pinned sessions and custom-group members. The list's own reorder scope (getReorderScope) treats workspace, repository and environment sections as manually ordered too. So in those sections the edge zones always fell through to nesting.

Regressed in #342624, which introduced session nesting by drag and drop. Before it, canReorderOnto allowed reordering inside workspace sections. Its tests only covered Date grouping.

Fix

isInManuallyOrderedSection also returns true when the session's own section (when it isn't pinned or in a group) is a workspace, repository or environment section. Date sections keep nesting on every edge, as before. External and Quick Chats sections are unchanged.

Tests

  • sessionsListChatMoveDnd.test.ts: the test list can now use a grouping other than Date. Both edge-placement tests now cover workspace, repository (owner/project) and environment (local) sections, alongside Pinned and custom groups. The top-quarter test also checks that a drop on the middle of a row still nests. The Date-section test is renamed to "in date sections, a session row only nests, at every edge".
  • Red/green: with the fix removed, both edge-placement tests fail for workspace, repository and environment (reordered: 0, nest feedback); with the fix, they pass.
  • ./scripts/test.sh --runGlob "vs/sessions/contrib/sessions/test/**/*.test.js": passed (1119 passing after merging main).
  • npm run typecheck-client: passed. npm run eslint on the changed files: passed. Hygiene: passed (pre-commit).

Live validation

Validated in the Agents window of the Code - OSS dev build (--agents) against a local mock agent host (agentHostServerMain.js --enable-mock-agent). The scenario creates three sessions in one workspace folder:

  • Before the fix: dropping "Alpha task" on the top edge of "Gamma task" nested it ("Moved session 'Alpha task' into 'Gamma task'").
  • After the fix: the same drop reorders the folder to Alpha, Gamma, Beta. Dropping on the middle of a row still moves the session into the target.

Repository and environment sections, Date sections, and restart (the order uses the existing sort-key storage) are covered by unit tests only; they were not replayed live.

Performance

The change adds one section-id lookup (getUngroupedSectionIds(session)[0]) per drag-over on a single dragged session. It is not on a rendering or list-update path, and adds no listeners, storage or I/O. Assessed by inspection; not measured.

Review

  • Independent code review: approved. Its one note, a stale doc comment on getSessionsListSessionDrop, is fixed.
  • Re-review of the merge from main and the repository/environment test commit: SHIP, no findings. It confirmed the fixtures render real repository: and environment: sections.

How to test

  1. Enable chat.agentHost.moveChats.enabled.
  2. In the Agents window, group the sessions list by workspace. Pick a folder that has at least two single-chat sessions from an agent host.
  3. Drag a session onto the top edge of another session in the same folder. It moves above that session.
  4. Drag it onto the middle of a session row. It still moves into that session.

…and environment sections

With Move Chats drag and drop on, dropping a session on another session's top edge (or the bottom edge of a section's last row) only placed it in Pinned and custom groups; in workspace, repository and environment sections every edge nested it into the target session. Treat those sections as manually ordered too, as the list's reorder scope already does. Date sections keep nesting on every edge. Regressed in #342624.

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 29, 2026 10:21
@sandy081 Sandeep Somavarapu (sandy081) added this to the 1.145.0 milestone Oct 29, 2026
…ession-reordering-workspace

# Conflicts:
#	src/vs/sessions/contrib/sessions/test/browser/sessionsListChatMoveDnd.test.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The added tests cover only Workspace grouping, leaving changed Repository and Environment behavior without regression coverage for edge placement and middle-row nesting.

1 open issue
What changed in this PR

Restores drag-and-drop session reordering in workspace, repository, and environment sections of the Agents window, while preserving middle-row nesting.

Changes:

  • Recognizes these sections as manually ordered when choosing between reordering and nesting.
  • Adds workspace regression cases for both insertion edges and retains Date-section nesting tests.
  • Updates comments to describe the expanded reorder scope.
File Description
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​sessionsListChatMoveDnd.test.ts Adds configurable grouping and workspace drag-and-drop coverage.
src/​vs/​sessions/​contrib/​sessions/​browser/​views/​sessionsListChatMove.ts Updates comments describing manually ordered sections.
src/​vs/​sessions/​contrib/​sessions/​browser/​views/​sessionsList.ts Includes workspace, repository, and environment sections in edge-reorder eligibility.

Review effort: Balanced

@sandy081
Sandeep Somavarapu (sandy081) merged commit 280fdb2 into main Oct 29, 2026
55 checks passed
@sandy081
Sandeep Somavarapu (sandy081) deleted the sandy081/agents/fix-session-reordering-workspace branch October 29, 2026 10:46
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.

5 participants