Skip to content

Watch package changes through PackageWatcher instead of TerminaPacakageWatcher - #1698

Open
Eduardo Villalpando Mello (edvilme) wants to merge 3 commits into
mainfrom
terminal-package-wathcer
Open

Watch package changes through PackageWatcher instead of TerminaPacakageWatcher#1698
Eduardo Villalpando Mello (edvilme) wants to merge 3 commits into
mainfrom
terminal-package-wathcer

Conversation

@edvilme

Copy link
Copy Markdown
Contributor

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, F89a1842L51R51)
  • The watcher registration is now called once during extension activation, rather than per environment manager, ensuring all active environments are covered. [1] [2]
  • 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] [2] [3]
  • Manager-specific watcher registration code is removed from builtin/main.ts and poetry/main.ts, further consolidating watcher logic. [1] [2] [3] [4]

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] [2]

These changes improve maintainability, reliability, and coverage of package change detection across all Python environments managed by the extension.

@edvilme Eduardo Villalpando Mello (edvilme) added the bug Issue identified by VS Code Team member as probable bug label Aug 6, 2026
@StellaHuang95

Copy link
Copy Markdown
Contributor

🔒 Automated review in progress — Stella Huang (@StellaHuang95) is auto-reviewing this PR.

@StellaHuang95

Copy link
Copy Markdown
Contributor

GitHub cannot anchor PR review comments to unchanged lines in the diff. Falling back to a general PR comment for src/features/terminal/terminalPackageWatcher.ts:L1.

Warning · Non-blocking recommendation

Removing this watcher drops refreshes for environments manually activated in a terminal but not selected in any workspace scope. Please confirm that this behavior is intentionally out of scope for #1683 and document the tradeoff in the PR description.

Comment thread package-lock.json Outdated
"integrity": "sha512-D7DbgGFtsqIPIFMPJwCad9Gfi/hC0PWErRRHFnaCWoEDYi5tQUDiJCTmGUbBiLzjqAck4KcXt9Ayj0CNlIrF+w==",
"dev": true,
"license": "BSD-2-Clause",
"peer": true,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Info · Optional note

These "peer": true additions appear unrelated to the watcher refactor and look like incidental lockfile reserialization. Please revert this churn to keep the change focused.

Comment thread package.json Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved via Review Center.

@StellaHuang95 Stella Huang (StellaHuang95) added the review-auto:approved Automated review: no blocking findings (approval posted). label Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue identified by VS Code Team member as probable bug review-auto:approved Automated review: no blocking findings (approval posted).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

terminalPackageWatcher completely hangs VS Code’s extension host infinitely

2 participants