@codingame/monaco-vscode-remote-agent-service-override 3.2.3 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/package.json +3 -3
  2. package/remoteAgent.js +9 -9
  3. package/external/rollup-plugin-styles/dist/runtime/inject-css.js +0 -3
  4. package/override/vs/platform/dialogs/common/dialogs.js +0 -8
  5. package/vscode/src/vs/platform/download/common/downloadIpc.js +0 -18
  6. package/vscode/src/vs/platform/log/common/logIpc.js +0 -26
  7. package/vscode/src/vs/platform/remote/browser/remoteAuthorityResolverService.js +0 -110
  8. package/vscode/src/vs/workbench/contrib/remote/browser/explorerViewItems.js +0 -135
  9. package/vscode/src/vs/workbench/contrib/remote/browser/media/remoteViewlet.css.js +0 -6
  10. package/vscode/src/vs/workbench/contrib/remote/browser/remote.contribution.js +0 -19
  11. package/vscode/src/vs/workbench/contrib/remote/browser/remote.js +0 -831
  12. package/vscode/src/vs/workbench/contrib/remote/browser/remoteConnectionHealth.js +0 -158
  13. package/vscode/src/vs/workbench/contrib/remote/browser/remoteIndicator.js +0 -774
  14. package/vscode/src/vs/workbench/contrib/remote/browser/remoteStartEntry.contribution.js +0 -6
  15. package/vscode/src/vs/workbench/contrib/remote/browser/remoteStartEntry.js +0 -97
  16. package/vscode/src/vs/workbench/contrib/remote/browser/showCandidate.js +0 -35
  17. package/vscode/src/vs/workbench/contrib/remote/browser/tunnelFactory.js +0 -110
  18. package/vscode/src/vs/workbench/contrib/remote/common/remote.contribution.js +0 -515
  19. package/vscode/src/vs/workbench/services/remote/browser/browserRemoteResourceHandler.js +0 -49
  20. package/vscode/src/vs/workbench/services/remote/browser/remoteAgentService.js +0 -78
  21. package/vscode/src/vs/workbench/services/remote/common/abstractRemoteAgentService.js +0 -179
  22. package/vscode/src/vs/workbench/services/remote/common/remoteAgentEnvironmentChannel.js +0 -54
  23. package/vscode/src/vs/workbench/services/remote/common/remoteExtensionsScanner.js +0 -73
  24. package/vscode/src/vs/workbench/services/tunnel/browser/tunnelService.js +0 -36
