Skip to content

agents: fix Mark as Done on cancelled new chat session#318750

Merged
sandy081 merged 1 commit into
mainfrom
ulugbekna/agents/fix-issue-318550-vscode
Jun 5, 2026
Merged

agents: fix Mark as Done on cancelled new chat session#318750
sandy081 merged 1 commit into
mainfrom
ulugbekna/agents/fix-issue-318550-vscode

Conversation

@ulugbekna
Copy link
Copy Markdown
Contributor

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.archiveSession tried 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 by getOrCreateChatSession during the first 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:

  1. 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.
  2. Only fall back to the agent-host path for committed sessions (where AgentSessionAdapter is the chat adapter and _refreshSessionCache does propagate the change).

Verification

Reproduced the bug in a local Code OSS dev build:

  1. Sent a sleep 90 query
  2. Cancelled it mid-flight
  3. Clicked Mark as Done

Before the fix: session stayed in the active list. After the fix: session is archived correctly and disappears from the active list.

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>
Copilot AI review requested due to automatic review settings May 28, 2026 13:49
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

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 onDidChangeSessions for 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

@ulugbekna ulugbekna requested a review from sandy081 June 1, 2026 13:57
@sandy081 sandy081 merged commit f08110f into main Jun 5, 2026
26 checks passed
@sandy081 sandy081 deleted the ulugbekna/agents/fix-issue-318550-vscode branch June 5, 2026 14:24
@vs-code-engineering vs-code-engineering Bot added this to the 1.124.0 milestone Jun 5, 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.

"Mark as done" on an interrupted session doesn't work

4 participants