agents: fix Mark as Done on cancelled new chat session#318750
Merged
Conversation
When a Mark as Done action was invoked on an uncommitted (NEW) chat
session that had been cancelled mid-flight, the click was a no-op:
the session stayed in the active list and the UI never refreshed.
Root cause: 'CopilotChatSessionsProvider.archiveSession' tried the
agent-host lookup ('_findAgentSession') first. For untitled sessions
that were started via the chat view, an entry already exists in the
agent-host model (registered by 'getOrCreateChatSession' during the
initial chat send) but with providerType 'Local'. That providerType is
filtered out by '_refreshSessionCache', so calling
'agentSession.setArchived(true)' updates the agent-host model in
isolation and never propagates to the chat adapter's '_isArchived'
observable that the UI is bound to.
Fix: reorder the logic in both 'archiveSession' and 'unarchiveSession'
to check the chat-adapter first. If it is a NEW (uncommitted) session,
archive it via the chat adapter and fire 'onDidChangeSessions' so the
UI updates immediately. Only fall back to the agent-host path for
committed sessions (where 'AgentSessionAdapter' is the chat adapter and
'_refreshSessionCache' does propagate the change).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes Agents window archiving for cancelled, uncommitted Copilot chat sessions by ensuring the UI-bound chat adapter is updated before falling back to agent-host session state.
Changes:
- Archives/unarchives NEW chat sessions directly through the chat adapter.
- Emits
onDidChangeSessionsfor these uncommitted sessions so the sessions list refreshes immediately. - Preserves the existing agent-host path for committed sessions.
Show a summary per file
| File | Description |
|---|---|
src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsProvider.ts |
Reorders archive/unarchive handling to prioritize NEW session adapters before agent-host sessions. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 0
dmitrivMS
approved these changes
May 28, 2026
sandy081
approved these changes
Jun 5, 2026
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.
Fixes #318550.
Problem
When the user starts a new chat in the Agents window, cancels the response mid-flight, then clicks Mark as Done on the session, the click is a no-op: the session stays in the active list and the UI never refreshes.
Root cause
CopilotChatSessionsProvider.archiveSessiontried the agent-host lookup (_findAgentSession) first. For untitled sessions started via the chat view, an entry already exists in the agent-host model — it was registered bygetOrCreateChatSessionduring the first chat send — but with providerTypeLocal.That providerType is filtered out by
_refreshSessionCache, so callingagentSession.setArchived(true)updates the agent-host model in isolation and never propagates to the chat adapter's_isArchivedobservable that the UI is bound to.Fix
Reorder the logic in both
archiveSessionandunarchiveSession:onDidChangeSessionsso the UI updates immediately.AgentSessionAdapteris the chat adapter and_refreshSessionCachedoes propagate the change).Verification
Reproduced the bug in a local Code OSS dev build:
sleep 90queryBefore the fix: session stayed in the active list. After the fix: session is archived correctly and disappears from the active list.