266834cbdf
Reduce Performance tab to optional diagnostics Hide the Performance/Diagnostics surface from the primary UX by default and remove hidden startup/tray runtime cost. - Hide Diagnostics from primary navigation and tray by default - Lazy-create PerformanceViewModel only when Diagnostics is opened - Stop initializing diagnostics snapshots during app startup - Gate tray CPU/RAM metrics behind the advanced diagnostics flag - Avoid starting the tray lightweight metrics timer when diagnostics are hidden - Lazily allocate PerformanceMonitoringService counters on first metrics use - Stop live diagnostics when inactive, minimized or tray-hidden - Preserve diagnostics internals for future selected-process summary work - Add tests for lazy diagnostics creation, tray metrics gating and explicit diagnostics activation No Process tab redesign, CPU affinity changes, memory priority changes, persistent rules changes, version bump or tag changes.
95 lines
3.9 KiB
C#
95 lines
3.9 KiB
C#
/*
|
|
* ThreadPilot - Advanced Windows Process and Power Plan Manager
|
|
* Copyright (C) 2025 Prime Build
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
* the Free Software Foundation, version 3 only.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
namespace ThreadPilot.Services
|
|
{
|
|
/// <summary>
|
|
/// Represents the current UI activity state used to decide refresh work.
|
|
/// </summary>
|
|
public enum AppActivityState
|
|
{
|
|
ForegroundProcessView,
|
|
ForegroundDiagnosticsView,
|
|
ForegroundOtherTab,
|
|
Minimized,
|
|
TrayHidden,
|
|
}
|
|
|
|
/// <summary>
|
|
/// Describes refresh and monitoring work allowed for a UI activity state.
|
|
/// </summary>
|
|
public sealed record AppRefreshDecision(
|
|
bool ProcessUiRefreshEnabled,
|
|
bool ImmediateProcessRefresh,
|
|
bool VirtualizedPreloadEnabled,
|
|
bool PerformanceUiMonitoringEnabled,
|
|
bool PowerPlanUiRefreshEnabled,
|
|
bool BackgroundAutomationEnabled);
|
|
|
|
/// <summary>
|
|
/// Central policy for foreground/background refresh decisions.
|
|
/// </summary>
|
|
public static class AppRefreshPolicy
|
|
{
|
|
public static bool ShouldApplyTransition(AppActivityState? previousState, AppActivityState nextState)
|
|
{
|
|
return previousState != nextState;
|
|
}
|
|
|
|
public static AppRefreshDecision Evaluate(AppActivityState state)
|
|
{
|
|
return state switch
|
|
{
|
|
AppActivityState.ForegroundProcessView => new AppRefreshDecision(
|
|
ProcessUiRefreshEnabled: true,
|
|
ImmediateProcessRefresh: true,
|
|
VirtualizedPreloadEnabled: true,
|
|
PerformanceUiMonitoringEnabled: false,
|
|
PowerPlanUiRefreshEnabled: true,
|
|
BackgroundAutomationEnabled: true),
|
|
AppActivityState.ForegroundDiagnosticsView => new AppRefreshDecision(
|
|
ProcessUiRefreshEnabled: false,
|
|
ImmediateProcessRefresh: false,
|
|
VirtualizedPreloadEnabled: false,
|
|
PerformanceUiMonitoringEnabled: true,
|
|
PowerPlanUiRefreshEnabled: true,
|
|
BackgroundAutomationEnabled: true),
|
|
AppActivityState.ForegroundOtherTab => new AppRefreshDecision(
|
|
ProcessUiRefreshEnabled: false,
|
|
ImmediateProcessRefresh: false,
|
|
VirtualizedPreloadEnabled: false,
|
|
PerformanceUiMonitoringEnabled: false,
|
|
PowerPlanUiRefreshEnabled: true,
|
|
BackgroundAutomationEnabled: true),
|
|
AppActivityState.Minimized or AppActivityState.TrayHidden => new AppRefreshDecision(
|
|
ProcessUiRefreshEnabled: false,
|
|
ImmediateProcessRefresh: false,
|
|
VirtualizedPreloadEnabled: false,
|
|
PerformanceUiMonitoringEnabled: false,
|
|
PowerPlanUiRefreshEnabled: false,
|
|
BackgroundAutomationEnabled: true),
|
|
_ => new AppRefreshDecision(
|
|
ProcessUiRefreshEnabled: false,
|
|
ImmediateProcessRefresh: false,
|
|
VirtualizedPreloadEnabled: false,
|
|
PerformanceUiMonitoringEnabled: false,
|
|
PowerPlanUiRefreshEnabled: false,
|
|
BackgroundAutomationEnabled: true),
|
|
};
|
|
}
|
|
}
|
|
}
|