Skip to content

Fix deleting sub-session when it is not active#313200

Merged
sandy081 merged 1 commit into
mainfrom
sandy081/fix-delete-sub-session
Apr 29, 2026
Merged

Fix deleting sub-session when it is not active#313200
sandy081 merged 1 commit into
mainfrom
sandy081/fix-delete-sub-session

Conversation

@sandy081
Copy link
Copy Markdown
Member

When a child chat in a multi-chat group was removed, _refreshSessionCache would first remove it from _sessionCache and invalidate grouping caches. Then _refreshSessionCacheMultiChat would try to resolve the removed chat's group ID, but since the caches were already rebuilt without the removed chat, _getGroupIdForChat fell back to the chat's own ID instead of the parent group's ID.

This caused the child to be treated as a "truly removed" standalone session rather than a group membership change, so no "changed" event was fired for the parent group — which could result in the main session being incorrectly removed.

Fix: Resolve group IDs for removed sessions before removing them from the cache and invalidating grouping caches, then pass the pre-computed map to _refreshSessionCacheMultiChat.

Fixes #311987

When a child chat in a multi-chat group was removed, _refreshSessionCache
would first remove it from _sessionCache and invalidate grouping caches.
Then _refreshSessionCacheMultiChat would try to resolve the removed chat's
group ID, but since the caches were already rebuilt without the removed
chat, _getGroupIdForChat fell back to the chat's own ID instead of the
parent group's ID. This caused the child to be treated as a 'truly removed'
standalone session rather than a group membership change, so no 'changed'
event was fired for the parent group.

Fix: resolve group IDs for removed sessions BEFORE removing them from the
cache and invalidating grouping caches.

Fixes #311987

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 29, 2026 10:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a multi-chat session grouping bug in the Agents window where deleting a child/sub-session could be misclassified as removing a standalone session, preventing the parent group from emitting a changed event and potentially causing incorrect UI/session removal.

Changes:

  • Pre-computes group IDs for removed sessions before mutating _sessionCache / invalidating grouping caches.
  • Passes the pre-computed removed→groupId mapping into _refreshSessionCacheMultiChat.
  • Updates _refreshSessionCacheMultiChat signature to accept the removed group ID map.
Show a summary per file
File Description
src/vs/sessions/contrib/copilotChatSessions/browser/copilotChatSessionsProvider.ts Preserves correct group resolution for removed child chats by computing group IDs before cache invalidation and wiring that data into multi-chat refresh logic.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 3

@sandy081 sandy081 enabled auto-merge (squash) April 29, 2026 11:38
@sandy081 sandy081 merged commit 4a46ed2 into main Apr 29, 2026
44 of 45 checks passed
@sandy081 sandy081 deleted the sandy081/fix-delete-sub-session branch April 29, 2026 15:08
@vs-code-engineering vs-code-engineering Bot added this to the 1.119.0 milestone Apr 29, 2026
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.

Agents: Deleting a sub-session doesn't immediately work

3 participants