Skip to content

Auto-activate kiosk mode on launch when previously enabled#4609

Open
nstefanelli wants to merge 1 commit intohome-assistant:mainfrom
nstefanelli:kiosk-fix-auto-activate-on-launch
Open

Auto-activate kiosk mode on launch when previously enabled#4609
nstefanelli wants to merge 1 commit intohome-assistant:mainfrom
nstefanelli:kiosk-fix-auto-activate-on-launch

Conversation

@nstefanelli
Copy link
Copy Markdown
Contributor

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 = true is loaded into memory by KioskModeManager.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 from WebViewController.viewDidLoad), if settings.isKioskModeEnabled is true and kiosk mode is not already active, call enableKioskMode() to restore it.

enableKioskMode() is idempotent — it guards on !isKioskModeActive — so this is safe to call from any path and existing flows are unaffected.

// 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
}

Test plan

  • Enable kiosk mode in the app
  • Force-quit the app from the app switcher
  • Re-launch
  • Verify the screen comes back up in kiosk mode (status bar hidden, screensaver active, secret exit gesture working)
  • Reboot the device — verify kiosk mode is still on after launch
  • Disable kiosk mode, force-quit, re-launch — verify it stays disabled

Notes

  • KioskModeManager is 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.
  • Out of scope (per the issue): a "panic recovery" guard so a crash loop inside kiosk mode does not trap the user. Worth a follow-up.
  • Local xcodebuild was blocked by an unrelated BuildMaterialDesignIconsFont script failure in my environment, but swiftformat --lint passes and the change uses existing APIs that mirror the adjacent code path.

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
Copilot AI review requested due to automatic review settings May 5, 2026 04:09
Copy link
Copy Markdown
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

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:), detect settings.isKioskModeEnabled == true and call enableKioskMode() 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
Copy link
Copy Markdown
Member

@bgoncal bgoncal left a comment

Choose a reason for hiding this comment

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

LGTM! Just missing the test that copilot has catch

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.

Kiosk Mode does not auto-activate on app launch when previously enabled

3 participants