Skip to content

Add command contribution support for chat session view items #260698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 9, 2025

This PR enables extensions to contribute commands to specific chat session view items in the Chat Sessions view. Extensions like the GitHub Pull Request extension can now register context-aware commands that appear as action bar items for individual session items.

Changes Made

1. New Context Keys

Added three new context keys in chatContextKeys.ts to provide session-specific context:

  • chatSessionId: The unique ID of the session item
  • chatSessionLabel: The display label of the session item
  • chatSessionType: The type of session (e.g., 'local', 'github', etc.)

2. Enhanced SessionsRenderer

Modified the SessionsRenderer in chatSessions.ts to support menu contributions:

  • Added menu service and context key service dependencies
  • Enhanced template data with elementDisposable for proper cleanup
  • Created context overlay for each session item using the new context keys
  • Integrated action bar support with MenuId.ChatSessionsMenu
  • Added proper disposal methods to prevent memory leaks

How Extensions Use This

Extensions can now contribute to the existing ChatSessionsMenu MenuId with context-aware commands:

{
  "contributes": {
    "menus": {
      "ChatSessionsMenu": [
        {
          "command": "github.createPullRequestFromSession",
          "when": "chatSessionType == 'github'",
          "group": "github",
          "order": 1
        }
      ]
    }
  }
}

Commands receive the full session object as an argument:

vscode.commands.registerCommand('github.createPullRequestFromSession', (session) => {
  // Access session.id, session.label, session.provider.chatSessionType
  console.log(`Creating PR for session: ${session.label}`);
});

Use Cases

This enables the GitHub Pull Request extension and other extensions to provide rich, session-specific functionality such as:

  • Creating pull requests from chat session content
  • Viewing associated PRs/issues
  • Adding comments to linked items
  • Quick management actions

The implementation follows VS Code's standard menu contribution patterns and provides a clean, extensible foundation for session-specific command contributions.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • electronjs.org
    • Triggering command: node-gyp (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@Copilot Copilot AI changed the title [WIP] Enhancing Chat Session View with Command Contributions Add command contribution support for chat session view items Aug 9, 2025
@Copilot Copilot AI requested a review from osortega August 9, 2025 00:43
Copilot finished work on behalf of osortega August 9, 2025 00:43
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.

2 participants