From 1aa95e28bf2acbdee7ba16ba92373cae142acbe8 Mon Sep 17 00:00:00 2001 From: PrimeBuild-pc Date: Wed, 20 May 2026 22:43:51 +0200 Subject: [PATCH 1/2] Reduce Performance tab to optional diagnostics --- MainWindow.Behaviors.partial.cs | 32 +++-- MainWindow.xaml | 14 +- MainWindow.xaml.cs | 8 ++ Services/AppNavigationOptions.cs | 26 ++++ Services/AppRefreshPolicy.cs | 10 +- Services/SystemTrayService.cs | 14 +- .../AppRefreshPolicyTests.cs | 7 +- .../PerformanceViewModelDiagnosticsTests.cs | 120 ++++++++++++++++ ViewModels/PerformanceViewModel.cs | 129 +++++++++++------- Views/PerformanceView.xaml | 6 +- 10 files changed, 286 insertions(+), 80 deletions(-) create mode 100644 Services/AppNavigationOptions.cs create mode 100644 Tests/ThreadPilot.Core.Tests/PerformanceViewModelDiagnosticsTests.cs diff --git a/MainWindow.Behaviors.partial.cs b/MainWindow.Behaviors.partial.cs index 753e7e0..c6bf7ad 100644 --- a/MainWindow.Behaviors.partial.cs +++ b/MainWindow.Behaviors.partial.cs @@ -340,15 +340,7 @@ private async Task LoadViewModelsAsync() await powerPlanTask; // Ensure we get any exceptions this.LogDebug("PowerPlanViewModel loaded successfully"); - this.LogDebug("About to initialize PerformanceViewModel..."); - var performanceTask = this.performanceViewModel.InitializeAsync(); - var performanceResult = await Task.WhenAny(performanceTask, Task.Delay(5000)); - if (performanceResult != performanceTask) - { - throw new TimeoutException("PerformanceViewModel.InitializeAsync() timed out after 5 seconds"); - } - await performanceTask; // Ensure we get any exceptions - this.LogDebug("PerformanceViewModel initialized successfully"); + this.LogDebug("Skipping optional diagnostics initialization until the diagnostics page is opened."); this.LogDebug("About to load SystemTweaksViewModel..."); var systemTweaksTask = this.systemTweaksViewModel.LoadCommand.ExecuteAsync(null); @@ -1365,8 +1357,13 @@ private void ResumeForegroundRefreshes() private AppActivityState GetForegroundActivityState() { - return this.ProcessManagementTab.Visibility == Visibility.Visible - ? AppActivityState.ForegroundProcessView + if (this.ProcessManagementTab.Visibility == Visibility.Visible) + { + return AppActivityState.ForegroundProcessView; + } + + return this.PerformanceViewControl.Visibility == Visibility.Visible + ? AppActivityState.ForegroundDiagnosticsView : AppActivityState.ForegroundOtherTab; } @@ -1408,7 +1405,7 @@ private void ApplyAppRefreshPolicy(AppActivityState state) if (decision.PerformanceUiMonitoringEnabled) { - _ = this.performanceViewModel.ResumeBackgroundMonitoringAsync(); + _ = this.performanceViewModel.ActivateDiagnosticsAsync(); } else { @@ -1791,9 +1788,14 @@ private void ApplySectionVisibility(string tag) return; } - this.ApplyAppRefreshPolicy(string.Equals(tag, "Process", StringComparison.Ordinal) - ? AppActivityState.ForegroundProcessView - : AppActivityState.ForegroundOtherTab); + var activityState = tag switch + { + "Process" => AppActivityState.ForegroundProcessView, + "Performance" => AppActivityState.ForegroundDiagnosticsView, + _ => AppActivityState.ForegroundOtherTab, + }; + + this.ApplyAppRefreshPolicy(activityState); } private void NavMenuItem_Click(object sender, RoutedEventArgs e) diff --git a/MainWindow.xaml b/MainWindow.xaml index 5f890ee..6972afe 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -138,7 +138,7 @@ - + @@ -325,14 +325,14 @@ @@ -344,21 +344,21 @@ Margin="0,0,0,6"/>