@@ -1,774 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import { localize2WithPath, localizeWithPath } from 'vscode/vscode/vs/nls';
3
- import { remoteConnectionLatencyMeasurer, IRemoteAgentService } from 'vscode/vscode/vs/workbench/services/remote/common/remoteAgentService';
4
- import { RunOnceScheduler, retry } from 'vscode/vscode/vs/base/common/async';
5
- import { Emitter, Event } from 'vscode/vscode/vs/base/common/event';
6
- import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
7
- import { MenuId, registerAction2, Action2, MenuRegistry, MenuItemAction, IMenuService } from 'vscode/vscode/vs/platform/actions/common/actions';
8
- import { IStatusbarService } from 'vscode/vscode/vs/workbench/services/statusbar/browser/statusbar';
9
- import { ILabelService } from 'vscode/vscode/vs/platform/label/common/label';
10
- import { RawContextKey, ContextKeyExpr, IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
11
- import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands';
12
- import { Schemas } from 'vscode/vscode/vs/base/common/network';
13
- import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions';
14
- import { IQuickInputService } from 'vscode/vscode/vs/platform/quickinput/common/quickInput';
15
- import { IBrowserWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/browser/environmentService';
16
- import { IRemoteAuthorityResolverService } from 'vscode/vscode/vs/platform/remote/common/remoteAuthorityResolver';
17
- import { IHostService } from 'vscode/vscode/vs/workbench/services/host/browser/host';
18
- import { isWeb, PlatformToString, platform } from 'vscode/vscode/vs/base/common/platform';
19
- import { truncate } from 'vscode/vscode/vs/base/common/strings';
20
- import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace';
21
- import { getRemoteName } from 'vscode/vscode/vs/platform/remote/common/remoteHosts';
22
- import { getVirtualWorkspaceLocation } from 'vscode/vscode/vs/platform/workspace/common/virtualWorkspace';
23
- import { getCodiconAriaLabel } from 'vscode/vscode/vs/base/common/iconLabels';
24
- import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
25
- import { ReloadWindowAction } from 'vscode/vscode/vs/workbench/browser/actions/windowActions';
26
- import { EXTENSION_INSTALL_SKIP_WALKTHROUGH_CONTEXT, IExtensionGalleryService, IExtensionManagementService } from 'vscode/vscode/vs/platform/extensionManagement/common/extensionManagement';
27
- import { VIEWLET_ID, LIST_WORKSPACE_UNSUPPORTED_EXTENSIONS_COMMAND_ID } from 'vscode/vscode/vs/workbench/contrib/extensions/common/extensions';
28
- import { MarkdownString } from 'vscode/vscode/vs/base/common/htmlContent';
29
- import { RemoteNameContext, VirtualWorkspaceContext } from 'vscode/vscode/vs/workbench/common/contextkeys';
30
- import { IPaneCompositePartService } from 'vscode/vscode/vs/workbench/services/panecomposite/browser/panecomposite';
31
- import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry';
32
- import { IProductService } from 'vscode/vscode/vs/platform/product/common/productService';
33
- import { DomEmitter } from 'vscode/vscode/vs/base/browser/event';
34
- import { ExtensionIdentifier } from 'vscode/vscode/vs/platform/extensions/common/extensions';
35
- import { CancellationToken } from 'vscode/vscode/vs/base/common/cancellation';
36
- import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
37
- import { infoIcon } from 'vscode/vscode/vs/workbench/contrib/extensions/browser/extensionsIcons';
38
- import { IOpenerService } from 'vscode/vscode/vs/platform/opener/common/opener';
39
- import { URI } from 'vscode/vscode/vs/base/common/uri';
40
- import { mainWindow } from 'vscode/vscode/vs/base/browser/window';
41
-
42
- var RemoteStatusIndicator_1;
43
- let RemoteStatusIndicator = class RemoteStatusIndicator extends Disposable {
44
- static { RemoteStatusIndicator_1 = this; }
45
- static { this.ID = 'workbench.contrib.remoteStatusIndicator'; }
46
- static { this.REMOTE_ACTIONS_COMMAND_ID = 'workbench.action.remote.showMenu'; }
47
- static { this.CLOSE_REMOTE_COMMAND_ID = 'workbench.action.remote.close'; }
48
- static { this.SHOW_CLOSE_REMOTE_COMMAND_ID = !isWeb; }
49
- static { this.INSTALL_REMOTE_EXTENSIONS_ID = 'workbench.action.remote.extensions'; }
50
- static { this.REMOTE_STATUS_LABEL_MAX_LENGTH = 40; }
51
- static { this.REMOTE_CONNECTION_LATENCY_SCHEDULER_DELAY = 60 * 1000; }
52
- static { this.REMOTE_CONNECTION_LATENCY_SCHEDULER_FIRST_RUN_DELAY = 10 * 1000; }
53
- constructor(statusbarService, environmentService, labelService, contextKeyService, menuService, quickInputService, commandService, extensionService, remoteAgentService, remoteAuthorityResolverService, hostService, workspaceContextService, logService, extensionGalleryService, telemetryService, productService, extensionManagementService, openerService) {
54
- super();
55
- this.statusbarService = statusbarService;
56
- this.environmentService = environmentService;
57
- this.labelService = labelService;
58
- this.contextKeyService = contextKeyService;
59
- this.menuService = menuService;
60
- this.quickInputService = quickInputService;
61
- this.commandService = commandService;
62
- this.extensionService = extensionService;
63
- this.remoteAgentService = remoteAgentService;
64
- this.remoteAuthorityResolverService = remoteAuthorityResolverService;
65
- this.hostService = hostService;
66
- this.workspaceContextService = workspaceContextService;
67
- this.logService = logService;
68
- this.extensionGalleryService = extensionGalleryService;
69
- this.telemetryService = telemetryService;
70
- this.productService = productService;
71
- this.extensionManagementService = extensionManagementService;
72
- this.openerService = openerService;
73
- this.legacyIndicatorMenu = this._register(this.menuService.createMenu(MenuId.StatusBarWindowIndicatorMenu, this.contextKeyService));
74
- this.remoteIndicatorMenu = this._register(this.menuService.createMenu(MenuId.StatusBarRemoteIndicatorMenu, this.contextKeyService));
75
- this.remoteAuthority = this.environmentService.remoteAuthority;
76
- this.virtualWorkspaceLocation = undefined;
77
- this.connectionState = undefined;
78
- this.connectionToken = undefined;
79
- this.connectionStateContextKey = ( new RawContextKey('remoteConnectionState', '')).bindTo(this.contextKeyService);
80
- this.networkState = undefined;
81
- this.measureNetworkConnectionLatencyScheduler = undefined;
82
- this.loggedInvalidGroupNames = Object.create(null);
83
- this.remoteMetadataInitialized = false;
84
- this._onDidChangeEntries = this._register(( new Emitter()));
85
- this.onDidChangeEntries = this._onDidChangeEntries.event;
86
- const remoteExtensionTips = { ...this.productService.remoteExtensionTips, ...this.productService.virtualWorkspaceExtensionTips };
87
- this.remoteExtensionMetadata = ( ( Object.values(remoteExtensionTips)).filter(value => value.startEntry !== undefined).map(value => {
88
- return {
89
- id: value.extensionId,
90
- installed: false,
91
- friendlyName: value.friendlyName,
92
- isPlatformCompatible: false,
93
- dependencies: [],
94
- helpLink: value.startEntry?.helpLink ?? '',
95
- startConnectLabel: value.startEntry?.startConnectLabel ?? '',
96
- startCommand: value.startEntry?.startCommand ?? '',
97
- priority: value.startEntry?.priority ?? 10,
98
- supportedPlatforms: value.supportedPlatforms
99
- };
100
- }));
101
- this.remoteExtensionMetadata.sort((ext1, ext2) => ext1.priority - ext2.priority);
102
- if (this.remoteAuthority) {
103
- this.connectionState = 'initializing';
104
- this.connectionStateContextKey.set(this.connectionState);
105
- }
106
- else {
107
- this.updateVirtualWorkspaceLocation();
108
- }
109
- this.registerActions();
110
- this.registerListeners();
111
- this.updateWhenInstalledExtensionsRegistered();
112
- this.updateRemoteStatusIndicator();
113
- }
114
- registerActions() {
115
- const category = ( localize2WithPath(
116
- 'vs/workbench/contrib/remote/browser/remoteIndicator',
117
- 'remote.category',
118
- "Remote"
119
- ));
120
- const that = this;
121
- registerAction2(class extends Action2 {
122
- constructor() {
123
- super({
124
- id: RemoteStatusIndicator_1.REMOTE_ACTIONS_COMMAND_ID,
125
- category,
126
- title: ( localize2WithPath(
127
- 'vs/workbench/contrib/remote/browser/remoteIndicator',
128
- 'remote.showMenu',
129
- "Show Remote Menu"
130
- )),
131
- f1: true,
132
- keybinding: {
133
- weight: 200 ,
134
- primary: 2048 | 512 | 45 ,
135
- }
136
- });
137
- this.run = () => that.showRemoteMenu();
138
- }
139
- });
140
- if (RemoteStatusIndicator_1.SHOW_CLOSE_REMOTE_COMMAND_ID) {
141
- registerAction2(class extends Action2 {
142
- constructor() {
143
- super({
144
- id: RemoteStatusIndicator_1.CLOSE_REMOTE_COMMAND_ID,
145
- category,
146
- title: ( localize2WithPath(
147
- 'vs/workbench/contrib/remote/browser/remoteIndicator',
148
- 'remote.close',
149
- "Close Remote Connection"
150
- )),
151
- f1: true,
152
- precondition: ( ContextKeyExpr.or(RemoteNameContext, VirtualWorkspaceContext))
153
- });
154
- this.run = () => that.hostService.openWindow({ forceReuseWindow: true, remoteAuthority: null });
155
- }
156
- });
157
- if (this.remoteAuthority) {
158
- MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
159
- group: '6_close',
160
- command: {
161
- id: RemoteStatusIndicator_1.CLOSE_REMOTE_COMMAND_ID,
162
- title: ( localizeWithPath(
163
- 'vs/workbench/contrib/remote/browser/remoteIndicator',
164
- { key: 'miCloseRemote', comment: ['&& denotes a mnemonic'] },
165
- "Close Re&&mote Connection"
166
- ))
167
- },
168
- order: 3.5
169
- });
170
- }
171
- }
172
- if (this.extensionGalleryService.isEnabled()) {
173
- registerAction2(class extends Action2 {
174
- constructor() {
175
- super({
176
- id: RemoteStatusIndicator_1.INSTALL_REMOTE_EXTENSIONS_ID,
177
- category,
178
- title: ( localize2WithPath(
179
- 'vs/workbench/contrib/remote/browser/remoteIndicator',
180
- 'remote.install',
181
- "Install Remote Development Extensions"
182
- )),
183
- f1: true
184
- });
185
- this.run = (accessor, input) => {
186
- const paneCompositeService = accessor.get(IPaneCompositePartService);
187
- return paneCompositeService.openPaneComposite(VIEWLET_ID, 0 , true).then(viewlet => {
188
- if (viewlet) {
189
- (viewlet?.getViewPaneContainer()).search(`@recommended:remotes`);
190
- viewlet.focus();
191
- }
192
- });
193
- };
194
- }
195
- });
196
- }
197
- }
198
- registerListeners() {
199
- const updateRemoteActions = () => {
200
- this.remoteMenuActionsGroups = undefined;
201
- this.updateRemoteStatusIndicator();
202
- };
203
- this._register(this.legacyIndicatorMenu.onDidChange(updateRemoteActions));
204
- this._register(this.remoteIndicatorMenu.onDidChange(updateRemoteActions));
205
- this._register(this.labelService.onDidChangeFormatters(() => this.updateRemoteStatusIndicator()));
206
- const remoteIndicator = this.environmentService.options?.windowIndicator;
207
- if (remoteIndicator && remoteIndicator.onDidChange) {
208
- this._register(remoteIndicator.onDidChange(() => this.updateRemoteStatusIndicator()));
209
- }
210
- if (this.remoteAuthority) {
211
- const connection = this.remoteAgentService.getConnection();
212
- if (connection) {
213
- this._register(connection.onDidStateChange((e) => {
214
- switch (e.type) {
215
- case 0 :
216
- case 2 :
217
- case 1 :
218
- this.setConnectionState('reconnecting');
219
- break;
220
- case 3 :
221
- this.setConnectionState('disconnected');
222
- break;
223
- case 4 :
224
- this.setConnectionState('connected');
225
- break;
226
- }
227
- }));
228
- }
229
- }
230
- else {
231
- this._register(this.workspaceContextService.onDidChangeWorkbenchState(() => {
232
- this.updateVirtualWorkspaceLocation();
233
- this.updateRemoteStatusIndicator();
234
- }));
235
- }
236
- if (isWeb) {
237
- this._register(Event.any(this._register(( new DomEmitter(mainWindow, 'online'))).event, this._register(( new DomEmitter(mainWindow, 'offline'))).event)(() => this.setNetworkState(navigator.onLine ? 'online' : 'offline')));
238
- }
239
- this._register(this.extensionService.onDidChangeExtensions(async (result) => {
240
- for (const ext of result.added) {
241
- const index = this.remoteExtensionMetadata.findIndex(value => ExtensionIdentifier.equals(value.id, ext.identifier));
242
- if (index > -1) {
243
- this.remoteExtensionMetadata[index].installed = true;
244
- }
245
- }
246
- }));
247
- this._register(this.extensionManagementService.onDidUninstallExtension(async (result) => {
248
- const index = this.remoteExtensionMetadata.findIndex(value => ExtensionIdentifier.equals(value.id, result.identifier.id));
249
- if (index > -1) {
250
- this.remoteExtensionMetadata[index].installed = false;
251
- }
252
- }));
253
- }
254
- async initializeRemoteMetadata() {
255
- if (this.remoteMetadataInitialized) {
256
- return;
257
- }
258
- const currentPlatform = PlatformToString(platform);
259
- for (let i = 0; i < this.remoteExtensionMetadata.length; i++) {
260
- const extensionId = this.remoteExtensionMetadata[i].id;
261
- const supportedPlatforms = this.remoteExtensionMetadata[i].supportedPlatforms;
262
- const isInstalled = (await this.extensionManagementService.getInstalled()).find(value => ExtensionIdentifier.equals(value.identifier.id, extensionId)) ? true : false;
263
- this.remoteExtensionMetadata[i].installed = isInstalled;
264
- if (isInstalled) {
265
- this.remoteExtensionMetadata[i].isPlatformCompatible = true;
266
- }
267
- else if (supportedPlatforms && !supportedPlatforms.includes(currentPlatform)) {
268
- this.remoteExtensionMetadata[i].isPlatformCompatible = false;
269
- }
270
- else {
271
- this.remoteExtensionMetadata[i].isPlatformCompatible = true;
272
- }
273
- }
274
- this.remoteMetadataInitialized = true;
275
- this._onDidChangeEntries.fire();
276
- this.updateRemoteStatusIndicator();
277
- }
278
- updateVirtualWorkspaceLocation() {
279
- this.virtualWorkspaceLocation = getVirtualWorkspaceLocation(this.workspaceContextService.getWorkspace());
280
- }
281
- async updateWhenInstalledExtensionsRegistered() {
282
- await this.extensionService.whenInstalledExtensionsRegistered();
283
- const remoteAuthority = this.remoteAuthority;
284
- if (remoteAuthority) {
285
- (async () => {
286
- try {
287
- const { authority } = await this.remoteAuthorityResolverService.resolveAuthority(remoteAuthority);
288
- this.connectionToken = authority.connectionToken;
289
- this.setConnectionState('connected');
290
- }
291
- catch (error) {
292
- this.setConnectionState('disconnected');
293
- }
294
- })();
295
- }
296
- this.updateRemoteStatusIndicator();
297
- this.initializeRemoteMetadata();
298
- }
299
- setConnectionState(newState) {
300
- if (this.connectionState !== newState) {
301
- this.connectionState = newState;
302
- if (this.connectionState === 'reconnecting') {
303
- this.connectionStateContextKey.set('disconnected');
304
- }
305
- else {
306
- this.connectionStateContextKey.set(this.connectionState);
307
- }
308
- this.updateRemoteStatusIndicator();
309
- if (newState === 'connected') {
310
- this.scheduleMeasureNetworkConnectionLatency();
311
- }
312
- }
313
- }
314
- scheduleMeasureNetworkConnectionLatency() {
315
- if (!this.remoteAuthority ||
316
- this.measureNetworkConnectionLatencyScheduler
317
- ) {
318
- return;
319
- }
320
- this.measureNetworkConnectionLatencyScheduler = this._register(( new RunOnceScheduler(
321
- () => this.measureNetworkConnectionLatency(),
322
- RemoteStatusIndicator_1.REMOTE_CONNECTION_LATENCY_SCHEDULER_DELAY
323
- )));
324
- this.measureNetworkConnectionLatencyScheduler.schedule(RemoteStatusIndicator_1.REMOTE_CONNECTION_LATENCY_SCHEDULER_FIRST_RUN_DELAY);
325
- }
326
- async measureNetworkConnectionLatency() {
327
- if (this.hostService.hasFocus && this.networkState !== 'offline') {
328
- const measurement = await remoteConnectionLatencyMeasurer.measure(this.remoteAgentService);
329
- if (measurement) {
330
- if (measurement.high) {
331
- this.setNetworkState('high-latency');
332
- }
333
- else if (this.networkState === 'high-latency') {
334
- this.setNetworkState('online');
335
- }
336
- }
337
- }
338
- this.measureNetworkConnectionLatencyScheduler?.schedule();
339
- }
340
- setNetworkState(newState) {
341
- if (this.networkState !== newState) {
342
- const oldState = this.networkState;
343
- this.networkState = newState;
344
- if (newState === 'high-latency') {
345
- this.logService.warn(`Remote network connection appears to have high latency (${remoteConnectionLatencyMeasurer.latency?.current?.toFixed(2)}ms last, ${remoteConnectionLatencyMeasurer.latency?.average?.toFixed(2)}ms average)`);
346
- }
347
- if (this.connectionToken) {
348
- if (newState === 'online' && oldState === 'high-latency') {
349
- this.logNetworkConnectionHealthTelemetry(this.connectionToken, 'good');
350
- }
351
- else if (newState === 'high-latency' && oldState === 'online') {
352
- this.logNetworkConnectionHealthTelemetry(this.connectionToken, 'poor');
353
- }
354
- }
355
- this.updateRemoteStatusIndicator();
356
- }
357
- }
358
- logNetworkConnectionHealthTelemetry(connectionToken, connectionHealth) {
359
- this.telemetryService.publicLog2('remoteConnectionHealth', {
360
- remoteName: getRemoteName(this.remoteAuthority),
361
- reconnectionToken: connectionToken,
362
- connectionHealth
363
- });
364
- }
365
- validatedGroup(group) {
366
- if (!group.match(/^(remote|virtualfs)_(\d\d)_(([a-z][a-z0-9+.-]*)_(.*))$/)) {
367
- if (!this.loggedInvalidGroupNames[group]) {
368
- this.loggedInvalidGroupNames[group] = true;
369
- this.logService.warn(`Invalid group name used in "statusBar/remoteIndicator" menu contribution: ${group}. Entries ignored. Expected format: 'remote_$ORDER_$REMOTENAME_$GROUPING or 'virtualfs_$ORDER_$FILESCHEME_$GROUPING.`);
370
- }
371
- return false;
372
- }
373
- return true;
374
- }
375
- getRemoteMenuActions(doNotUseCache) {
376
- if (!this.remoteMenuActionsGroups || doNotUseCache) {
377
- this.remoteMenuActionsGroups = this.remoteIndicatorMenu.getActions().filter(a => this.validatedGroup(a[0])).concat(this.legacyIndicatorMenu.getActions());
378
- }
379
- return this.remoteMenuActionsGroups;
380
- }
381
- updateRemoteStatusIndicator() {
382
- const remoteIndicator = this.environmentService.options?.windowIndicator;
383
- if (remoteIndicator) {
384
- let remoteIndicatorLabel = remoteIndicator.label.trim();
385
- if (!remoteIndicatorLabel.startsWith('$(')) {
386
- remoteIndicatorLabel = `$(remote) ${remoteIndicatorLabel}`;
387
- }
388
- this.renderRemoteStatusIndicator(truncate(remoteIndicatorLabel, RemoteStatusIndicator_1.REMOTE_STATUS_LABEL_MAX_LENGTH), remoteIndicator.tooltip, remoteIndicator.command);
389
- return;
390
- }
391
- if (this.remoteAuthority) {
392
- const hostLabel = this.labelService.getHostLabel(Schemas.vscodeRemote, this.remoteAuthority) || this.remoteAuthority;
393
- switch (this.connectionState) {
394
- case 'initializing':
395
- this.renderRemoteStatusIndicator(( localizeWithPath(
396
- 'vs/workbench/contrib/remote/browser/remoteIndicator',
397
- 'host.open',
398
- "Opening Remote..."
399
- )), ( localizeWithPath(
400
- 'vs/workbench/contrib/remote/browser/remoteIndicator',
401
- 'host.open',
402
- "Opening Remote..."
403
- )), undefined, true );
404
- break;
405
- case 'reconnecting':
406
- this.renderRemoteStatusIndicator(`${( localizeWithPath(
407
- 'vs/workbench/contrib/remote/browser/remoteIndicator',
408
- 'host.reconnecting',
409
- "Reconnecting to {0}...",
410
- truncate(hostLabel, RemoteStatusIndicator_1.REMOTE_STATUS_LABEL_MAX_LENGTH)
411
- ))}`, undefined, undefined, true );
412
- break;
413
- case 'disconnected':
414
- this.renderRemoteStatusIndicator(`$(alert) ${( localizeWithPath(
415
- 'vs/workbench/contrib/remote/browser/remoteIndicator',
416
- 'disconnectedFrom',
417
- "Disconnected from {0}",
418
- truncate(hostLabel, RemoteStatusIndicator_1.REMOTE_STATUS_LABEL_MAX_LENGTH)
419
- ))}`);
420
- break;
421
- default: {
422
- const tooltip = ( new MarkdownString('', { isTrusted: true, supportThemeIcons: true }));
423
- const hostNameTooltip = this.labelService.getHostTooltip(Schemas.vscodeRemote, this.remoteAuthority);
424
- if (hostNameTooltip) {
425
- tooltip.appendMarkdown(hostNameTooltip);
426
- }
427
- else {
428
- tooltip.appendText(( localizeWithPath(
429
- 'vs/workbench/contrib/remote/browser/remoteIndicator',
430
- { key: 'host.tooltip', comment: ['{0} is a remote host name, e.g. Dev Container'] },
431
- "Editing on {0}",
432
- hostLabel
433
- )));
434
- }
435
- this.renderRemoteStatusIndicator(`$(remote) ${truncate(hostLabel, RemoteStatusIndicator_1.REMOTE_STATUS_LABEL_MAX_LENGTH)}`, tooltip);
436
- }
437
- }
438
- return;
439
- }
440
- if (this.virtualWorkspaceLocation) {
441
- const workspaceLabel = this.labelService.getHostLabel(this.virtualWorkspaceLocation.scheme, this.virtualWorkspaceLocation.authority);
442
- if (workspaceLabel) {
443
- const tooltip = ( new MarkdownString('', { isTrusted: true, supportThemeIcons: true }));
444
- const hostNameTooltip = this.labelService.getHostTooltip(this.virtualWorkspaceLocation.scheme, this.virtualWorkspaceLocation.authority);
445
- if (hostNameTooltip) {
446
- tooltip.appendMarkdown(hostNameTooltip);
447
- }
448
- else {
449
- tooltip.appendText(( localizeWithPath(
450
- 'vs/workbench/contrib/remote/browser/remoteIndicator',
451
- { key: 'workspace.tooltip', comment: ['{0} is a remote workspace name, e.g. GitHub'] },
452
- "Editing on {0}",
453
- workspaceLabel
454
- )));
455
- }
456
- if (!isWeb || this.remoteAuthority) {
457
- tooltip.appendMarkdown('\n\n');
458
- tooltip.appendMarkdown(( localizeWithPath(
459
- 'vs/workbench/contrib/remote/browser/remoteIndicator',
460
- { key: 'workspace.tooltip2', comment: ['[features are not available]({1}) is a link. Only translate `features are not available`. Do not change brackets and parentheses or {0}'] },
461
- "Some [features are not available]({0}) for resources located on a virtual file system.",
462
- `command:${LIST_WORKSPACE_UNSUPPORTED_EXTENSIONS_COMMAND_ID}`
463
- )));
464
- }
465
- this.renderRemoteStatusIndicator(`$(remote) ${truncate(workspaceLabel, RemoteStatusIndicator_1.REMOTE_STATUS_LABEL_MAX_LENGTH)}`, tooltip);
466
- return;
467
- }
468
- }
469
- this.renderRemoteStatusIndicator(`$(remote)`, ( localizeWithPath(
470
- 'vs/workbench/contrib/remote/browser/remoteIndicator',
471
- 'noHost.tooltip',
472
- "Open a Remote Window"
473
- )));
474
- return;
475
- }
476
- renderRemoteStatusIndicator(initialText, initialTooltip, command, showProgress) {
477
- const { text, tooltip, ariaLabel } = this.withNetworkStatus(initialText, initialTooltip, showProgress);
478
- const properties = {
479
- name: ( localizeWithPath(
480
- 'vs/workbench/contrib/remote/browser/remoteIndicator',
481
- 'remoteHost',
482
- "Remote Host"
483
- )),
484
- kind: this.networkState === 'offline' ? 'offline' : 'remote',
485
- ariaLabel,
486
- text,
487
- showProgress,
488
- tooltip,
489
- command: command ?? RemoteStatusIndicator_1.REMOTE_ACTIONS_COMMAND_ID
490
- };
491
- if (this.remoteStatusEntry) {
492
- this.remoteStatusEntry.update(properties);
493
- }
494
- else {
495
- this.remoteStatusEntry = this.statusbarService.addEntry(properties, 'status.host', 0 , Number.MAX_VALUE );
496
- }
497
- }
498
- withNetworkStatus(initialText, initialTooltip, showProgress) {
499
- let text = initialText;
500
- let tooltip = initialTooltip;
501
- let ariaLabel = getCodiconAriaLabel(text);
502
- function textWithAlert() {
503
- if (!showProgress && initialText.startsWith('$(remote)')) {
504
- return initialText.replace('$(remote)', '$(alert)');
505
- }
506
- return initialText;
507
- }
508
- switch (this.networkState) {
509
- case 'offline': {
510
- const offlineMessage = ( localizeWithPath(
511
- 'vs/workbench/contrib/remote/browser/remoteIndicator',
512
- 'networkStatusOfflineTooltip',
513
- "Network appears to be offline, certain features might be unavailable."
514
- ));
515
- text = textWithAlert();
516
- tooltip = this.appendTooltipLine(tooltip, offlineMessage);
517
- ariaLabel = `${ariaLabel}, ${offlineMessage}`;
518
- break;
519
- }
520
- case 'high-latency':
521
- text = textWithAlert();
522
- tooltip = this.appendTooltipLine(tooltip, ( localizeWithPath(
523
- 'vs/workbench/contrib/remote/browser/remoteIndicator',
524
- 'networkStatusHighLatencyTooltip',
525
- "Network appears to have high latency ({0}ms last, {1}ms average), certain features may be slow to respond.",
526
- remoteConnectionLatencyMeasurer.latency?.current?.toFixed(2),
527
- remoteConnectionLatencyMeasurer.latency?.average?.toFixed(2)
528
- )));
529
- break;
530
- }
531
- return { text, tooltip, ariaLabel };
532
- }
533
- appendTooltipLine(tooltip, line) {
534
- let markdownTooltip;
535
- if (typeof tooltip === 'string') {
536
- markdownTooltip = ( new MarkdownString(tooltip, { isTrusted: true, supportThemeIcons: true }));
537
- }
538
- else {
539
- markdownTooltip = tooltip ?? ( new MarkdownString('', { isTrusted: true, supportThemeIcons: true }));
540
- }
541
- if (markdownTooltip.value.length > 0) {
542
- markdownTooltip.appendMarkdown('\n\n');
543
- }
544
- markdownTooltip.appendMarkdown(line);
545
- return markdownTooltip;
546
- }
547
- async installExtension(extensionId) {
548
- const galleryExtension = (await this.extensionGalleryService.getExtensions([{ id: extensionId }], CancellationToken.None))[0];
549
- await this.extensionManagementService.installFromGallery(galleryExtension, {
550
- isMachineScoped: false,
551
- donotIncludePackAndDependencies: false,
552
- context: { [EXTENSION_INSTALL_SKIP_WALKTHROUGH_CONTEXT]: true }
553
- });
554
- }
555
- async runRemoteStartCommand(extensionId, startCommand) {
556
- await retry(async () => {
557
- const ext = await this.extensionService.getExtension(extensionId);
558
- if (!ext) {
559
- throw Error('Failed to find installed remote extension');
560
- }
561
- return ext;
562
- }, 300, 10);
563
- this.commandService.executeCommand(startCommand);
564
- this.telemetryService.publicLog2('workbenchActionExecuted', {
565
- id: 'remoteInstallAndRun',
566
- detail: extensionId,
567
- from: 'remote indicator'
568
- });
569
- }
570
- showRemoteMenu() {
571
- const getCategoryLabel = (action) => {
572
- if (action.item.category) {
573
- return typeof action.item.category === 'string' ? action.item.category : action.item.category.value;
574
- }
575
- return undefined;
576
- };
577
- const matchCurrentRemote = () => {
578
- if (this.remoteAuthority) {
579
- return ( new RegExp(`^remote_\\d\\d_${getRemoteName(this.remoteAuthority)}_`));
580
- }
581
- else if (this.virtualWorkspaceLocation) {
582
- return ( new RegExp(`^virtualfs_\\d\\d_${this.virtualWorkspaceLocation.scheme}_`));
583
- }
584
- return undefined;
585
- };
586
- const computeItems = () => {
587
- let actionGroups = this.getRemoteMenuActions(true);
588
- const items = [];
589
- const currentRemoteMatcher = matchCurrentRemote();
590
- if (currentRemoteMatcher) {
591
- actionGroups = actionGroups.sort((g1, g2) => {
592
- const isCurrentRemote1 = currentRemoteMatcher.test(g1[0]);
593
- const isCurrentRemote2 = currentRemoteMatcher.test(g2[0]);
594
- if (isCurrentRemote1 !== isCurrentRemote2) {
595
- return isCurrentRemote1 ? -1 : 1;
596
- }
597
- if (g1[0] !== '' && g2[0] === '') {
598
- return -1;
599
- }
600
- else if (g1[0] === '' && g2[0] !== '') {
601
- return 1;
602
- }
603
- return g1[0].localeCompare(g2[0]);
604
- });
605
- }
606
- let lastCategoryName = undefined;
607
- for (const actionGroup of actionGroups) {
608
- let hasGroupCategory = false;
609
- for (const action of actionGroup[1]) {
610
- if (action instanceof MenuItemAction) {
611
- if (!hasGroupCategory) {
612
- const category = getCategoryLabel(action);
613
- if (category !== lastCategoryName) {
614
- items.push({ type: 'separator', label: category });
615
- lastCategoryName = category;
616
- }
617
- hasGroupCategory = true;
618
- }
619
- const label = typeof action.item.title === 'string' ? action.item.title : action.item.title.value;
620
- items.push({
621
- type: 'item',
622
- id: action.item.id,
623
- label
624
- });
625
- }
626
- }
627
- }
628
- if (this.extensionGalleryService.isEnabled() && this.remoteMetadataInitialized) {
629
- const notInstalledItems = [];
630
- for (const metadata of this.remoteExtensionMetadata) {
631
- if (!metadata.installed && metadata.isPlatformCompatible) {
632
- const label = metadata.startConnectLabel;
633
- const buttons = [{
634
- iconClass: ThemeIcon.asClassName(infoIcon),
635
- tooltip: ( localizeWithPath(
636
- 'vs/workbench/contrib/remote/browser/remoteIndicator',
637
- 'remote.startActions.help',
638
- "Learn More"
639
- ))
640
- }];
641
- notInstalledItems.push({ type: 'item', id: metadata.id, label: label, buttons: buttons });
642
- }
643
- }
644
- items.push({
645
- type: 'separator', label: ( localizeWithPath(
646
- 'vs/workbench/contrib/remote/browser/remoteIndicator',
647
- 'remote.startActions.install',
648
- 'Install'
649
- ))
650
- });
651
- items.push(...notInstalledItems);
652
- }
653
- items.push({
654
- type: 'separator'
655
- });
656
- const entriesBeforeConfig = items.length;
657
- if (RemoteStatusIndicator_1.SHOW_CLOSE_REMOTE_COMMAND_ID) {
658
- if (this.remoteAuthority) {
659
- items.push({
660
- type: 'item',
661
- id: RemoteStatusIndicator_1.CLOSE_REMOTE_COMMAND_ID,
662
- label: ( localizeWithPath(
663
- 'vs/workbench/contrib/remote/browser/remoteIndicator',
664
- 'closeRemoteConnection.title',
665
- 'Close Remote Connection'
666
- ))
667
- });
668
- if (this.connectionState === 'disconnected') {
669
- items.push({
670
- type: 'item',
671
- id: ReloadWindowAction.ID,
672
- label: ( localizeWithPath(
673
- 'vs/workbench/contrib/remote/browser/remoteIndicator',
674
- 'reloadWindow',
675
- 'Reload Window'
676
- ))
677
- });
678
- }
679
- }
680
- else if (this.virtualWorkspaceLocation) {
681
- items.push({
682
- type: 'item',
683
- id: RemoteStatusIndicator_1.CLOSE_REMOTE_COMMAND_ID,
684
- label: ( localizeWithPath(
685
- 'vs/workbench/contrib/remote/browser/remoteIndicator',
686
- 'closeVirtualWorkspace.title',
687
- 'Close Remote Workspace'
688
- ))
689
- });
690
- }
691
- }
692
- if (items.length === entriesBeforeConfig) {
693
- items.pop();
694
- }
695
- return items;
696
- };
697
- const quickPick = this.quickInputService.createQuickPick();
698
- quickPick.placeholder = ( localizeWithPath(
699
- 'vs/workbench/contrib/remote/browser/remoteIndicator',
700
- 'remoteActions',
701
- "Select an option to open a Remote Window"
702
- ));
703
- quickPick.items = computeItems();
704
- quickPick.sortByLabel = false;
705
- quickPick.canSelectMany = false;
706
- Event.once(quickPick.onDidAccept)((async (_) => {
707
- const selectedItems = quickPick.selectedItems;
708
- if (selectedItems.length === 1) {
709
- const commandId = selectedItems[0].id;
710
- const remoteExtension = this.remoteExtensionMetadata.find(value => ExtensionIdentifier.equals(value.id, commandId));
711
- if (remoteExtension) {
712
- quickPick.items = [];
713
- quickPick.busy = true;
714
- quickPick.placeholder = ( localizeWithPath(
715
- 'vs/workbench/contrib/remote/browser/remoteIndicator',
716
- 'remote.startActions.installingExtension',
717
- 'Installing extension... '
718
- ));
719
- await this.installExtension(remoteExtension.id);
720
- quickPick.hide();
721
- await this.runRemoteStartCommand(remoteExtension.id, remoteExtension.startCommand);
722
- }
723
- else {
724
- this.telemetryService.publicLog2('workbenchActionExecuted', {
725
- id: commandId,
726
- from: 'remote indicator'
727
- });
728
- this.commandService.executeCommand(commandId);
729
- quickPick.hide();
730
- }
731
- }
732
- }));
733
- Event.once(quickPick.onDidTriggerItemButton)(async (e) => {
734
- const remoteExtension = this.remoteExtensionMetadata.find(value => ExtensionIdentifier.equals(value.id, e.item.id));
735
- if (remoteExtension) {
736
- await this.openerService.open(( URI.parse(remoteExtension.helpLink)));
737
- }
738
- });
739
- const legacyItemUpdater = this.legacyIndicatorMenu.onDidChange(() => quickPick.items = computeItems());
740
- quickPick.onDidHide(legacyItemUpdater.dispose);
741
- const itemUpdater = this.remoteIndicatorMenu.onDidChange(() => quickPick.items = computeItems());
742
- quickPick.onDidHide(itemUpdater.dispose);
743
- if (!this.remoteMetadataInitialized) {
744
- quickPick.busy = true;
745
- this._register(this.onDidChangeEntries(() => {
746
- quickPick.busy = false;
747
- quickPick.items = computeItems();
748
- }));
749
- }
750
- quickPick.show();
751
- }
752
- };
753
- RemoteStatusIndicator = RemoteStatusIndicator_1 = ( __decorate([
754
- ( __param(0, IStatusbarService)),
755
- ( __param(1, IBrowserWorkbenchEnvironmentService)),
756
- ( __param(2, ILabelService)),
757
- ( __param(3, IContextKeyService)),
758
- ( __param(4, IMenuService)),
759
- ( __param(5, IQuickInputService)),
760
- ( __param(6, ICommandService)),
761
- ( __param(7, IExtensionService)),
762
- ( __param(8, IRemoteAgentService)),
763
- ( __param(9, IRemoteAuthorityResolverService)),
764
- ( __param(10, IHostService)),
765
- ( __param(11, IWorkspaceContextService)),
766
- ( __param(12, ILogService)),
767
- ( __param(13, IExtensionGalleryService)),
768
- ( __param(14, ITelemetryService)),
769
- ( __param(15, IProductService)),
770
- ( __param(16, IExtensionManagementService)),
771
- ( __param(17, IOpenerService))
772
- ], RemoteStatusIndicator));
773
-
774
- export { RemoteStatusIndicator };