Skip to content

Fix: DownloadManagerView traps window on Mac Catalyst with no dismiss path#4379

Merged
bgoncal merged 4 commits intomainfrom
copilot/fix-window-control-issue
Feb 23, 2026
Merged

Fix: DownloadManagerView traps window on Mac Catalyst with no dismiss path#4379
bgoncal merged 4 commits intomainfrom
copilot/fix-window-control-issue

Conversation

Copy link
Contributor

Copilot AI commented Feb 20, 2026

On Mac Catalyst, downloading the emergency kit backup presented DownloadManagerView with no way to dismiss it — no swipe gesture, no close button — requiring a force-quit to recover the window.

Mac Catalyst has no sheet swipe-to-dismiss, so the view needs an explicit close affordance via a navigation bar.

Changes

  • DownloadManagerView — conditionally adds a CloseButton as leading toolbar item when Current.isCatalyst, using the existing .modify pattern
  • WebViewController+WebKitDelegates — wraps the UIHostingController in a UINavigationController on Mac Catalyst so the toolbar is rendered
// WebViewController+WebKitDelegates.swift
if Current.isCatalyst {
    let navigationController = UINavigationController(rootViewController: downloadController)
    presentOverlayController(controller: navigationController, animated: true)
} else {
    presentOverlayController(controller: downloadController, animated: true)
}
// DownloadManagerView.swift
.modify { view in
    if Current.isCatalyst {
        view.toolbar {
            ToolbarItem(placement: .topBarLeading) {
                CloseButton { dismiss() }
            }
        }
    } else {
        view
    }
}

Pattern mirrors the existing WidgetSelectionView Mac Catalyst handling in EntityAddToHandler.

Screenshots

Before: "Download finished" overlay with no dismiss control, app window unresponsive until force-quit.

After: Navigation bar with close button allows dismissal normally.

Link to pull request in Documentation repository

Documentation: home-assistant/companion.home-assistant#

Any other notes

No documentation change needed — no user-visible feature added, only a broken interaction fixed.

Original prompt

This section details on the original issue you should resolve

<issue_title>Lost window control of HA app after downloading emergency kit backup</issue_title>
<issue_description>

Device model, version and app version

Model Name: M1 Pro MBP
macOS Version: 15.7.4
App Version: 2026.2.1
Safari Version: n/a

Home Assistant Core Version

2026.2.2

Describe the bug

Downloading the emergency kit through the macOS app results in the app window staying continually on screen and being unable to click anywhere else on screen to regain control of the app.

The app must be force closed via Activity Monitor to regain control of the app.

To Reproduce

  1. Open macOS HA app.
  2. Go to Settings, System, Backups, Settings and History, Download emergency kit

Expected behavior

Window to close after the config is downloaded allowing the user to control the app again.

Screenshots

Image

Additional context

</issue_description>

<agent_instructions>When presenting the DownloadManagerView on Mac Catalyst we can’t rely on presentation defender and gesture to dismiss, we need a navigation view with a “CloseButton” as leading toolbar item</agent_instructions>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

On Mac Catalyst, users were unable to dismiss the DownloadManagerView
after downloading the emergency kit because there's no swipe-to-dismiss
gesture. Fix by adding a CloseButton as leading toolbar item via a
NavigationController wrapper when on Mac Catalyst.

Co-authored-by: bgoncal <5808343+bgoncal@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix lost window control in HA app after emergency kit backup Fix: DownloadManagerView traps window on Mac Catalyst with no dismiss path Feb 20, 2026
Copilot AI requested a review from bgoncal February 20, 2026 21:02
@codecov
Copy link

codecov bot commented Feb 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@c05233b). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4379   +/-   ##
=======================================
  Coverage        ?   42.95%           
=======================================
  Files           ?      262           
  Lines           ?    15182           
  Branches        ?        0           
=======================================
  Hits            ?     6522           
  Misses          ?     8660           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bgoncal bgoncal marked this pull request as ready for review February 23, 2026 09:28
Copilot AI review requested due to automatic review settings February 23, 2026 09:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a Mac Catalyst-specific UX trap where DownloadManagerView could be presented without any dismiss path, leaving the app window effectively stuck after downloading the emergency kit.

Changes:

  • Adds a Mac Catalyst-only leading toolbar CloseButton to DownloadManagerView.
  • Wraps the UIHostingController in a UINavigationController on Mac Catalyst so the toolbar/navigation bar is rendered.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
Sources/App/Frontend/WebView/WebViewController+WebKitDelegates.swift Presents the download manager inside a UINavigationController on Mac Catalyst to enable a visible navigation bar/toolbar.
Sources/App/Frontend/DownloadManager/DownloadManagerView.swift Adds a Catalyst-only close affordance via a leading toolbar item that calls dismiss().

Wrap the DownloadManagerView in a NavigationView and always attach the CloseButton toolbar (use .navigationViewStyle(.stack) for consistent behavior). Remove the previous platform-specific view.modify conditional for Catalyst. Simplify presentation in WebViewController by removing the special-case UINavigationController wrapper and present the UIHostingController directly. These changes unify the download UI and simplify presentation logic across platforms.
@bgoncal bgoncal enabled auto-merge (squash) February 23, 2026 09:45
@bgoncal bgoncal merged commit 5d88cf3 into main Feb 23, 2026
15 checks passed
@bgoncal bgoncal deleted the copilot/fix-window-control-issue branch February 23, 2026 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lost window control of HA app after downloading emergency kit backup

3 participants