Skip to content

Add an option to quit UniGetUI once automatic updates have finished - #5530

Merged
Gabriel Dufresne (GabrielDuf) merged 8 commits into
mainfrom
feature-5527-quit-after-auto-updates
Oct 16, 2026
Merged

Gabriel Dufresne (GabrielDuf) merged 8 commits into
mainfrom
feature-5527-quit-after-auto-updates

Conversation

@GabrielDuf

@GabrielDuf Gabriel Dufresne (GabrielDuf) commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Adds an opt-in setting to quit UniGetUI once automatic updates have finished, and moves the automatic update restrictions next to the switch that controls them.

Quit after automatic updates

New setting QuitAfterAutomaticUpdates, off by default. With it off, every code path behaves exactly as before.

When it is on and an automatic install pass actually launches updates (scheduled install, or an --updateapps launch), UniGetUI waits until it is idle and then quits. Idle means two consecutive 5 s checks where:

  • no package operation is running or queued,
  • no maintenance task (local/cloud backup) is running,
  • UniGetUI's own self-update is not checking or downloading. Waiting for install consent counts as idle, because quitting is what launches a ready installer, same as a manual quit.

It then quits only if:

  • the main window is hidden in the tray (a user who has the window open is never closed on),
  • there is no unsaved work. IAsyncLeaveGuard gains a non-interactive HasUnsavedWork probe (dirty catalog editor, open policy editor session), so the automatic quit never opens a discard dialog on a hidden window.

A pass that finds nothing to install does not quit. Otherwise, with the default "after every update check" frequency, the app would exit right after its first check and periodic checks and backups would never run.

Settings layout

The metered / battery / battery-saver restrictions and the new quit toggle moved from Settings → Updates to a new Automatic update restrictions section on Settings → Scheduled maintenance, below the task cards. Before, they were greyed out unless the install task, configured on that other page, was enabled.

  • They are no longer gated on the install task, because they also govern --updateapps launches, which run with that task off.
  • Setting keys are unchanged, so existing values carry over.
  • The cards keep their x:Names, so settings search still scrolls to them (now on the Scheduler page).
  • The Updates page's scheduler link subtitle now says where the restrictions live.

Testing

  • dotnet build (x64) clean; dotnet format whitespace and style with --verify-no-changes exit 0.
  • UniGetUI.Tests: settings search, policy editor, shutdown coordinator and scheduler groups pass (409 tests); UniGetUI.Core.Settings.Tests pass.
  • Settings layout checked in a dev build. The end-to-end quit after a real automatic update pass from the tray has not been exercised yet.

Not covered

  • The TUI's auto-install path does not honour the setting. The option is defined by the window being hidden in the tray, which has no TUI equivalent.

Closes #5527

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

Activity-tracking gaps and shutdown races can interrupt ongoing work or prevent a ready self-update installer from launching.

5 open findings
What changed in this PR

Adds opt-in automatic shutdown after package updates, addressing #5527, with visibility and unsaved-work safeguards.

Changes:

  • Adds idle monitoring after scheduled and command-line automatic updates.
  • Adds non-interactive unsaved-work checks.
  • Moves automatic-update restrictions to Scheduled maintenance and updates settings search.
File Description
src/​UniGetUI.Core.Settings/​SettingsEngine_Names.cs Defines the quit setting.
src/​UniGetUI.Avalonia/​Views/​SoftwarePages/​SoftwareUpdatesPage.cs Starts monitoring after automatic updates.
src/​UniGetUI.Avalonia/​Views/​SoftwarePages/​Interfaces/​PageInterfaces.cs Adds an unsaved-work probe.
src/​UniGetUI.Avalonia/​Views/​Pages/​SettingsPages/​Updates.axaml Moves restrictions and updates navigation text.
src/​UniGetUI.Avalonia/​Views/​Pages/​SettingsPages/​SettingsBasePage.axaml.cs Delegates unsaved-work detection.
src/​UniGetUI.Avalonia/​Views/​Pages/​SettingsPages/​Scheduler.axaml Hosts restrictions and the quit toggle.
src/​UniGetUI.Avalonia/​Views/​Pages/​SettingsPages/​AgentPolicyInspector.axaml.cs Reports active editor sessions.
src/​UniGetUI.Avalonia/​Views/​MainWindow.axaml.cs Exposes unsaved-work state.
src/​UniGetUI.Avalonia/​ViewModels/​Pages/​SettingsPages/​UpdatesViewModel.cs Removes obsolete restriction gating.
src/​UniGetUI.Avalonia/​ViewModels/​MainWindowViewModel.cs Aggregates unsaved-work checks.
src/​UniGetUI.Avalonia/​Infrastructure/​SettingsSearchIndex.cs Updates restriction targets and indexes the toggle.
src/​UniGetUI.Avalonia/​Infrastructure/​QuitAfterAutomaticUpdates.cs Implements idle polling and conditional shutdown.
src/​UniGetUI.Avalonia/​Infrastructure/​MaintenanceScheduler.cs Exposes maintenance activity.
src/​UniGetUI.Avalonia/​Infrastructure/​AvaloniaOperationRegistry.cs Extracts the active-operation check.
src/​UniGetUI.Avalonia/​Infrastructure/​AvaloniaAutoUpdater.cs Tracks updater activity and consent waiting.
src/​Languages/​lang_en.json Adds English settings text.

🧠 Review effort: 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.Avalonia/Infrastructure/QuitAfterAutomaticUpdates.cs Outdated
Comment thread src/UniGetUI.Avalonia/Infrastructure/AvaloniaAutoUpdater.cs Outdated
Comment thread src/UniGetUI.Avalonia/Infrastructure/AvaloniaOperationRegistry.cs
Comment thread src/UniGetUI.Avalonia/Infrastructure/QuitAfterAutomaticUpdates.cs Outdated
Comment thread src/UniGetUI.Avalonia/Infrastructure/QuitAfterAutomaticUpdates.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.

Comment thread src/UniGetUI.Avalonia/Infrastructure/AvaloniaAutoUpdater.cs Outdated

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

Overlapping self-update attempts can lose an outstanding handoff, allowing shutdown before a ready installer launches.

1 open finding
1 resolved since last review

🧠 Review effort: Balanced

Comment thread src/UniGetUI.Avalonia/Infrastructure/AvaloniaAutoUpdater.cs Outdated

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

Automatic shutdown can discard unsaved bundle edits, and the tray shutdown flow still needs end-to-end validation.

1 open finding
1 resolved since last review

🧠 Review effort: Balanced

Comment thread src/UniGetUI.Avalonia/ViewModels/MainWindowViewModel.cs Outdated

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

Dismissing canceled operations can permit shutdown before cancellation finishes, and automatic-quit safeguards lack regression coverage.

1 open finding
1 resolved since last review
Previously missed (1)

In code that hasn't changed since last review

Medium severity Add regression tests for automatic-quit decision logic

src/​UniGetUI.Avalonia/​Infrastructure/​QuitAfterAutomaticUpdates.cs:62

The automatic-quit decision has no regression coverage. The new tests cover installer handoffs, while ApplicationShutdownCoordinatorTests covers shutdown authorization rather than this path. Please expose a testable decision helper or inject the activity probes and quit callback, then add deterministic tests for two consecutive idle samples, resetting on activity, and vetoing shutdown when the setting is disabled, the window is visible, or work is unsaved. These checks protect against unexpected exits during work or editing.

🧠 Review effort: Balanced

Comment thread src/UniGetUI.Avalonia/Infrastructure/QuitAfterAutomaticUpdates.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

Automatic-shutdown safeguards lack direct regression coverage, and tray-to-exit behavior remains unverified end to end.

1 open finding
1 resolved since last review

🧠 Review effort: Balanced

Comment thread src/UniGetUI.Avalonia/Infrastructure/QuitAfterAutomaticUpdates.cs Outdated

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

Real tray shutdown and cross-platform installer handoffs still need end-to-end validation, including published NativeAOT execution.

0 open findings

1 resolved since last review

🧠 Review effort: 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": "94da8f10-c989-11f1-93bb-9219d7076dc5",
	"headSha": "964280cfb80e3bf1cb77c2c255e89d53d0f34d18",
	"reviewer": "copilot-pull-request-reviewer[bot]"
}

@GabrielDuf
Gabriel Dufresne (GabrielDuf) merged commit 71fbbd2 into main Oct 16, 2026
7 checks passed
@GabrielDuf
Gabriel Dufresne (GabrielDuf) deleted the feature-5527-quit-after-auto-updates branch October 16, 2026 18:31
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.

[FEATURE REQUEST] Automatically close UnigetUI once all updates have finished

2 participants