Skip to content

fix: prevent UAC prompts and browser tabs during local test runs#520

Merged
laurentiu021 merged 1 commit into
mainfrom
fix/silent-tests-no-uac-no-browser
May 25, 2026
Merged

fix: prevent UAC prompts and browser tabs during local test runs#520
laurentiu021 merged 1 commit into
mainfrom
fix/silent-tests-no-uac-no-browser

Conversation

@laurentiu021
Copy link
Copy Markdown
Owner

@laurentiu021 laurentiu021 commented May 25, 2026

Summary

  • AdminHelper.RelaunchAsAdmin: early-return when no WPF Application (test host)
  • AboutViewModel.OpenUrl: skip browser launch in test context
  • DialogService.Confirm: return false when no Application, preventing MessageBox

Impact

All 2281 tests now run fully silent — zero UAC dialogs, zero browser tabs, zero MessageBox popups during dotnet test.

Test plan

  • Full suite: 2281 passed, 0 failed, 0 skipped
  • Previously failing SFC/DISM tests now pass
  • Previously prompting AdminHelper tests now silent
  • Previously browser-opening About tests now silent

Summary by CodeRabbit

Bug Fixes

  • Improved application stability by adding protective validation checks before executing critical operations. The app now validates its environment before requesting admin privileges, displaying dialogs, and opening web links. This prevents crashes and unexpected behavior that could occur in edge cases and unusual scenarios where the application environment may not be properly initialized or available.

Review Change Stack

- AdminHelper.RelaunchAsAdmin: skip Process.Start when no WPF Application
  is running (test host context)
- AboutViewModel.OpenUrl: skip browser launch when no Application context
- DialogService.Confirm: return false when no Application context,
  preventing MessageBox from appearing during test execution

Tests now run fully silent — no UAC dialogs, no browser tabs, no MessageBox
popups. All 2281 tests pass with zero user interaction required.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 93ca85db-0d7d-444e-93b2-986108892597

📥 Commits

Reviewing files that changed from the base of the PR and between 73d9884 and 6d8f992.

📒 Files selected for processing (3)
  • SysManager/SysManager/Helpers/AdminHelper.cs
  • SysManager/SysManager/Services/DialogService.cs
  • SysManager/SysManager/ViewModels/AboutViewModel.cs
📜 Recent review details
🔇 Additional comments (3)
SysManager/SysManager/Helpers/AdminHelper.cs (1)

28-28: LGTM!

SysManager/SysManager/Services/DialogService.cs (1)

26-26: LGTM!

SysManager/SysManager/ViewModels/AboutViewModel.cs (1)

567-567: LGTM!


📝 Walkthrough

Walkthrough

Three WPF-context-dependent methods—AdminHelper.RelaunchAsAdmin, DialogService.Confirm, and AboutViewModel.OpenUrl—now add early guards that check whether System.Windows.Application.Current is null. Each method returns false or void immediately if the WPF application context is unavailable, preventing process elevation, message box display, and URL launching in invalid contexts.

Changes

WPF Application Context Guards

Layer / File(s) Summary
Application context null-checks
SysManager/SysManager/Helpers/AdminHelper.cs, SysManager/SysManager/Services/DialogService.cs, SysManager/SysManager/ViewModels/AboutViewModel.cs
RelaunchAsAdmin, Confirm, and OpenUrl each add an early guard returning false or void when System.Windows.Application.Current is null, preventing WPF operations outside a valid application context.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • laurentiu021/SystemManager#504: Adds "relaunch elevated" behavior in ServicesViewModel that depends on the hardened AdminHelper.RelaunchAsAdmin null-check logic added in this PR.

Poem

A rabbit refactored with care,
Null checks placed here and there,
No WPF? Return with grace,
Safe guards for every place! 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: prevent UAC prompts and browser tabs during local test runs' is fully related to the main changeset, which adds null-checks to AdminHelper, DialogService, and AboutViewModel to prevent UAC dialogs, browser tabs, and MessageBox popups during test execution.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/silent-tests-no-uac-no-browser

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@laurentiu021 laurentiu021 merged commit a64d351 into main May 25, 2026
5 checks passed
@laurentiu021 laurentiu021 deleted the fix/silent-tests-no-uac-no-browser branch May 25, 2026 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant