Repository navigation
Description
Summary
After an extension's progress notification finishes (i.e. progress.done() is called internally), the notification that remains visible in the Notification Center exhibits two broken behaviors:
- The close (×) button is not shown on the notification row — there is no way to dismiss it individually.
- The "Clear All Notifications" button is disabled, and the
notifications.clearAllcommand silently skips the notification.
Steps to Reproduce
- Use any extension that creates a
ProgressLocation.Notificationprogress notification and leaves it visible after the operation completes (e.g. extensions like Gradle for Java, Dev Containers, or any extension usingvscode.window.withProgress({ location: vscode.ProgressLocation.Notification })). - Wait for the operation to finish (the progress bar completes/disappears).
- Open the Notification Center (
Ctrl+K Ctrl+Shift+N). - Observe: the notification row has no close (×) button.
- Observe: the "Clear All Notifications" toolbar button is greyed out.
- Run
notifications.clearAllfrom the Command Palette — the completed-progress notification is not dismissed.
Expected Behavior
Once progress completes (done() is called), the notification should behave like any other standard notification:
- The close (×) button should appear.
- "Clear All Notifications" should be enabled and should dismiss it.
Root Cause
INotificationViewItem.hasProgress (in src/vs/workbench/common/notifications.ts) is implemented as:
get hasProgress(): boolean {
return !!this._progress; // BUG: _progress is never nulled out after done()
}_progress is a lazily-created object that, once instantiated, is never set back to null, even after progress.done() is called. As a result, hasProgress permanently returns true for any notification that ever had progress.
This getter is used in at least three places that all misbehave:
1. Close button hidden (notificationsViewer.ts):
// Close (unless progress is showing)
if (!notification.hasProgress) { // ← always false after any progress
actions.push(NotificationTemplateRenderer.closeNotificationAction);
}2. "Clear All" disabled (notificationsCenter.ts):
clearAllAction.enabled = this.model.notifications.some(notification => !notification.hasProgress);
// ← if all notifications had progress, enabled is always false3. clearAll() skips the notification (notificationsCenter.ts):
if (!notification.hasProgress) { // ← false, so close() is never called
notification.close();
}Note: The sticky getter in the same file already handles this correctly:
(this._progress && !this._progress.state.done) // only sticky while progress is runningProposed Fix
Step 1 — Fix the root cause in src/vs/workbench/common/notifications.ts:
get hasProgress(): boolean {
return !!this._progress && !this._progress.state.done;
}Step 2 — Trigger a toolbar re-render when progress completes, in src/vs/workbench/browser/parts/notifications/notificationsViewer.ts:
case NotificationViewItemContentChangeKind.PROGRESS:
this.renderProgress(notification);
this.renderActions(notification); // add this: refresh close button visibility
break;Without Step 2, even with Step 1 fixed, the close button won't appear in the toolbar until the next full list re-render (e.g. scrolling), because the PROGRESS content change event handler only calls renderProgress() and not renderActions().
Affected Files
-
src/vs/workbench/common/notifications.ts—hasProgressgetter (root cause) -
src/vs/workbench/browser/parts/notifications/notificationsViewer.ts— close button render logic, PROGRESS event handler -
src/vs/workbench/browser/parts/notifications/notificationsCenter.ts—clearAllAction.enabled,clearAll() -
VS Code Version: latest
main -
OS: Windows / macOS / Linux (platform-independent)
Activity
Fix completed progress notification dismissal (#315184)
Fix completed progress notification dismissal (microsoft#315184)