Fix silent runner startup after login - #2
Conversation
Development log: investigation and regression
|
Development log: implementation and validation
|
Development log: independent review round 1The Explore subagent found one blocking migration issue and one related multi-runner risk:
Remediation in
A second independent review will run after CI completes. |
Development log: independent review round 2The second Explore review confirmed the migration-write blocker was fixed, then found one remaining ownership issue: disabling autostart still removed the shared legacy value unconditionally. Remediation in
A third independent review will run after CI completes. |
Development log: independent review round 3The third Explore review found no blocking issues and judged PR #2 deliverable. It rechecked all earlier migration and ownership findings, silent login startup, PowerShell 5.1 compatibility, and test coverage. One non-blocking documentation mismatch remained: the README implied the shared legacy value was always removed when disabling autostart. Commit A final quick review and latest CI confirmation will close the delivery gate. |
Delivery gate passed
PR #2 is ready for delivery. |
There was a problem hiding this comment.
🟡 Changes recommended
The new legacy-autostart cleanup/migration logic relies on exact command-string equality (including the exact PowerShell executable path), which can fail to detect/clean legacy entries that still target the same script, leading to missed migration and possible double-launch behavior.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates the tray launcher so that when started at Windows login it will automatically start the runner silently and record the outcome to the host log, while also safely migrating older “tray-only” autostart registry entries to the new behavior.
Changes:
- Add
-StartRunnerOnLaunchto the autostart command line and wire it into startup flow. - Add a silent runner-start helper that logs success/failure without UI.
- Add legacy autostart migration/repair logic and extend Pester coverage + README documentation accordingly.
File summaries
| File | Description |
|---|---|
runner-tray.ps1 |
Adds login-triggered silent runner startup and legacy autostart migration/cleanup logic. |
tests/runner-tray.Tests.ps1 |
Extends Pester tests to validate silent startup logging and legacy registry migration behavior. |
README.md |
Updates documentation to reflect silent startup and safer legacy autostart cleanup behavior. |
Review details
Suppressed comments (2)
runner-tray.ps1:354
- Same issue in the disable path: the legacy fixed-name value is only removed when it exactly matches the currently generated command strings. If it still points at this script but differs in exe path/flags, disabling autostart can leave the legacy entry behind, so Windows will continue launching the tray.
try {
$legacyValue = (Get-ItemProperty -Path $AutostartRegPath -Name $LegacyAutostartValueName -ErrorAction Stop).$LegacyAutostartValueName
if ($legacyValue -and ($legacyValue.Trim() -iin @((Get-AutostartCommand), (Get-LegacyAutostartCommand)))) {
Remove-ItemProperty -Path $AutostartRegPath -Name $LegacyAutostartValueName -ErrorAction SilentlyContinue
}
runner-tray.ps1:366
- Repair-LegacyAutostartCommand only recognizes legacy entries when the entire stored command equals Get-LegacyAutostartCommand (including the exact $PowerShellExe path). If the legacy value still points at this runner-tray.ps1 but uses a different exe path/flags, migration (and the intended silent runner start) will never trigger.
$legacyCommand = Get-LegacyAutostartCommand
foreach ($valueName in @($AutostartValueName, $LegacyAutostartValueName)) {
try {
$currentValue = (Get-ItemProperty -Path $AutostartRegPath -Name $valueName -ErrorAction Stop).$valueName
if ($currentValue -and ($currentValue.Trim() -ieq $legacyCommand)) {
try {
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| try { | ||
| $legacyValue = (Get-ItemProperty -Path $AutostartRegPath -Name $LegacyAutostartValueName -ErrorAction Stop).$LegacyAutostartValueName | ||
| if ($legacyValue -and ($legacyValue.Trim() -iin @((Get-AutostartCommand), (Get-LegacyAutostartCommand)))) { | ||
| Remove-ItemProperty -Path $AutostartRegPath -Name $LegacyAutostartValueName -ErrorAction SilentlyContinue | ||
| } |
Summary
Validation