Skip to content

Agents window: "Delete..." silently fails for Claude (claude-code) sessions #313072

Description

Bug Report

Summary

Right-clicking a Claude session in the Agents window shows a "Delete..." context menu item, and the confirmation dialog appears — but after confirming, the session is not deleted and no error is surfaced to the user. The session remains in the list as if nothing happened.

Steps to Reproduce

  1. Open VS Code Insiders with the Agents window
  2. Start a conversation using a Claude model (claude-code session)
  3. Right-click the session in the sidebar
  4. Click "Delete..."
  5. Confirm the dialog

Expected: Session is deleted and removed from the list.
Actual: Session remains — nothing changes, no error shown.

Root Cause (traced)

_deleteAgentSessions() in CopilotChatSessionsProvider routes all non-CLI sessions — including Claude — to chatService.removeHistoryEntry(agentSession.resource):

// copilotChatSessionsProvider.ts ~line 1521
private async _deleteAgentSessions(agentSessions: IAgentSession[]): Promise<void> {
    const cliSessionItems: { resource: URI }[] = [];
    for (const agentSession of agentSessions) {
        if (agentSession.providerType === CopilotCLISessionType.id) {
            cliSessionItems.push({ resource: agentSession.resource });
        } else {
            await this.chatService.removeHistoryEntry(agentSession.resource); // ← bug
        }
    }
    ...
}

removeHistoryEntry calls LocalChatSessionUri.parseLocalSessionId(resource), which only handles vscode-local-chat-session:// URIs (standard Copilot Cloud sessions). Claude sessions use the claude-code:// URI scheme, so this throws:

Error: Invalid local chat session resource: claude-code://...

The error is swallowed somewhere in the call stack, causing the silent no-op.

Fix Pattern (already used for rename)

renameChat() (line ~1446) already correctly special-cases AgentSessionProviders.Claude by delegating to an extension command:

if (agentSession?.providerType === AgentSessionProviders.Claude) {
    await this.commandService.executeCommand('github.copilot.claude.sessions.rename', { resource: chatUri }, title);
    return;
}

The same pattern is needed for deletion — but 'github.copilot.claude.sessions.delete' does not exist in the extension yet.

Fix Required (two parts)

  1. copilotChatSessionsProvider.ts_deleteAgentSessions(): Add a Claude special-case to route to a new 'github.copilot.claude.sessions.delete' extension command (analogous to the CLI agents.github.copilot.cli.deleteSessions delegation).

  2. claudeChatSessionContentProvider.ts (Copilot extension): Register 'github.copilot.claude.sessions.delete', following the same pattern as the existing 'github.copilot.claude.sessions.rename' command.

Affected Scope

  • Both "Delete session" (full session) and "Delete chat" (single chat in a multi-chat session) go through _deleteAgentSessions() — both are broken.
  • Not affected: Copilot CLI sessions (use a dedicated command), Copilot Cloud sessions (use vscode-local-chat-session:// which works correctly).

Environment

  • VS Code Insiders (Agents window)
  • macOS
  • GitHub Copilot Chat extension

Metadata

Metadata

Labels

agents-windowbugIssue identified by VS Code Team member as probable bugclaude-agentIntegration with the Claude Agent SDK

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions