@@ -343,6 +343,14 @@ export interface QuickCreateConfig {
343343
344344/**
345345 * Interface representing an environment manager.
346+ *
347+ * @remarks
348+ * Methods on this interface are invoked both by the Python Environments extension itself
349+ * (in response to UI actions, startup, terminal activation, script execution, and so on)
350+ * and directly by other extensions that consume the published API. Any "called when…"
351+ * notes on individual methods list representative triggers only — they are not
352+ * exhaustive, and the precise set of call sites may evolve over time. Implementations
353+ * should focus on the documented contract rather than any specific caller.
346354 */
347355export interface EnvironmentManager {
348356 /**
@@ -398,10 +406,9 @@ export interface EnvironmentManager {
398406 * @returns A promise that resolves to the created Python environment, or undefined if creation failed.
399407 *
400408 * @remarks
401- * Called when the user:
402- * - Invokes the `python.createEnvironment` command (which prompts for a manager to use).
403- * - Uses the add-environment action for an environment manager in the Python Environments view.
404- * - Creates a new environment as part of a Python package project creation flow.
409+ * Invoked when an environment of this manager's type should be created for the given
410+ * scope. Typical triggers include user-initiated environment-creation flows and
411+ * programmatic creation via the API.
405412 */
406413 create ?( scope : CreateEnvironmentScope , options ?: CreateEnvironmentOptions ) : Promise < PythonEnvironment | undefined > ;
407414
@@ -411,8 +418,8 @@ export interface EnvironmentManager {
411418 * @returns A promise that resolves when the environment is removed.
412419 *
413420 * @remarks
414- * Called when the user right-clicks an environment in the Python Environments tree view and selects
415- * "Delete Environment".
421+ * Invoked to delete the given environment. Typical triggers include an explicit user
422+ * action (such as a "Delete Environment" command) and programmatic removal via the API .
416423 */
417424 remove ?( environment : PythonEnvironment ) : Promise < void > ;
418425
@@ -422,7 +429,8 @@ export interface EnvironmentManager {
422429 * @returns A promise that resolves when the refresh is complete.
423430 *
424431 * @remarks
425- * Called when the user clicks the refresh button in the Python Environments view title bar.
432+ * Forces the manager to re-discover environments for the given scope. Typically
433+ * triggered by an explicit user "refresh" action.
426434 */
427435 refresh ( scope : RefreshEnvironmentsScope ) : Promise < void > ;
428436
@@ -432,10 +440,8 @@ export interface EnvironmentManager {
432440 * @returns A promise that resolves to an array of Python environments.
433441 *
434442 * @remarks
435- * Called when:
436- * - The user expands an environment manager node in the Python Environments tree view.
437- * - The user opens the environment picker to select an interpreter.
438- * - Internally after {@link EnvironmentManager.refresh} completes, to count discovered environments.
443+ * Returns the environments known to this manager for the given scope. Called
444+ * frequently by UI surfaces (tree views, pickers) and by other consumers of the API.
439445 */
440446 getEnvironments ( scope : GetEnvironmentsScope ) : Promise < PythonEnvironment [ ] > ;
441447
@@ -451,16 +457,12 @@ export interface EnvironmentManager {
451457 * @returns A promise that resolves when the environment is set.
452458 *
453459 * @remarks
454- * Called when the user:
455- * - Selects an environment in the environment picker or clicks the checkmark button in the tree view.
456- * - Creates a new environment and the extension auto-selects it .
460+ * Invoked when the active environment for the given scope should change — for example
461+ * after the user selects an environment in a picker, after a newly created environment
462+ * is auto-selected, or programmatically via the API .
457463 *
458- * Also called at extension startup during initial environment selection to initialize or
459- * reconcile the active environment state. This startup call may pass the already-persisted or
460- * previously-selected environment; implementations should treat it as idempotent and avoid
461- * unnecessary work or side effects, including firing change events, unless the selected
462- * environment actually changes. Also called when a Python project is removed (with
463- * `environment` set to `undefined`).
464+ * Also invoked at extension startup to rehydrate the active environment from
465+ * persisted state.
464466 */
465467 set ( scope : SetEnvironmentScope , environment ?: PythonEnvironment ) : Promise < void > ;
466468
@@ -470,13 +472,10 @@ export interface EnvironmentManager {
470472 * @returns A promise that resolves to the current Python environment, or undefined if none is set.
471473 *
472474 * @remarks
473- * Called when:
474- * - The extension starts up, during initial environment selection for each workspace folder and global scope.
475- * - After {@link EnvironmentManager.set}, to confirm the new active environment and fire change events.
476- * - A terminal is opened or a command is run, to determine which Python environment to activate.
477- * - The user runs a Python file ("Run in Terminal", "Run as Task"), to get the interpreter.
478- * - The environment picker needs to display the currently selected (recommended) environment.
479- * - Auto-discovery checks if a local venv already exists for a workspace folder.
475+ * Returns the currently active environment for the given scope, or `undefined` if
476+ * none is selected. Called very frequently — at startup, after {@link set}, when a
477+ * terminal is opened, before running Python, by UI surfaces that display the active
478+ * interpreter, and by other extensions consuming the API.
480479 */
481480 get ( scope : GetEnvironmentScope ) : Promise < PythonEnvironment | undefined > ;
482481
@@ -498,10 +497,12 @@ export interface EnvironmentManager {
498497 * @returns A promise that resolves to the fully detailed {@link PythonEnvironment}, or `undefined` if the environment cannot be resolved.
499498 *
500499 * @remarks
501- * Called when:
502- * - The user browses for and selects a Python interpreter path via the file picker.
503- * - The user has `python.defaultInterpreterPath` configured and the extension resolves it at startup.
504- * - Before running a Python script ("Run in Terminal", "Run as Task"), to obtain full execution info.
500+ * Called to turn a lightly-populated {@link PythonEnvironment} or a {@link Uri}
501+ * pointing at an interpreter or environment folder into a fully-populated
502+ * {@link PythonEnvironment} with complete {@link PythonEnvironment.execInfo}. Typical
503+ * triggers include the user manually selecting an interpreter path, resolving
504+ * `python.defaultInterpreterPath` at startup, and populating execution details before
505+ * launching Python.
505506 */
506507 resolve ( context : ResolveEnvironmentContext ) : Promise < PythonEnvironment | undefined > ;
507508
@@ -511,7 +512,10 @@ export interface EnvironmentManager {
511512 * @returns A promise that resolves when the cache is cleared.
512513 *
513514 * @remarks
514- * Called when the user runs the "Python: Clear Cache" command from the Command Palette.
515+ * Drops any cached environment data held by the manager so that subsequent calls to
516+ * {@link EnvironmentManager.getEnvironments} or {@link EnvironmentManager.get}
517+ * re-discover state from disk. Typically triggered by an explicit user "clear cache"
518+ * action.
515519 */
516520 clearCache ?( ) : Promise < void > ;
517521}
0 commit comments