From 8ecf079fcf15d78bf50916909732cac1837b00d1 Mon Sep 17 00:00:00 2001 From: Francisco Alejandro Garcia Cebada Date: Thu, 28 May 2026 17:38:58 -0700 Subject: [PATCH] fix: Fixing slowness due to sending too much snapshots. --- .../src/monitorPanelProvider.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/FASTBuildMonitorVSCode/src/monitorPanelProvider.ts b/FASTBuildMonitorVSCode/src/monitorPanelProvider.ts index 2773e46..7c6de2a 100644 --- a/FASTBuildMonitorVSCode/src/monitorPanelProvider.ts +++ b/FASTBuildMonitorVSCode/src/monitorPanelProvider.ts @@ -17,6 +17,7 @@ export class MonitorPanelProvider implements vscode.WebviewViewProvider { private disposables: vscode.Disposable[] = []; private refreshTimer: ReturnType | undefined; private isMonitoringOverride: boolean = false; + private isSnapshotRequestPending: boolean = false; public static getOrCreate(context: vscode.ExtensionContext, service: BuildMonitorService): MonitorPanelProvider { if (MonitorPanelProvider.instance) { @@ -72,7 +73,7 @@ export class MonitorPanelProvider implements vscode.WebviewViewProvider { if(this.isMonitoringOverride) { this.start(true /* force */); } - this.sendSnapshot(); + this.isSnapshotRequestPending = true; } else { this.stop(false /* don't override */); } @@ -81,7 +82,7 @@ export class MonitorPanelProvider implements vscode.WebviewViewProvider { // Listen for state changes from the service this.service.on('stateChanged', () => { if(!this.service.getIsRestoringHistory()) { - this.sendSnapshot(); + this.isSnapshotRequestPending = true; } }); @@ -91,13 +92,15 @@ export class MonitorPanelProvider implements vscode.WebviewViewProvider { } this.refreshTimer = setInterval(() => { if ( + this.isSnapshotRequestPending || ( this.service.isMonitoring() && this.service.getCurrentSession() && - !this.service.getCurrentSession()?.endTime + !this.service.getCurrentSession()?.endTime) ) { - this.sendSnapshot(); + this.isSnapshotRequestPending = false; + this.sendSnapshot(); } - }, 1000); + }, 100); // Auto-start if configured const config = vscode.workspace.getConfiguration('fbuildMonitor'); @@ -106,7 +109,7 @@ export class MonitorPanelProvider implements vscode.WebviewViewProvider { } // Send initial snapshot - this.sendSnapshot(); + this.isSnapshotRequestPending = true; } private handleWebviewMessage(message: { command: string }): void {