From 49e6535abe015a620069a438fdf8d9619701b00a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Mar 2026 21:36:15 +0000 Subject: [PATCH 1/2] Initial plan From 90a8f6e7960b1410dab4b52d30af34f4a5724301 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Mar 2026 21:42:33 +0000 Subject: [PATCH 2/2] fix: cache Team Dashboard data to avoid slow load on every open Add `lastDashboardData` cache property so that when the Team Dashboard panel is opened after the first load, cached data is sent to the webview immediately instead of waiting for a full backend fetch + maturity score calculation. Fresh data is still fetched in the background and replaces the cached view when ready. The cache is cleared alongside other stat caches when the user explicitly clears the session cache. Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com> --- src/extension.ts | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 5fa4972c..b60396b8 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -171,6 +171,7 @@ class CopilotTokenTracker implements vscode.Disposable { private lastDetailedStats: DetailedStats | undefined; private lastDailyStats: DailyTokenStats[] | undefined; private lastUsageAnalysisStats: UsageAnalysisStats | undefined; + private lastDashboardData: any | undefined; private tokenEstimators: { [key: string]: number } = tokenEstimatorsData.estimators; private co2Per1kTokens = 0.2; // gCO2e per 1000 tokens, a rough estimate private co2AbsorptionPerTreePerYear = 21000; // grams of CO2 per tree per year @@ -357,6 +358,7 @@ class CopilotTokenTracker implements vscode.Disposable { this.lastDetailedStats = undefined; this.lastDailyStats = undefined; this.lastUsageAnalysisStats = undefined; + this.lastDashboardData = undefined; this.log(`Cache cleared successfully. Removed ${cacheSize} entries.`); vscode.window.showInformationMessage('Cache cleared successfully. Reloading statistics...'); @@ -4828,20 +4830,33 @@ ${hashtag}`; this.dashboardPanel = undefined; }); - // Load data asynchronously and send to webview + // If we have cached data, show it immediately so the panel renders fast + if (this.lastDashboardData) { + this.log("📊 Sending cached dashboard data immediately"); + this.dashboardPanel.webview.postMessage({ + command: "dashboardData", + data: this.lastDashboardData, + }); + } + + // Load (or refresh) data asynchronously and send to webview try { const dashboardData = await this.getDashboardData(); + this.lastDashboardData = dashboardData; this.dashboardPanel?.webview.postMessage({ command: "dashboardData", data: dashboardData, }); } catch (error) { this.error("Failed to load dashboard data:", error); - this.dashboardPanel?.webview.postMessage({ - command: "dashboardError", - message: - "Failed to load dashboard data. Please check backend configuration and try again.", - }); + // Only show error state when there's no cached data to fall back on + if (!this.lastDashboardData) { + this.dashboardPanel?.webview.postMessage({ + command: "dashboardError", + message: + "Failed to load dashboard data. Please check backend configuration and try again.", + }); + } } } @@ -4854,6 +4869,7 @@ ${hashtag}`; this.dashboardPanel.webview.postMessage({ command: "dashboardLoading" }); try { const dashboardData = await this.getDashboardData(); + this.lastDashboardData = dashboardData; this.dashboardPanel?.webview.postMessage({ command: "dashboardData", data: dashboardData,