Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Oct 10, 2025

Problem

When creating a Python virtual environment in a very large workspace folder (e.g., a dev folder with many subdirectories and files), the "Searching for dependencies" progress notification would run for an extended period with no way to cancel. Users were forced to either wait indefinitely or exit VS Code entirely to escape the operation.

image

Solution

Added cancellation support to the dependency search progress by setting cancellable: true in the withProgress options. This enables a Cancel button (X) on the progress notification, allowing users to gracefully exit the operation.

Changes

Modified src/managers/builtin/pipUtils.ts:

  • Added cancellable: true to the progress options in the getProjectInstallable function
  • The cancellation token was already being properly passed to findFiles calls, so no additional changes were needed

Added tests in src/test/managers/builtin/pipUtils.unit.test.ts:

  • Test to verify the cancellable flag is set correctly
  • Test to verify the cancellation token is properly propagated to file search operations

How Cancellation Works

  1. User clicks the Cancel button on the progress notification
  2. VS Code framework sets token.isCancellationRequested = true
  3. The findFiles API calls check the token and terminate the search
  4. A CancellationError is thrown and propagates up the call stack
  5. The environment creation flow handles the cancellation gracefully

Impact

  • ✅ Users can now cancel long-running dependency searches
  • ✅ No need to exit VS Code to escape the operation
  • ✅ Consistent with other cancellable operations in the extension (package management, conda operations, etc.)
  • ✅ Minimal code change (1 line) with comprehensive test coverage

Test Results

  • All 196 unit tests passing (2 new tests added)
  • No linting errors
  • TypeScript compilation successful

Fixes #[issue-number]

Original prompt

This section details on the original issue you should resolve

<issue_title>Support cancelling when searching for dependencies</issue_title>
<issue_description>I use the quick create option to create a new environment in a very large worksapce folder (lots of folders and files, basically my dev folder).
The progress window has been going on for a long time,

I think we should support adding Cancel button for such actions, as these aren't compulsory, i.e. users need to be able to exit from this
My only solution was to exit VS Code and create the env manually.

Image</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #924


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Add cancel button for searching dependencies Add cancellation support for dependency search during environment creation Oct 10, 2025
@Copilot Copilot AI requested a review from eleanorjboyd October 10, 2025 21:12
Copilot finished work on behalf of eleanorjboyd October 10, 2025 21:12
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.

Support cancelling when searching for dependencies

2 participants