Skip to content

Prevent window from pulling forward before UAC prompts - #5353

Merged
Gabriel Dufresne (GabrielDuf) merged 2 commits into
mainfrom
fix/5102-elevation-foreground-regression
Sep 4, 2026
Merged

Prevent window from pulling forward before UAC prompts#5353
Gabriel Dufresne (GabrielDuf) merged 2 commits into
mainfrom
fix/5102-elevation-foreground-regression

Conversation

@GabrielDuf

Copy link
Copy Markdown
Contributor

This pull request refactors how UniGetUI handles foreground window rights before showing a UAC consent prompt. The main change is to simplify and centralize foreground delegation logic, ensuring the app never unintentionally activates or brings forward the main window, which could disrupt the user. The previous mechanism using a delegate from the UI layer is removed in favor of a direct call that only delegates foreground rights if the app already owns the foreground.

Foreground rights delegation refactor:

  • Removed the CoreData.BringMainWindowToForegroundAsync delegate and all related UI-layer logic, eliminating the ability for the UI to forcibly bring the main window to the foreground before elevation. [1] [2] [3]
  • Refactored CoreTools.PrepareForegroundForElevationAsync() to a synchronous PrepareForegroundForElevation() method that only delegates foreground rights without activating the window, and updated all call sites accordingly. [1] [2] [3]

Documentation improvements:

  • Updated comments and method summaries to clarify the new behavior: the app now only delegates foreground rights and never brings the window forward, preventing unwanted interruptions when the window is minimized or in the tray. [1] [2]

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Verify UniGetUI owns the foreground before granting foreground rights.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Refactors foreground-rights delegation before UAC elevation to avoid forcibly activating UniGetUI.

Changes:

  • Removes UI-driven window activation.
  • Makes foreground delegation synchronous.
  • Updates elevation call sites and documentation.
File summaries
File Description
src/UniGetUI.PackageEngine.Operations/AbstractProcessOperation.cs Uses synchronous delegation before elevation.
src/UniGetUI.Core.Tools/Tools.cs Centralizes delegation but lacks the required foreground-process check.
src/UniGetUI.Core.Data/CoreData.cs Removes the obsolete UI delegate.
src/UniGetUI.Avalonia/Views/MainWindow.axaml.cs Removes foreground-activation wiring.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/UniGetUI.Core.Tools/Tools.cs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The ASFW_ANY documentation must accurately describe its process-wide foreground delegation.

Review details

Suppressed comments (1)

src/UniGetUI.Core.Tools/Tools.cs:759

  • ASFW_ANY delegates foreground permission to every process, not only the consent UI, as the comment above the constant also notes. Reword this to avoid promising a restriction the API does not provide while retaining the guarantee that this method does not activate UniGetUI itself.
        /// Either way this only ever lets the consent UI come forward; it never activates our
        /// own window, so a minimized UniGetUI stays minimized (#5102). No-op elsewhere.
  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@randy-but-a-ro randy-but-a-ro Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Pull request was approved automatically: the AI review is complete and all its review threads are resolved. 🎉

Integration Details
{
	"deliveryId": "10542a50-a899-11f1-8d98-d73c0b2b2be5",
	"headSha": "a884005c53e3d569b2a234436121a97ec3fec506",
	"reviewer": "copilot-pull-request-reviewer[bot]"
}

@GabrielDuf
Gabriel Dufresne (GabrielDuf) merged commit 0544681 into main Sep 4, 2026
6 checks passed
@GabrielDuf
Gabriel Dufresne (GabrielDuf) deleted the fix/5102-elevation-foreground-regression branch September 4, 2026 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants