Skip to content

Free, open-source Windows optimization tool for performance, privacy, and simplicity.

Improve logging, error handling, and UI consistency

itsfatduck564be70223b9
diff --git a/optimizerDuck/Program.cs b/optimizerDuck/Program.cs
index 8c2a003..279142c 100644
--- a/optimizerDuck/Program.cs
+++ b/optimizerDuck/Program.cs
@@ -193,13 +193,18 @@ internal class Program
AnsiConsole.Clear();
AnsiConsole.Write(Defaults.Logo);
- AnsiConsole.Write(SystemInfoService.GetDetailedPanel(_systemSnapshot));
- AnsiConsole.Write(
- Align.Center(
- new Markup("[dim]Press any key to go back to the main menu.[/]"),
- VerticalAlignment.Middle)
- );
- Console.ReadKey();
+
+ var detailedPanel = SystemInfoService.GetDetailedPanel(_systemSnapshot, Log);
+ if (detailedPanel is not null)
+ {
+ AnsiConsole.Write(detailedPanel);
+ AnsiConsole.Write(
+ Align.Center(
+ new Markup("[dim]Press any key to go back to the main menu.[/]"),
+ VerticalAlignment.Middle)
+ );
+ Console.ReadKey();
+ }
break;
}
}
@@ -215,7 +220,7 @@ internal class Program
AnsiConsole.Clear();
AnsiConsole.Write(Defaults.Logo);
-
+
await UpdateService.CheckForUpdatesAsync();
var app = new Program();
diff --git a/optimizerDuck/src/Core/Helpers/OptimizationHelper.cs b/optimizerDuck/src/Core/Helpers/OptimizationHelper.cs
index 7ab3cf1..d6b5010 100644
--- a/optimizerDuck/src/Core/Helpers/OptimizationHelper.cs
+++ b/optimizerDuck/src/Core/Helpers/OptimizationHelper.cs
@@ -5,6 +5,7 @@ using optimizerDuck.Core.Managers;
using optimizerDuck.Core.Services;
using optimizerDuck.Interfaces;
using optimizerDuck.Models;
+using optimizerDuck.UI;
using optimizerDuck.UI.Logger;
using Spectre.Console;
using System.Reflection;
@@ -55,7 +56,7 @@ public static class OptimizationHelper
.Select(t =>
{
var paddedName = t.Name.PadRight(globalMaxNameLength);
- var description = $"[dim]| {t.Description}[/]";
+ var description = $"[dim]{t.Description}[/]";
return new OptimizationTweakChoice(t, paddedName, description, t.EnabledByDefault);
})
@@ -172,17 +173,17 @@ public static class OptimizationHelper
if (classification.SafeApps.Count > 0)
{
- parts.Add($"{classification.SafeApps.Count} safe apps");
+ parts.Add($"[{Theme.Primary}]{classification.SafeApps.Count}[/] safe apps");
Log.LogDebug("Found {TotalSafeApps} safe apps: {SafeApps}", classification.SafeApps.Count, string.Join(", ", classification.SafeApps.Select(x => x.Name).ToList()));
}
if (classification.CautionApps.Count > 0)
{
- parts.Add($"{classification.CautionApps.Count} caution apps");
+ parts.Add($"[{Theme.Primary}]{classification.CautionApps.Count}[/] caution apps");
Log.LogDebug("Found {TotalCautionApps} caution apps: {CautionApps}", classification.CautionApps.Count, string.Join(", ", classification.CautionApps.Select(x => x.Name).ToList()));
}
if (parts.Any())
- Log.LogInformation("Found {Apps}.", string.Join(" and ", parts));
+ Log.LogInformation($"Found {string.Join(" and ", parts)}.");
else
Log.LogWarning("No apps found.");
diff --git a/optimizerDuck/src/Core/Managers/OptimizationManager.cs b/optimizerDuck/src/Core/Managers/OptimizationManager.cs
index 8b0b77a..b84fe72 100644
--- a/optimizerDuck/src/Core/Managers/OptimizationManager.cs
+++ b/optimizerDuck/src/Core/Managers/OptimizationManager.cs
@@ -125,11 +125,11 @@ public class OptimizationManager(SystemSnapshot systemSnapshot)
- if (SelectedBloatware is { Count: > 0 })
- foreach (var app in SelectedBloatware)
+ if (SelectedBloatware.Count == 0) // default selected safe apps first time only
+ foreach (var app in appxClassification.SafeApps)
promptBloatware.Select(app);
else
- foreach (var app in appxClassification.SafeApps)
+ foreach (var app in SelectedBloatware)
promptBloatware.Select(app);
var bloatwareSelection = await escapeCancellableConsole.PromptAsync(promptBloatware).ConfigureAwait(false);
@@ -151,7 +151,7 @@ public class OptimizationManager(SystemSnapshot systemSnapshot)
AnsiConsole.Clear();
AnsiConsole.Write(Defaults.Logo);
- SystemHelper.Title("Setting up");
+ SystemHelper.Title("Create Restore Point");
return Task.FromResult(PromptDialog.Warning("Create Restore Point",
$"""
diff --git a/optimizerDuck/src/Core/Optimizers/BloatwareAndServices.cs b/optimizerDuck/src/Core/Optimizers/BloatwareAndServices.cs
index 137ac49..6322644 100644
--- a/optimizerDuck/src/Core/Optimizers/BloatwareAndServices.cs
+++ b/optimizerDuck/src/Core/Optimizers/BloatwareAndServices.cs
@@ -35,7 +35,9 @@ public class BloatwareAndServices : IOptimizationGroup
Log.LogDebug("Raw AppxPackage name: {AppxPackage}", appxPackage.Name);
ShellService.PowerShell($$"""
$packages = Get-AppxPackage -AllUsers | Where-Object { $_.Name -eq "{{appxPackage.Name}}" }
+ Write-Output "Found $($packages.Count) packages for {{appxPackage.Name}}"
foreach ($pkg in $packages) {
+ Write-Output "Removing $($pkg.PackageFullName)"
Remove-AppxPackage -Package $pkg.PackageFullName -AllUsers
}
""");
diff --git a/optimizerDuck/src/Core/Services/SystemInfoService.cs b/optimizerDuck/src/Core/Services/SystemInfoService.cs
index 020cf46..7435792 100644
--- a/optimizerDuck/src/Core/Services/SystemInfoService.cs
+++ b/optimizerDuck/src/Core/Services/SystemInfoService.cs
@@ -1,10 +1,11 @@
using Microsoft.Extensions.Logging;
+using Microsoft.Win32.SafeHandles;
using optimizerDuck.UI;
+using optimizerDuck.UI.Components;
using Spectre.Console;
using Spectre.Console.Rendering;
using System.Management;
using System.Runtime.InteropServices;
-using Microsoft.Win32.SafeHandles;
namespace optimizerDuck.Core.Services;
@@ -423,7 +424,7 @@ public static partial class DiskHelper
return !result.IncursSeekPenalty; // false = HDD, true = SSD
}
-
+
public static bool IsSystemDrive(string driveLetter)
{
var systemDrive = Path.GetPathRoot(Environment.SystemDirectory)?.TrimEnd('\\') ?? "C:";
@@ -434,8 +435,8 @@ public static partial class DiskHelper
internal static class DiskProvider
{
-
-
+
+
public static DiskInfo Get()
{
try
@@ -711,7 +712,7 @@ public static class SystemInfoService
var bios = ((Task<BiosInfo>)tasks[3]).Result;
var gpus = ((Task<IReadOnlyList<GpuInfo>>)tasks[4]).Result;
var primaryGpu = GpuProvider.GetPrimary(gpus);
- var disk = DiskProvider.Get();
+ var disk = DiskProvider.Get();
var snapshot = new SystemSnapshot(cpu, ram, os, bios, gpus, primaryGpu, disk);
Snapshot = snapshot;
@@ -726,29 +727,36 @@ public static class SystemInfoService
public static void GetSummary(ILogger log)
{
- log.LogDebug("OS : {OsName} {OsEdition} {OsArchitecture} ({OsDeviceType})",
- Snapshot.Os.Name, Snapshot.Os.Edition, Snapshot.Os.Architecture, Snapshot.Os.DeviceType);
+ try
+ {
+ log.LogDebug("OS : {OsName} {OsEdition} {OsArchitecture} ({OsDeviceType})",
+ Snapshot.Os.Name, Snapshot.Os.Edition, Snapshot.Os.Architecture, Snapshot.Os.DeviceType);
- LogGpuSummary(log);
+ LogGpuSummary(log);
- log.LogDebug("CPU: {CpuName} ({CpuVendor}) [{CpuCores} Cores/{CpuThreads} Threads]",
- Snapshot.Cpu.Name, Snapshot.Cpu.Vendor, Snapshot.Cpu.Cores, Snapshot.Cpu.Threads);
+ log.LogDebug("CPU: {CpuName} ({CpuVendor}) [{CpuCores} Cores/{CpuThreads} Threads]",
+ Snapshot.Cpu.Name, Snapshot.Cpu.Vendor, Snapshot.Cpu.Cores, Snapshot.Cpu.Threads);
- log.LogDebug("RAM: {RamTotalGb:F1} GB (Used: {RamUsedPercent:F1}%)",
- Snapshot.Ram.TotalGB, Snapshot.Ram.UsedPercent);
+ log.LogDebug("RAM: {RamTotalGb:F1} GB (Used: {RamUsedPercent:F1}%)",
+ Snapshot.Ram.TotalGB, Snapshot.Ram.UsedPercent);
- foreach (var volume in Snapshot.Disk.Volumes)
+ foreach (var volume in Snapshot.Disk.Volumes)
+ {
+ var systemDrive = volume.SystemDrive ? " [System Drive]" : "";
+ log.LogDebug("Disk {VolumeName}{SystemDrive} ({VolumeDriveType}) [{VolumeTotalSizeGb:F1} GB] (Free: {VolumeFreeSpaceGb:F1} GB)",
+ volume.Name, systemDrive, volume.DriveTypeDescription, volume.TotalSizeGB, volume.FreeSpaceGB);
+ }
+ }
+ catch (Exception ex)
{
- var systemDrive = volume.SystemDrive ? " [System Drive]" : "";
- log.LogDebug("Disk {VolumeName}{SystemDrive} ({VolumeDriveType}) [{VolumeTotalSizeGb:F1} GB] (Free: {VolumeFreeSpaceGb:F1} GB)",
- volume.Name, systemDrive, volume.DriveTypeDescription, volume.TotalSizeGB, volume.FreeSpaceGB);
+ log.LogError(ex, "Failed to log system summary.");
}
}
private static void LogGpuSummary(ILogger log)
{
var gpuCount = Snapshot.Gpus.Count;
-
+
if (gpuCount == 0 || (gpuCount == 1 && Snapshot.Gpus[0] == GpuInfo.Unknown))
{
@@ -778,7 +786,7 @@ public static class SystemInfoService
if (Snapshot.Gpus[index].Name == Snapshot.PrimaryGpu.Name
&& Snapshot.Gpus[index].Vendor == Snapshot.PrimaryGpu.Vendor)
continue;
-
+
var gpu = Snapshot.Gpus[index];
var memoryInfo = gpu.MemoryMB.HasValue
@@ -791,10 +799,12 @@ public static class SystemInfoService
}
}
- public static Panel GetDetailedPanel(SystemSnapshot s)
+ public static Panel? GetDetailedPanel(SystemSnapshot s, ILogger log)
{
- // Operating System Information
- var osGroup = new List<IRenderable>
+ try
+ {
+ // Operating System Information
+ var osGroup = new List<IRenderable>
{
new Rule("Operating System Information") { Style = Theme.Primary },
new Markup($"[{Theme.Info}]Name :[/] [bold]{s.Os.Name}[/]"),
@@ -807,8 +817,8 @@ public static class SystemInfoService
new Markup($"[{Theme.Info}]Last Boot :[/] [{Theme.Success}]{s.Os.LastBoot}[/]")
};
- // BIOS Information
- var biosGroup = new List<IRenderable>
+ // BIOS Information
+ var biosGroup = new List<IRenderable>
{
new Rule("BIOS Information") { Style = Theme.Success },
new Markup($"[{Theme.Info}]Manufacturer :[/] [bold]{Safe(s.Bios.Manufacturer)}[/]"),
@@ -817,14 +827,14 @@ public static class SystemInfoService
new Markup($"[{Theme.Info}]SMBIOS Version :[/] [{Theme.Success}]{Safe(s.Bios.SmbiosVersion)}[/]")
};
- // CPU Information
- var cpuVendorColor = s.Cpu.Vendor switch
- {
- "AMD" => Theme.Error,
- "Intel" => Theme.Info,
- _ => Theme.Muted
- };
- var cpuGroup = new List<IRenderable>
+ // CPU Information
+ var cpuVendorColor = s.Cpu.Vendor switch
+ {
+ "AMD" => Theme.Error,
+ "Intel" => Theme.Info,
+ _ => Theme.Muted
+ };
+ var cpuGroup = new List<IRenderable>
{
new Rule("CPU Information") { Style = Theme.Info },
new Markup($"[{Theme.Info}]Name :[/] [bold]{Safe(s.Cpu.Name)}[/]"),
@@ -839,12 +849,12 @@ public static class SystemInfoService
new Markup($"[{Theme.Info}]L3 Cache :[/] [{Theme.Success}]{s.Cpu.L3CacheKB}[/] [dim]KB[/]")
};
- // RAM Information
- var usedColor = s.Ram.UsedPercent > 80 ? Theme.Error : Theme.Warning;
- var ramGroup = new List<IRenderable>
+ // RAM Information
+ var usedColor = s.Ram.UsedPercent > 80 ? Theme.Error : Theme.Warning;
+ var ramGroup = new List<IRenderable>
{
new Rule("Memory Information") { Style = new Style(Color.Yellow) },
-
+
new Markup(
$"[{Theme.Info}]Total :[/] [{Theme.Success}]{s.Ram.TotalGB:F2}[/] [dim]GB[/] [dim]([/][{Theme.Success}]{s.Ram.TotalMB}[/] [dim]MB)[/]"),
new Markup($"[{Theme.Info}]Available :[/] [{Theme.Success}]{s.Ram.AvailableGB:F2}[/] [dim]GB[/]"),
@@ -862,148 +872,159 @@ public static class SystemInfoService
Color.FromHex(Theme.Success)),
};
- if (s.Ram.Modules.Count > 0)
- {
- ramGroup.Add(new Markup(
- $"[{Theme.Info}]Modules :[/] [{Theme.Success}]{s.Ram.Modules.Count}[/] [dim]detected[/]"));
- for (var i = 0; i < s.Ram.Modules.Count; i++)
+ if (s.Ram.Modules.Count > 0)
{
- var module = s.Ram.Modules[i];
ramGroup.Add(new Markup(
- $" [{Theme.Info}]Module {i + 1} :[/] [{Theme.Success}]{module.CapacityGB:F2}[/] [dim]GB @[/] [{Theme.Warning}]{module.SpeedMHz}[/] [dim]MHz[/]"));
- ramGroup.Add(new Markup($" [dim]Manufacturer:[/] [{Theme.Info}]{Safe(module.Manufacturer)}[/]"));
- ramGroup.Add(new Markup($" [dim]Part Number :[/] [bold]{Safe(module.PartNumber)}[/]"));
- ramGroup.Add(new Markup($" [dim]Location :[/] [bold]{Safe(module.DeviceLocator)}[/]"));
+ $"[{Theme.Info}]Modules :[/] [{Theme.Success}]{s.Ram.Modules.Count}[/] [dim]detected[/]"));
+ for (var i = 0; i < s.Ram.Modules.Count; i++)
+ {
+ var module = s.Ram.Modules[i];
+ ramGroup.Add(new Markup(
+ $" [{Theme.Info}]Module {i + 1} :[/] [{Theme.Success}]{module.CapacityGB:F2}[/] [dim]GB @[/] [{Theme.Warning}]{module.SpeedMHz}[/] [dim]MHz[/]"));
+ ramGroup.Add(new Markup($" [dim]Manufacturer:[/] [{Theme.Info}]{Safe(module.Manufacturer)}[/]"));
+ ramGroup.Add(new Markup($" [dim]Part Number :[/] [bold]{Safe(module.PartNumber)}[/]"));
+ ramGroup.Add(new Markup($" [dim]Location :[/] [bold]{Safe(module.DeviceLocator)}[/]"));
+ }
}
- }
-
- // Disk Information
- var diskGroup = new List<IRenderable>
+
+ // Disk Information
+ var diskGroup = new List<IRenderable>
{
new Rule("Disk Information") { Style = Theme.Info }
};
- foreach (var volume in s.Disk.Volumes)
- {
- var usedDiskColor = volume.UsedPercent > 90 ? Theme.Error : Theme.Warning;
- var systemDrive = volume.SystemDrive ? $" [{Theme.Success}][[System Drive]][/]" : "";
-
- diskGroup.Add(new Markup($"[{Theme.Info}]{volume.Name} [bold white]{volume.Label}[/]{systemDrive}[/]"));
- diskGroup.Add(new Markup($" [{Theme.Info}]Type :[/] [bold]{volume.DriveTypeDescription}[/]"));
- diskGroup.Add(new Markup($" [{Theme.Info}]Total Size :[/] [{Theme.Success}]{volume.TotalSizeGB:F2}[/] [dim]GB[/]"));
- diskGroup.Add(new Markup($" [{Theme.Info}]Used Size :[/] [{Theme.Warning}]{volume.UsedSpaceGB:F2}[/] [dim]GB[/]"));
- diskGroup.Add(new Markup($" [{Theme.Info}]Free Space :[/] [{usedDiskColor}]{volume.FreeSpaceGB:F2}[/] [dim]GB[/]"));
- diskGroup.Add(new BreakdownChart()
- .Width(50)
- .UseValueFormatter(v => $"{v:F2} GB")
- .AddItem(
- "Used GB",
- volume.UsedSpaceGB,
- Color.FromHex(usedDiskColor))
- .AddItem(
- "Available GB",
- volume.FreeSpaceGB,
- Color.FromHex(Theme.Success)));
- }
-
- // GPU Information
- var gpuCount = s.Gpus.Count;
- var gpuGroup = new List<IRenderable>();
-
- switch (gpuCount)
- {
- case 0:
- case 1 when s.Gpus[0] == GpuInfo.Unknown:
- gpuGroup.Add(new Rule("GPU Information") { Style = new Style(Color.Red) });
- gpuGroup.Add(new Markup($"[{Theme.Error}]No GPUs detected[/]"));
- break;
- case 1:
+ foreach (var volume in s.Disk.Volumes)
{
- gpuGroup.Add(new Rule("GPU Information") { Style = new Style(Color.Green) });
- var gpu = s.Gpus[0];
- var vendorColor = gpu.Vendor switch
- {
- GpuVendor.NVIDIA => Theme.Success,
- GpuVendor.AMD => Theme.Error,
- GpuVendor.Intel => Theme.Accent,
- _ => Theme.Muted
- };
-
- gpuGroup.Add(new Markup($"[{Theme.Info}]Name :[/] [bold]{Safe(gpu.Name)}[/]"));
- gpuGroup.Add(new Markup($"[{Theme.Info}]Vendor :[/] [{vendorColor}]{gpu.Vendor}[/]"));
- gpuGroup.Add(new Markup($"[{Theme.Info}]Driver Version :[/] [{Theme.Warning}]{Safe(gpu.DriverVersion)}[/]"));
-
- if (gpu.MemoryMB.HasValue)
- gpuGroup.Add(new Markup(
- $"[{Theme.Info}]Memory :[/] [{Theme.Success}]{gpu.MemoryMB.Value / 1024.0:F2}[/] [dim]GB[/] [dim]([/][{Theme.Success}]{gpu.MemoryMB.Value}[/] [dim]MB)[/]"));
-
- if (!string.IsNullOrEmpty(gpu.DeviceId))
- gpuGroup.Add(new Markup($"[{Theme.Info}]Device ID :[/] [dim]{Safe(gpu.DeviceId)}[/]"));
-
- if (!string.IsNullOrEmpty(gpu.PnpDeviceId))
- gpuGroup.Add(new Markup($"[{Theme.Info}]PCI Device ID :[/] [dim]{Safe(gpu.PnpDeviceId)}[/]"));
- break;
+ var usedDiskColor = volume.UsedPercent > 90 ? Theme.Error : Theme.Warning;
+ var systemDrive = volume.SystemDrive ? $" [{Theme.Success}][[System Drive]][/]" : "";
+
+ diskGroup.Add(new Markup($"[{Theme.Info}]{volume.Name} [bold white]{volume.Label}[/]{systemDrive}[/]"));
+ diskGroup.Add(new Markup($" [{Theme.Info}]Type :[/] [bold]{volume.DriveTypeDescription}[/]"));
+ diskGroup.Add(new Markup($" [{Theme.Info}]Total Size :[/] [{Theme.Success}]{volume.TotalSizeGB:F2}[/] [dim]GB[/]"));
+ diskGroup.Add(new Markup($" [{Theme.Info}]Used Size :[/] [{Theme.Warning}]{volume.UsedSpaceGB:F2}[/] [dim]GB[/]"));
+ diskGroup.Add(new Markup($" [{Theme.Info}]Free Space :[/] [{usedDiskColor}]{volume.FreeSpaceGB:F2}[/] [dim]GB[/]"));
+ diskGroup.Add(new BreakdownChart()
+ .Width(50)
+ .UseValueFormatter(v => $"{v:F2} GB")
+ .AddItem(
+ "Used GB",
+ volume.UsedSpaceGB,
+ Color.FromHex(usedDiskColor))
+ .AddItem(
+ "Available GB",
+ volume.FreeSpaceGB,
+ Color.FromHex(Theme.Success)));
}
- default:
+
+ // GPU Information
+ var gpuCount = s.Gpus.Count;
+ var gpuGroup = new List<IRenderable>();
+
+ switch (gpuCount)
{
- gpuGroup.Add(new Rule($"GPU Information ({gpuCount} detected)") { Style = new Style(Color.Green) });
- for (var i = 0; i < s.Gpus.Count; i++)
- {
- var gpu = s.Gpus[i];
- var isPrimary = s.PrimaryGpu != null && gpu.Name == s.PrimaryGpu.Name ? $" [{Theme.Primary}][[Primary]][/]" : "";
- var vendorColor = gpu.Vendor switch
+ case 0:
+ case 1 when s.Gpus[0] == GpuInfo.Unknown:
+ gpuGroup.Add(new Rule("GPU Information") { Style = new Style(Color.Red) });
+ gpuGroup.Add(new Markup($"[{Theme.Error}]No GPUs detected[/]"));
+ break;
+ case 1:
{
- GpuVendor.NVIDIA => Theme.Success,
- GpuVendor.AMD => Theme.Error,
- GpuVendor.Intel => Theme.Accent,
- _ => Theme.Muted
- };
-
- gpuGroup.Add(new Markup($"[{Theme.Info}]GPU {i + 1}{isPrimary}:[/]"));
- gpuGroup.Add(new Markup($" [{Theme.Info}]Name :[/] [bold]{Safe(gpu.Name)}[/]"));
- gpuGroup.Add(
- new Markup($" [{Theme.Info}]Vendor :[/] [{vendorColor}]{gpu.Vendor}[/]"));
- gpuGroup.Add(new Markup($" [{Theme.Info}]Driver :[/] [{Theme.Warning}]{Safe(gpu.DriverVersion)}[/]"));
-
- if (gpu.MemoryMB.HasValue)
- gpuGroup.Add(new Markup(
- $" [{Theme.Info}]Memory :[/] [{Theme.Success}]{gpu.MemoryMB.Value / 1024.0:F2}[/] [dim]GB[/] [dim]([/][{Theme.Success}]{gpu.MemoryMB.Value}[/] [dim]MB)[/]"));
-
- if (!string.IsNullOrEmpty(gpu.DeviceId))
- gpuGroup.Add(new Markup($" [{Theme.Info}]Device ID :[/] [dim]{Safe(gpu.DeviceId)}[/]"));
-
- if (!string.IsNullOrEmpty(gpu.PnpDeviceId))
- gpuGroup.Add(new Markup($" [{Theme.Info}]PCI Device ID:[/] [dim]{Safe(gpu.PnpDeviceId)}[/]"));
- }
-
- break;
+ gpuGroup.Add(new Rule("GPU Information") { Style = new Style(Color.Green) });
+ var gpu = s.Gpus[0];
+ var vendorColor = gpu.Vendor switch
+ {
+ GpuVendor.NVIDIA => Theme.Success,
+ GpuVendor.AMD => Theme.Error,
+ GpuVendor.Intel => Theme.Accent,
+ _ => Theme.Muted
+ };
+
+ gpuGroup.Add(new Markup($"[{Theme.Info}]Name :[/] [bold]{Safe(gpu.Name)}[/]"));
+ gpuGroup.Add(new Markup($"[{Theme.Info}]Vendor :[/] [{vendorColor}]{gpu.Vendor}[/]"));
+ gpuGroup.Add(new Markup($"[{Theme.Info}]Driver Version :[/] [{Theme.Warning}]{Safe(gpu.DriverVersion)}[/]"));
+
+ if (gpu.MemoryMB.HasValue)
+ gpuGroup.Add(new Markup(
+ $"[{Theme.Info}]Memory :[/] [{Theme.Success}]{gpu.MemoryMB.Value / 1024.0:F2}[/] [dim]GB[/] [dim]([/][{Theme.Success}]{gpu.MemoryMB.Value}[/] [dim]MB)[/]"));
+
+ if (!string.IsNullOrEmpty(gpu.DeviceId))
+ gpuGroup.Add(new Markup($"[{Theme.Info}]Device ID :[/] [dim]{Safe(gpu.DeviceId)}[/]"));
+
+ if (!string.IsNullOrEmpty(gpu.PnpDeviceId))
+ gpuGroup.Add(new Markup($"[{Theme.Info}]PCI Device ID :[/] [dim]{Safe(gpu.PnpDeviceId)}[/]"));
+ break;
+ }
+ default:
+ {
+ gpuGroup.Add(new Rule($"GPU Information ({gpuCount} detected)") { Style = new Style(Color.Green) });
+ for (var i = 0; i < s.Gpus.Count; i++)
+ {
+ var gpu = s.Gpus[i];
+ var isPrimary = s.PrimaryGpu != null && gpu.Name == s.PrimaryGpu.Name ? $" [{Theme.Primary}][[Primary]][/]" : "";
+ var vendorColor = gpu.Vendor switch
+ {
+ GpuVendor.NVIDIA => Theme.Success,
+ GpuVendor.AMD => Theme.Error,
+ GpuVendor.Intel => Theme.Accent,
+ _ => Theme.Muted
+ };
+
+ gpuGroup.Add(new Markup($"[{Theme.Info}]GPU {i + 1}{isPrimary}:[/]"));
+ gpuGroup.Add(new Markup($" [{Theme.Info}]Name :[/] [bold]{Safe(gpu.Name)}[/]"));
+ gpuGroup.Add(
+ new Markup($" [{Theme.Info}]Vendor :[/] [{vendorColor}]{gpu.Vendor}[/]"));
+ gpuGroup.Add(new Markup($" [{Theme.Info}]Driver :[/] [{Theme.Warning}]{Safe(gpu.DriverVersion)}[/]"));
+
+ if (gpu.MemoryMB.HasValue)
+ gpuGroup.Add(new Markup(
+ $" [{Theme.Info}]Memory :[/] [{Theme.Success}]{gpu.MemoryMB.Value / 1024.0:F2}[/] [dim]GB[/] [dim]([/][{Theme.Success}]{gpu.MemoryMB.Value}[/] [dim]MB)[/]"));
+
+ if (!string.IsNullOrEmpty(gpu.DeviceId))
+ gpuGroup.Add(new Markup($" [{Theme.Info}]Device ID :[/] [dim]{Safe(gpu.DeviceId)}[/]"));
+
+ if (!string.IsNullOrEmpty(gpu.PnpDeviceId))
+ gpuGroup.Add(new Markup($" [{Theme.Info}]PCI Device ID:[/] [dim]{Safe(gpu.PnpDeviceId)}[/]"));
+ }
+
+ break;
+ }
}
- }
-
- // Combine all groups
- var allGroups = new List<IRenderable>();
- allGroups.AddRange(osGroup);
- allGroups.Add(Text.Empty);
- allGroups.AddRange(biosGroup);
- allGroups.Add(Text.Empty);
- allGroups.AddRange(cpuGroup);
- allGroups.Add(Text.Empty);
- allGroups.AddRange(ramGroup);
- allGroups.Add(Text.Empty);
- allGroups.AddRange(diskGroup);
- allGroups.Add(Text.Empty);
- allGroups.AddRange(gpuGroup);
- var panel = new Panel(new Rows(allGroups))
- {
- Border = BoxBorder.Rounded,
- BorderStyle = Theme.PrimaryMuted,
- Width = 90
- };
+ // Combine all groups
+ var allGroups = new List<IRenderable>();
+ allGroups.AddRange(osGroup);
+ allGroups.Add(Text.Empty);
+ allGroups.AddRange(biosGroup);
+ allGroups.Add(Text.Empty);
+ allGroups.AddRange(cpuGroup);
+ allGroups.Add(Text.Empty);
+ allGroups.AddRange(ramGroup);
+ allGroups.Add(Text.Empty);
+ allGroups.AddRange(diskGroup);
+ allGroups.Add(Text.Empty);
+ allGroups.AddRange(gpuGroup);
- return panel;
+ var panel = new Panel(new Rows(allGroups))
+ {
+ Border = BoxBorder.Rounded,
+ BorderStyle = Theme.PrimaryMuted,
+ Width = 90
+ };
+
+ return panel;
+ }
+ catch (Exception ex)
+ {
+ log.LogError(ex, "Failed to generate detailed system info panel.");
+ PromptDialog.Exception(ex, "An error occurred while displaying system information.",
+ $"""
+ This is an [{Theme.Error}]unhandled exception[/] that occurred while generating the detailed system information panel.
+ """
+ );
+ return null;
+ }
}
private static string Safe(string? s) => Markup.Escape(s ?? "");
diff --git a/optimizerDuck/src/UI/Components/PromptDialog.cs b/optimizerDuck/src/UI/Components/PromptDialog.cs
index 88cc96e..71b89cb 100644
--- a/optimizerDuck/src/UI/Components/PromptDialog.cs
+++ b/optimizerDuck/src/UI/Components/PromptDialog.cs
@@ -186,6 +186,7 @@ public class PromptDialog
[
new PromptOption("Exit", Theme.Error, () => Environment.Exit(1)),
new PromptOption("Restart Application", Theme.Success, () => RequirementChecker.Restart(true)),
+ new PromptOption("Create new issue on GitHub", Theme.Bright, () => SystemHelper.OpenWebsite("https://github.com/itsfatduck/optimizerDuck/issues/new")),
new PromptOption("Open log", Theme.Warning, SystemHelper.OpenLogFile)
];