Metered network connections support (#288919)

Includes public API, user setting, status bar icon and a new service to support metered network connections.
Updates code in various areas performing automated actions using network to delay/pause network operations while network connection is being metered.
This commit is contained in:
Dmitriy Vasyura
2026-02-06 14:52:14 -08:00
committed by GitHub
parent acab057679
commit fa6cfe12c6
51 changed files with 763 additions and 33 deletions

View File

@@ -118,6 +118,7 @@ import { IExtHostWindow } from './extHostWindow.js';
import { IExtHostPower } from './extHostPower.js';
import { IExtHostWorkspace } from './extHostWorkspace.js';
import { ExtHostChatContext } from './extHostChatContext.js';
import { IExtHostMeteredConnection } from './extHostMeteredConnection.js';
export interface IExtensionRegistries {
mine: ExtensionDescriptionRegistry;
@@ -160,6 +161,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
const extHostLanguageModels = accessor.get(IExtHostLanguageModels);
const extHostMcp = accessor.get(IExtHostMpcService);
const extHostDataChannels = accessor.get(IExtHostDataChannels);
const extHostMeteredConnection = accessor.get(IExtHostMeteredConnection);
// register addressable instances
rpcProtocol.set(ExtHostContext.ExtHostFileSystemInfo, extHostFileSystemInfo);
@@ -181,6 +183,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
rpcProtocol.set(ExtHostContext.ExtHostAuthentication, extHostAuthentication);
rpcProtocol.set(ExtHostContext.ExtHostChatProvider, extHostLanguageModels);
rpcProtocol.set(ExtHostContext.ExtHostDataChannels, extHostDataChannels);
rpcProtocol.set(ExtHostContext.ExtHostMeteredConnection, extHostMeteredConnection);
// automatically create and register addressable instances
const extHostDecorations = rpcProtocol.set(ExtHostContext.ExtHostDecorations, accessor.get(IExtHostDecorations));
@@ -428,6 +431,14 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
checkProposedApiEnabled(extension, 'telemetry');
return _asExtensionEvent(extHostTelemetry.onDidChangeTelemetryConfiguration);
},
get isMeteredConnection(): boolean {
checkProposedApiEnabled(extension, 'envIsConnectionMetered');
return extHostMeteredConnection.isConnectionMetered;
},
get onDidChangeMeteredConnection(): vscode.Event<boolean> {
checkProposedApiEnabled(extension, 'envIsConnectionMetered');
return _asExtensionEvent(extHostMeteredConnection.onDidChangeIsConnectionMetered);
},
get isNewAppInstall() {
return isNewAppInstall(initData.telemetryInfo.firstSessionDate);
},