Skip to content

Move the debug flag for WebView into the Application and Settings#6813

Open
TimoPtr wants to merge 1 commit intomainfrom
feature/WebViewDebug
Open

Move the debug flag for WebView into the Application and Settings#6813
TimoPtr wants to merge 1 commit intomainfrom
feature/WebViewDebug

Conversation

@TimoPtr
Copy link
Copy Markdown
Member

@TimoPtr TimoPtr commented May 6, 2026

Summary

Move the set of the debug capability of the WebView at the Application level and also in the settings level. The idea is to enable/disable it globally so that it apply right away when changing and also when the app starts.

There is a risk where maybe the debug flag is set after the webview load since it uses the ioScope in the Application but I'm not sure.

@TimoPtr TimoPtr requested review from Copilot and jpelgrom May 6, 2026 09:18
@TimoPtr TimoPtr added the WebViewActivity replacement Ongoing work to replace the WebViewActivity in favor of a well tested compose screen using nav. label May 6, 2026
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 centralizes WebView remote debugging enablement by moving the WebView.setWebContentsDebuggingEnabled(...) call out of WebViewActivity and into app-level startup plus the Developer Settings toggle, aiming to apply the setting globally and immediately when changed.

Changes:

  • Remove WebView debugging preference plumbing from WebViewPresenter/WebViewPresenterImpl and stop setting it from WebViewActivity
  • Apply the saved WebView remote debugging setting during HomeAssistantApplication startup
  • Apply WebView remote debugging immediately when toggled in Developer Settings

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
app/src/main/kotlin/io/homeassistant/companion/android/webview/WebViewPresenterImpl.kt Removes the presenter method that exposed the WebView debug preference
app/src/main/kotlin/io/homeassistant/companion/android/webview/WebViewPresenter.kt Removes isWebViewDebugEnabled() from the presenter interface
app/src/main/kotlin/io/homeassistant/companion/android/webview/WebViewActivity.kt Stops enabling WebView debugging from the activity lifecycle
app/src/main/kotlin/io/homeassistant/companion/android/settings/developer/DeveloperSettingsPresenterImpl.kt Enables/disables WebView debugging immediately when the developer preference is toggled
app/src/main/kotlin/io/homeassistant/companion/android/HomeAssistantApplication.kt Attempts to apply the saved WebView debugging setting on app startup

@@ -99,6 +100,7 @@ open class HomeAssistantApplication :
registerActivityLifecycleCallbacks(LifecycleHandler)

Copy link
Copy Markdown
Member

@jpelgrom jpelgrom left a comment

Choose a reason for hiding this comment

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

Verified. I don't see a new race happening here as this should result in it being set earlier in the lifecycle, but good to stay alert to reports of it not working.

registerActivityLifecycleCallbacks(LifecycleHandler)

ioScope.launch {
WebView.setWebContentsDebuggingEnabled(BuildConfig.DEBUG || prefsRepository.isWebViewDebugEnabled())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You may want to consider moving this down in this block so if it crashes we actually have crash reporting enabled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed WebViewActivity replacement Ongoing work to replace the WebViewActivity in favor of a well tested compose screen using nav.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants