Skip to content

feat: implement fast path resolution for Python environment managers#1408

Merged
eleanorjboyd merged 8 commits intomicrosoft:mainfrom
eleanorjboyd:vague-owl
Apr 1, 2026
Merged

feat: implement fast path resolution for Python environment managers#1408
eleanorjboyd merged 8 commits intomicrosoft:mainfrom
eleanorjboyd:vague-owl

Conversation

@eleanorjboyd
Copy link
Copy Markdown
Member

  • Added fast path resolution logic in SysPythonManager, VenvManager, CondaEnvManager, PipenvManager, and PyEnvManager to directly resolve persisted environments without waiting for full initialization.
  • Enhanced error handling with logging for failed resolutions in the fast path.
  • Introduced unit tests to validate the fast path behavior across different environment managers, ensuring correct resolution and background initialization handling.

dmitrivMS
dmitrivMS previously approved these changes Mar 27, 2026
@eleanorjboyd eleanorjboyd marked this pull request as draft March 27, 2026 19:15
@eleanorjboyd eleanorjboyd added the feature-request Request for new features or functionality label Mar 27, 2026
@eleanorjboyd eleanorjboyd marked this pull request as ready for review March 27, 2026 23:03
@eleanorjboyd eleanorjboyd requested a review from Copilot March 31, 2026 01:55
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 introduces a shared “fast path” for EnvironmentManager.get() so managers can immediately resolve a persisted environment selection (from workspace state) without waiting for full environment discovery to complete, while discovery continues in the background.

Changes:

  • Added a reusable tryFastPathGet() helper (plus a shared getProjectFsPathForScope() accessor) and integrated it into built-in and tool-based managers.
  • Updated get() implementations in SysPython/Venv/Conda/Pipenv/PyEnv managers to attempt fast resolution and trigger background initialization.
  • Added unit tests for both the shared helper and manager-level behavior; updated startup-flow documentation to describe the new execution fork.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/managers/common/fastPath.ts New shared helper implementing the fast-path resolution + background init orchestration.
src/managers/builtin/sysPythonManager.ts Uses fast-path helper before falling back to standard initialization.
src/managers/builtin/venvManager.ts Uses fast-path helper and starts background refresh via internalRefresh.
src/managers/conda/condaEnvManager.ts Uses fast-path helper and runs discovery under withProgress.
src/managers/pipenv/pipenvManager.ts Uses fast-path helper and runs discovery under withProgress.
src/managers/pyenv/pyenvManager.ts Uses fast-path helper and runs discovery under withProgress.
src/test/managers/common/fastPath.unit.test.ts New unit tests validating tryFastPathGet() behavior and background init semantics.
src/test/managers/fastPath.get.unit.test.ts New unit tests validating fast-path behavior across multiple managers’ get() implementations.
docs/startup-flow.md Documentation updates describing the new fast-path vs slow-path fork during startup/selection.
Comments suppressed due to low confidence (1)

src/managers/common/fastPath.ts:94

  • Same as the traceError case above: traceWarn(... ${err}) will often lose the error stack/details. Prefer passing the error object as a separate argument to traceWarn so util.format can render it more helpfully.
            traceWarn(
                `[${opts.label}] Fast path resolve failed for '${persistedPath}', falling back to full init: ${err}`,
            );
        }
    }

@eleanorjboyd eleanorjboyd enabled auto-merge (squash) April 1, 2026 18:13
@eleanorjboyd eleanorjboyd merged commit 4e46444 into microsoft:main Apr 1, 2026
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature-request Request for new features or functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants