Auto-activate kiosk mode on launch when previously enabled#4609
Open
nstefanelli wants to merge 1 commit intohome-assistant:mainfrom
Open
Auto-activate kiosk mode on launch when previously enabled#4609nstefanelli wants to merge 1 commit intohome-assistant:mainfrom
nstefanelli wants to merge 1 commit intohome-assistant:mainfrom
Conversation
When kiosk mode is enabled and the app is then force-quit, crashes, or the device reboots, the persisted setting in GRDB is loaded but never acted on at launch. The user has to manually re-toggle kiosk mode from settings. Restore kiosk mode in setup(using:) when settings.isKioskModeEnabled is true. enableKioskMode() is idempotent (guarded by !isKioskModeActive), so existing flows are unaffected. Fixes home-assistant#4608
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes #4608 by ensuring Kiosk Mode is automatically re-activated on app launch when it was previously enabled (persisted in KioskSettings), addressing the wall-mounted dashboard use case where restarts currently fall back to normal UI.
Changes:
- In
KioskModeManager.setup(using:), detectsettings.isKioskModeEnabled == trueand callenableKioskMode()when kiosk mode isn’t already active. - Add a log entry indicating kiosk mode is being restored from persisted settings.
Comment on lines
+178
to
+182
| // Restore kiosk mode if it was enabled before the app was last closed | ||
| if settings.isKioskModeEnabled, !isKioskModeActive { | ||
| Current.Log.info("Restoring kiosk mode from persisted settings") | ||
| enableKioskMode() | ||
| return |
bgoncal
approved these changes
May 6, 2026
Member
bgoncal
left a comment
There was a problem hiding this comment.
LGTM! Just missing the test that copilot has catch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #4608.
When kiosk mode is enabled and the Home Assistant app is then force-quit, crashes, or the device reboots, kiosk mode does not re-activate on the next launch. The persisted
settings.isKioskModeEnabled = trueis loaded into memory byKioskModeManager.loadSettings()but never acted on, so the user has to manually re-toggle kiosk mode from settings each time. For the wall-mounted iPad use case kiosk mode is designed for, this leaves an unattended dashboard silently falling back to the normal UI after any restart.What changed
In
KioskModeManager.setup(using:)(called fromWebViewController.viewDidLoad), ifsettings.isKioskModeEnabledistrueand kiosk mode is not already active, callenableKioskMode()to restore it.enableKioskMode()is idempotent — it guards on!isKioskModeActive— so this is safe to call from any path and existing flows are unaffected.Test plan
Notes
KioskModeManageris a singleton with UIKit dependencies and no existing tests, so I haven't added a unit test here. Happy to add one if there's a preferred pattern for managers like this.xcodebuildwas blocked by an unrelatedBuildMaterialDesignIconsFontscript failure in my environment, butswiftformat --lintpasses and the change uses existing APIs that mirror the adjacent code path.