You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Watch package changes through PackageWatcher instead of TerminaPacakageWatcher (#1698)
This pull request refactors and improves the package change detection
and watcher system for Python environments. It consolidates the logic
for watching package changes across all environment managers into a
single, manager-agnostic watcher registration, and removes redundant or
manager-specific watcher code. The new system ensures that package
changes are detected and handled consistently, regardless of environment
type or package manager.
Fixes#1683
**Core improvements to package watcher system:**
* A new `registerPackageWatchers` function is introduced in
`packageWatcher.ts`, which registers package watchers for all active
environments, sharing watchers when environments are active in multiple
scopes and cleaning up watchers when no longer needed. This replaces the
old per-manager watcher registration.
([src/managers/common/packageWatcher.tsL2-R11](diffhunk://#diff-db307f917634197b286344124fab7702aa1c37601df0c09bceba8b6d1cd76cd3L2-R11),
F89a1842L51R51)
* The watcher registration is now called once during extension
activation, rather than per environment manager, ensuring all active
environments are covered.
[[1]](diffhunk://#diff-04bba6a35cad1c794cbbe677678a51de13441b7a6ee8592b7b50be1f05c6f626R673-R674)
[[2]](diffhunk://#diff-04bba6a35cad1c794cbbe677678a51de13441b7a6ee8592b7b50be1f05c6f626L684-L688)
* The watcher logic is updated to better handle watcher sharing and
disposal, and to use improved glob patterns for `.dist-info`
directories, catching more package changes. (F89a1842L18R18,
F89a1842L43R43)
**Cleanup and removal of legacy code:**
* The old `terminalPackageWatcher.ts` and its related imports and
registration are removed, as its functionality is now covered by the new
watcher system.
[[1]](diffhunk://#diff-04bba6a35cad1c794cbbe677678a51de13441b7a6ee8592b7b50be1f05c6f626L89)
[[2]](diffhunk://#diff-04bba6a35cad1c794cbbe677678a51de13441b7a6ee8592b7b50be1f05c6f626L684-L688)
[[3]](diffhunk://#diff-9b9f96660a5ea04265c5ed7f91dba539d24dc06469c0feed8e3af541aa7d1321L1-L111)
* Manager-specific watcher registration code is removed from
`builtin/main.ts` and `poetry/main.ts`, further consolidating watcher
logic.
[[1]](diffhunk://#diff-450a068335039323c00b342cbfbff615ecf1cda7bd9d73aaed6b8e13d2d9d7f5L7)
[[2]](diffhunk://#diff-450a068335039323c00b342cbfbff615ecf1cda7bd9d73aaed6b8e13d2d9d7f5L44-L48)
[[3]](diffhunk://#diff-27854fc91d92524ea1d6cecfec07dcb12f64204246b5d45097156ddc3a1867ecL7)
[[4]](diffhunk://#diff-27854fc91d92524ea1d6cecfec07dcb12f64204246b5d45097156ddc3a1867ecL28)
**API and test updates:**
* The `InternalPackageManager` class now exposes a
`getPackageWatchTargets` method to allow custom watch targets per
package manager.
* Tests are updated to use the new watcher registration API.
[[1]](diffhunk://#diff-960d3ebbd27add9587b7da36c8ce1af3836525d17909b0e8f8fb01cf293f7ac3L7-R10)
[[2]](diffhunk://#diff-960d3ebbd27add9587b7da36c8ce1af3836525d17909b0e8f8fb01cf293f7ac3L87-L95)
These changes improve maintainability, reliability, and coverage of
package change detection across all Python environments managed by the
extension.
---------
Copilot-Session: a7de2667-ab70-47de-a8fd-5b00953e14f7
0 commit comments