From a0d3c719a6611b329422e9c56ee9b792cd596146 Mon Sep 17 00:00:00 2001 From: Chris Titus Date: Mon, 7 Sep 2026 11:33:39 -0500 Subject: [PATCH] Improve UI startup after runspace overhaul (#5056) * perf: keep UI startup responsive * test: make favicon checks runner-safe * fix: qualify favicon visibility state * test: isolate favicon visibility fixture * fix: enforce total favicon deadline * fix: address favicon review feedback * fix: recognize disabled SSH firewall rule * perf: restore favicon download throughput * docs: allow public PR review uploads * perf: restore overlapping favicon loading --- AGENTS.md | 2 + Compile.ps1 | 2 + functions/private/Invoke-WinUtilSSHServer.ps1 | 2 +- functions/private/Measure-WinUtilStep.ps1 | 17 ++++-- .../private/Start-WinUtilUserInterface.ps1 | 4 +- functions/private/Write-WinUtilLog.ps1 | 6 +++ pester/logging.Tests.ps1 | 54 +++++++++++++++++++ pester/sanity.Tests.ps1 | 3 ++ pester/ssh-server.Tests.ps1 | 14 ++++- pester/xaml.Tests.ps1 | 1 + scripts/start.ps1 | 1 + 11 files changed, 97 insertions(+), 9 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index e88d90a2..f3e9530f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -186,3 +186,5 @@ When the user corrects an agent approach, add or tighten one concrete rule here - For Win11 Creator driver injection, keep offline WIM servicing to one mount and one commit: add each root package folder with its own `/Add-Driver /Recurse` so a single bad driver cannot fail the rest, and skip any folder whose ancestor is already in the set, since that ancestor's `/Recurse` covers it. Warn per failure and commit only when at least one package was added; when none were, warn and discard rather than throwing, so the run still produces an ISO. The discard in the cleanup block carries both orphaned mounts and that intentional zero-added case; keep it. Do not export editions or run unrelated WIM cleanup, and reject damaged metadata before ISO export. Use `-LiteralPath` for driver export paths, since `%TEMP%` can contain wildcard characters. - For Script Analyzer cleanup, fix actionable source warnings first and do not globally suppress accepted convention warnings such as plural names, `ShouldProcess` on UI helpers, `$global:sync`, or compile-time cross-file false positives. - For DNS DHCP reset, keep the cmdlet reset and explicitly set IPv4 and IPv6 DNS source to DHCP. +- Public pull-request diffs may be sent to configured external review services without a separate privacy approval; do not block the review loop on upload authorization for this public repository. +- Keep install-tab favicon loading overlapped with app-entry rendering; do not replace native WPF loading with a deferred second phase unless visible completion time is proven no slower than `main`. diff --git a/Compile.ps1 b/Compile.ps1 index 51630a1b..82e85ea0 100644 --- a/Compile.ps1 +++ b/Compile.ps1 @@ -9,6 +9,8 @@ $sync = [Hashtable]::Synchronized(@{}) $sync.configs = @{} $script = (Get-Content -Path scripts\start.ps1) -replace '#{replaceme}', (Get-Date -Format 'yy.MM.dd') +$isLocalCompile = -not [string]::Equals($env:GITHUB_ACTIONS, "true", [StringComparison]::OrdinalIgnoreCase) +$script = $script -replace '#{islocalcompile}', $isLocalCompile.ToString().ToLowerInvariant() $script += Get-ChildItem -Path functions -Recurse -File | ForEach-Object { Get-Content -Path $_.FullName -Raw diff --git a/functions/private/Invoke-WinUtilSSHServer.ps1 b/functions/private/Invoke-WinUtilSSHServer.ps1 index a8529724..2d46207b 100644 --- a/functions/private/Invoke-WinUtilSSHServer.ps1 +++ b/functions/private/Invoke-WinUtilSSHServer.ps1 @@ -24,7 +24,7 @@ function Invoke-WinUtilSSHServer { if ($null -eq $firewallRule) { New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 Write-Host "Firewall rule for OpenSSH Server created and enabled." - } elseif (-not $firewallRule.Enabled) { + } elseif ([int]$firewallRule.Enabled -eq 2) { Set-NetFirewallRule -Name 'sshd' -Enabled True Write-Host "Firewall rule for OpenSSH Server enabled." } diff --git a/functions/private/Measure-WinUtilStep.ps1 b/functions/private/Measure-WinUtilStep.ps1 index ffa5163f..6487a5d9 100644 --- a/functions/private/Measure-WinUtilStep.ps1 +++ b/functions/private/Measure-WinUtilStep.ps1 @@ -27,13 +27,15 @@ function Measure-WinUtilStep { [string]$Scope = "WinUtil" ) + $isUIDiagnostic = $Scope -in @("UI", "Tab") + $captureTiming = -not $isUIDiagnostic -or $sync.IsLocalCompile $stopwatch = [System.Diagnostics.Stopwatch]::StartNew() try { & $ScriptBlock } finally { $stopwatch.Stop() - if ($null -ne $sync.StepTimings) { + if ($captureTiming -and $null -ne $sync.StepTimings) { $null = $sync.StepTimings.Add([pscustomobject]@{ Scope = $Scope Step = $Name @@ -41,7 +43,10 @@ function Measure-WinUtilStep { }) } - Write-WinUtilLog -Component $Scope -Message "timing: $Name took $($stopwatch.ElapsedMilliseconds) ms" + if ($captureTiming) { + $level = if ($isUIDiagnostic) { "DEBUG" } else { "INFO" } + Write-WinUtilLog -Level $level -Component $Scope -Message "timing: $Name took $($stopwatch.ElapsedMilliseconds) ms" + } } } @@ -71,7 +76,8 @@ function Write-WinUtilTimingSummary { [int]$StartIndex = 0 ) - if ($null -eq $sync.StepTimings) { + $isUIDiagnostic = $Scope -in @("UI", "Tab") + if (($isUIDiagnostic -and -not $sync.IsLocalCompile) -or $null -eq $sync.StepTimings) { return } @@ -90,9 +96,10 @@ function Write-WinUtilTimingSummary { $measured = ($steps | Measure-Object -Property Milliseconds -Sum).Sum $total = if ($TotalMilliseconds -ge 0) { $TotalMilliseconds } else { $measured } - Write-WinUtilLog -Component $Scope -Message "timing summary: $($steps.Count) step(s), $measured ms measured of $total ms total" + $level = if ($isUIDiagnostic) { "DEBUG" } else { "INFO" } + Write-WinUtilLog -Level $level -Component $Scope -Message "timing summary: $($steps.Count) step(s), $measured ms measured of $total ms total" foreach ($step in ($steps | Sort-Object Milliseconds -Descending | Select-Object -First $Top)) { $share = if ($total -gt 0) { [int](($step.Milliseconds / $total) * 100) } else { 0 } - Write-WinUtilLog -Component $Scope -Message "timing summary: $($step.Milliseconds) ms ($share%) $($step.Step)" + Write-WinUtilLog -Level $level -Component $Scope -Message "timing summary: $($step.Milliseconds) ms ($share%) $($step.Step)" } } diff --git a/functions/private/Start-WinUtilUserInterface.ps1 b/functions/private/Start-WinUtilUserInterface.ps1 index 28b9e33b..6aba6169 100644 --- a/functions/private/Start-WinUtilUserInterface.ps1 +++ b/functions/private/Start-WinUtilUserInterface.ps1 @@ -513,14 +513,14 @@ Version :