Metered network connections support#288919
Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements comprehensive support for detecting and respecting metered network connections (such as mobile data or tethering) to reduce data usage on limited connections.
Changes:
- Adds new proposed API
env.isConnectionMeteredandenv.onDidChangeIsConnectionMeteredfor extensions - Implements metered connection detection using the Network Information API with fallback logic
- Pauses automatic operations (updates, extension updates, Settings Sync, telemetry, and Git operations) when on metered connections
- Adds status bar indicator when a metered connection is detected
Reviewed changes
Copilot reviewed 45 out of 46 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/vscode-dts/vscode.proposed.envIsConnectionMetered.d.ts | Defines proposed API for metered connection detection |
| src/vs/platform/meteredConnection/common/meteredConnection.ts | Core service interface and Network Information API types |
| src/vs/platform/meteredConnection/browser/meteredConnectionService.ts | Browser implementation monitoring navigator.connection |
| src/vs/platform/meteredConnection/electron-browser/meteredConnectionService.ts | Electron renderer implementation with IPC to main process |
| src/vs/platform/meteredConnection/electron-main/meteredConnectionMainService.ts | Electron main process service receiving IPC updates |
| src/vs/workbench/api/common/extHostMeteredConnection.ts | Extension host implementation for proposed API |
| src/vs/workbench/api/browser/mainThreadMeteredConnection.ts | Main thread bridge for extension API |
| src/vs/workbench/contrib/meteredConnection/browser/meteredConnectionStatus.ts | Status bar indicator when metered |
| src/vs/platform/update/electron-main/abstractUpdateService.ts | Skips automatic update checks/downloads on metered connections |
| src/vs/platform/telemetry/common/telemetryService.ts | Buffers telemetry events when metered, flushes when recovered |
| src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts | Skips automatic extension update checks on metered connections |
| src/vs/platform/userDataSync/common/userDataAutoSyncService.ts | Skips Settings Sync on metered connections |
| extensions/git/src/autofetch.ts | Disables Git autofetch on metered connections |
| extensions/git/src/postCommitCommands.ts | Skips automatic post-commit operations on metered connections |
| src/vs/platform/update/common/update.config.contribution.ts | Adds update.respectMeteredConnections configuration setting |
| src/vs/workbench/workbench.*.main.ts | Registers metered connection services in workbench layers |
| src/vs/code/electron-main/app.ts | Sets up IPC handling for metered connection status updates |
Comments suppressed due to low confidence (1)
src/vs/platform/meteredConnection/browser/meteredConnectionService.ts:56
- The configuration value is read at the end of the constructor after event listeners are set up. This creates a timing issue where if the configuration changes between lines 55-56, the event listener (lines 45-53) might fire before the initial value is set. This could cause the service to fire an event with stale data. Consider reading the configuration value before setting up the change listener, or ensure the initial event firing happens consistently.
this._register(this.configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration(METERED_CONNECTION_SETTING_KEY)) {
const value = this.configurationService.getValue<boolean>(METERED_CONNECTION_SETTING_KEY);
if (this._respectMeteredConnections !== value) {
this._respectMeteredConnections = value;
this._onDidChangeIsConnectionMetered.fire(this.isConnectionMetered);
}
}
}));
this._respectMeteredConnections = this.configurationService.getValue<boolean>(METERED_CONNECTION_SETTING_KEY);
this._isConnectionMetered = getIsConnectionMetered();
src/vs/platform/meteredConnection/browser/meteredConnectionService.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts
Outdated
Show resolved
Hide resolved
src/vs/platform/meteredConnection/electron-browser/meteredConnectionService.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/contrib/meteredConnection/browser/meteredConnectionStatus.ts
Outdated
Show resolved
Hide resolved
src/vs/platform/meteredConnection/electron-browser/meteredConnectionService.ts
Outdated
Show resolved
Hide resolved
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @rzhao271Matched files:
|
|
@copilot Show me diagrams explaining the flows here. What happens when a user goes into a metered connection? Which systems are affected? What happens when a user disables respecting metered connection state? |
|
@joaomoreno I've opened a new pull request, #289126, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
FYI kicked off a new build for testing: https://dev.azure.com/monacotools/Monaco/_build/results?buildId=394456&view=results |
Fixes #103451
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.
While connection is metered:
Once connection is no longer metered, all automatic operations will resume on their normal schedule/triggers.
Status bar update:

New user setting:

update.respectMeteredConnections