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
{{ message }}
Repository navigation
[ENHANCEMENT] Dispose view listeners and ignore stale views when the webview is replaced #2205
When the sidebar view is replaced, the old view keeps its listeners. A stale view can still dispatch messages and refresh provider state. This work comes from the review of PR #1715.
Context (who is affected and when)
ClineProvider.resolveWebviewView pushes the message, visibility, configuration and dispose listeners into long-lived lists. It does not dispose them when VS Code resolves a new view. A disposed view can also clear listeners that belong to the new view.
A resolve that is still waiting for its HTML can finish after the provider or view is gone. It then installs listeners on a view that no longer exists.
This is a prerequisite for the heartbeat watchdog in PR #1715. The watchdog needs a replaced view to stop refreshing the provider-wide heartbeat.
Desired behavior (conceptual, not technical)
Keep the subscriptions of the current view in one list. Dispose that list when a different view replaces it, and when the view is disposed.
Ignore events from a view that is no longer the current view. This applies to the message, visibility, configuration and dispose listeners.
Stop a resolve that finishes after disposal or replacement. It must not assign HTML or install listeners.
Clear this.view when the sidebar view is disposed.
Add a test for each stale-resolve guard. This includes the guard after await this.getState(), which no test reaches today.
Activity
SoccerField24x7 commentedon Oct 27, 2026
@edelauna I can take a stab at this if you don't already have someone tagged for it.
edelauna commentedon Oct 27, 2026
Thanks @SoccerField24x7 I had started it - but got distracted before pushing a branch.