Lazy-register Conda manager#1600
Draft
Copilot wants to merge 3 commits into
Draft
Conversation
Copilot
AI
changed the title
[WIP] Implement lazy registration for Conda manager
Lazy-register Conda manager
Jun 21, 2026
Member
|
@copilot can you design a way to test this registration flow and the failure handling |
Contributor
Author
Added two unit test files covering the registration flow and failure handling — sinon-stubbed, no VS Code host required, follow the patterns of the existing
All 12 new tests pass (1209 total), and the full suite + lint are green. Latest commit: 8d5f8d4. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Conda discovery is the dominant per-locator cost in PET on Windows and was paid on every refresh, including in sessions where the user never picks a conda env. Mirror the v1.28 lazy-registration pattern already applied to pipenv/poetry/pyenv: register unconditionally so the manager shows up in the picker, defer the actual discovery until first use.
Changes
src/managers/conda/main.ts—registerCondaFeaturesno longer callsgetConda(nativeFinder)orconstructCondaSourcingStatusat activation. It unconditionally constructs and registersCondaEnvManagerandCondaPackageManager.projectManageris forwarded into the env manager so it can notify on missing-default later.src/managers/conda/condaEnvManager.ts—initialize()now performs the deferred work: a non-PETgetConda()fortoolSource = 'settings' | 'local', the existingrefreshCondaEnvs(...)(which does the PET refresh), and a post-refreshgetConda()to detect conda found via PET (toolSource = 'pet').constructCondaSourcingStatusruns lazily here. EmitsMANAGER_LAZY_INITtelemetry (result/envCount/toolSource/errorType) matching pipenv/poetry. CallsnotifyMissingManagerIfDefaultontool_not_found(relocated fromregisterCondaFeatures). Constructor accepts an optionalprojectManager(last arg, matches pipenv/poetry; existing 3-arg test call sites unaffected).docs/startup-flow.md— groups conda with pyenv/pipenv/poetry as unconditionally-registered, lazy-discovery managers.Tests
Added 12 sinon-stubbed unit tests covering the registration flow and every failure path:
src/test/managers/conda/registerCondaFeatures.unit.test.ts— proves the unconditional-registration contract: env manager + package manager are always registered (4 disposables) andgetConda/refreshCondaEnvs/constructCondaSourcingStatus/getCondaPathSettingare never called during activation. Registration still succeeds when conda is unavailable.src/test/managers/conda/condaEnvManager.initialize.unit.test.ts— covers the lazyinitialize()state machine: success paths fortoolSource = local / settings / pet;tool_not_foundwith and without aprojectManager(verifyingnotifyMissingManagerIfDefaultis called exactly when expected); the error path (verifiesinitialize()never throws to its caller and emitserrorType); graceful handling ofconstructCondaSourcingStatusfailure;MANAGER_LAZY_INITtelemetry payload; idempotency under concurrent calls; and that constructing the manager does no discovery work.Notes
MANAGER_REGISTRATION_SKIPPED { managerName: 'conda', reason: 'tool_not_found' }event in favor ofMANAGER_LAZY_INIT { result: 'tool_not_found' }, consistent with the other lazy-registered managers.sourcingInformationincondaUtils.tsalready guard againstundefinedand fall back to default activation. In practiceinitialize()runs before any conda env is resolved sincegetEnvironments()awaits it.conda-meta/historyis read multiple times per env perfind()call python-environment-tools#475 / Environment Manager viewlet - no visual indicatior on the currently selected environment. #476 — those still help when the user does open the picker; this removes the cost from startup entirely.