Skip to content

Commit b97f713

Browse files
authored
notifications - review visibility handling (microsoft#252031)
1 parent d46348a commit b97f713

File tree

7 files changed

+25
-8
lines changed

7 files changed

+25
-8
lines changed

src/vs/workbench/api/browser/mainThreadMessageService.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { IAction, toAction } from '../../../base/common/actions.js';
99
import { MainThreadMessageServiceShape, MainContext, MainThreadMessageOptions } from '../common/extHost.protocol.js';
1010
import { extHostNamedCustomer, IExtHostContext } from '../../services/extensions/common/extHostCustomers.js';
1111
import { IDialogService, IPromptButton } from '../../../platform/dialogs/common/dialogs.js';
12-
import { INotificationService, INotificationSource } from '../../../platform/notification/common/notification.js';
12+
import { INotificationService, INotificationSource, NotificationPriority } from '../../../platform/notification/common/notification.js';
1313
import { Event } from '../../../base/common/event.js';
1414
import { ICommandService } from '../../../platform/commands/common/commands.js';
1515
import { IExtensionService } from '../../services/extensions/common/extensions.js';
@@ -20,6 +20,11 @@ export class MainThreadMessageService implements MainThreadMessageServiceShape {
2020

2121
private extensionsListener: IDisposable;
2222

23+
private static readonly URGENT_NOTIFICATION_SOURCES = [
24+
'vscode.github-authentication',
25+
'vscode.microsoft-authentication'
26+
];
27+
2328
constructor(
2429
extHostContext: IExtHostContext,
2530
@INotificationService private readonly _notificationService: INotificationService,
@@ -61,11 +66,13 @@ export class MainThreadMessageService implements MainThreadMessageServiceShape {
6166
}));
6267

6368
let source: string | INotificationSource | undefined;
69+
let sourceIsUrgent = false;
6470
if (options.source) {
6571
source = {
6672
label: options.source.label,
6773
id: options.source.identifier.value
6874
};
75+
sourceIsUrgent = MainThreadMessageService.URGENT_NOTIFICATION_SOURCES.includes(source.id);
6976
}
7077

7178
if (!source) {
@@ -87,7 +94,9 @@ export class MainThreadMessageService implements MainThreadMessageServiceShape {
8794
severity,
8895
message,
8996
actions: { primary: primaryActions, secondary: secondaryActions },
90-
source
97+
source,
98+
priority: sourceIsUrgent ? NotificationPriority.URGENT : NotificationPriority.DEFAULT,
99+
sticky: sourceIsUrgent
91100
});
92101

93102
// if promise has not been resolved yet, now is the time to ensure a return value

src/vs/workbench/api/browser/mainThreadProgress.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,16 @@ import { ICommandService } from '../../../platform/commands/common/commands.js';
1010
import { localize } from '../../../nls.js';
1111
import { onUnexpectedExternalError } from '../../../base/common/errors.js';
1212
import { toAction } from '../../../base/common/actions.js';
13+
import { NotificationPriority } from '../../../platform/notification/common/notification.js';
1314

1415
@extHostNamedCustomer(MainContext.MainThreadProgress)
1516
export class MainThreadProgress implements MainThreadProgressShape {
1617

18+
private static readonly URGENT_PROGRESS_SOURCES = [
19+
'vscode.github-authentication',
20+
'vscode.microsoft-authentication'
21+
];
22+
1723
private readonly _progressService: IProgressService;
1824
private _progress = new Map<number, { resolve: () => void; progress: IProgress<IProgressStep> }>();
1925
private readonly _proxy: ExtHostProgressShape;
@@ -36,8 +42,10 @@ export class MainThreadProgress implements MainThreadProgressShape {
3642
const task = this._createTask(handle);
3743

3844
if (options.location === ProgressLocation.Notification && extensionId) {
45+
const sourceIsUrgent = MainThreadProgress.URGENT_PROGRESS_SOURCES.includes(extensionId);
3946
const notificationOptions: IProgressNotificationOptions = {
4047
...options,
48+
priority: sourceIsUrgent ? NotificationPriority.URGENT : NotificationPriority.DEFAULT,
4149
location: ProgressLocation.Notification,
4250
secondaryActions: [toAction({
4351
id: extensionId,

src/vs/workbench/browser/parts/notifications/notificationsToasts.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ export class NotificationsToasts extends Themable implements INotificationsToast
4646
private static readonly MAX_NOTIFICATIONS = 3;
4747

4848
private static readonly PURGE_TIMEOUT: { [severity: number]: number } = {
49-
[Severity.Info]: 15000,
50-
[Severity.Warning]: 18000,
51-
[Severity.Error]: 20000
49+
[Severity.Info]: 10000,
50+
[Severity.Warning]: 12000,
51+
[Severity.Error]: 15000
5252
};
5353

5454
private static readonly SPAM_PROTECTION = {

src/vs/workbench/contrib/surveys/browser/languageSurveys.contribution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class LanguageSurvey extends Disposable {
119119
storageService.store(SKIP_VERSION_KEY, productService.version, StorageScope.APPLICATION, StorageTarget.USER);
120120
}
121121
}],
122-
{ sticky: true, priority: NotificationPriority.OPTIONAL }
122+
{ priority: NotificationPriority.OPTIONAL }
123123
);
124124
}
125125
}

src/vs/workbench/contrib/surveys/browser/nps.contribution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class NPSContribution implements IWorkbenchContribution {
8787
storageService.store(SKIP_VERSION_KEY, productService.version, StorageScope.APPLICATION, StorageTarget.USER);
8888
}
8989
}],
90-
{ sticky: true, priority: NotificationPriority.URGENT }
90+
{ priority: NotificationPriority.URGENT }
9191
);
9292
}
9393
}

src/vs/workbench/contrib/terminalContrib/wslRecommendation/browser/terminal.wslRecommendation.contribution.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ export class TerminalWslRecommendationContribution extends Disposable implements
6666
}
6767
],
6868
{
69-
sticky: true,
7069
priority: NotificationPriority.OPTIONAL,
7170
neverShowAgain: { id: 'terminalConfigHelper/launchRecommendationsIgnore', scope: NeverShowAgainScope.APPLICATION },
7271
onCancel: () => { }

src/vs/workbench/services/progress/browser/progressService.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ export class ProgressService extends Disposable implements IProgressService {
338338
// shows again.
339339
let windowProgressDisposable: IDisposable | undefined = undefined;
340340
const onVisibilityChange = (visible: boolean) => {
341+
341342
// Clear any previous running window progress
342343
dispose(windowProgressDisposable);
343344

0 commit comments

Comments
 (0)