Add support for Add to feature within FrontendScreen#6792
Open
Add support for Add to feature within FrontendScreen#6792
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds Entity “Add to” support to the Compose-based FrontendScreen external bus flow, while reusing the same underlying handler logic previously owned by WebViewActivity, and refactors external bus result-message creation into factory objects with invoke.
Changes:
- Introduces
FrontendEntityAddToHandlerand wires it into bothFrontendMessageHandler(Frontend V2) andWebViewActivity(legacy) - Adds incoming/external-bus message types for
entity/add_toandentity/add_to/get_actions, plus outgoing result payload for actions - Refactors external-bus “result” message creation (
SuccessResultMessage,ConfigResultMessage,EntityAddToActionsResultMessage) and updates tests accordingly
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| app/src/main/kotlin/io/homeassistant/companion/android/frontend/addto/FrontendEntityAddToHandler.kt | New shared handler for AddTo action discovery + execution returning FrontendEvents |
| app/src/main/kotlin/io/homeassistant/companion/android/frontend/externalbus/incoming/IncomingExternalBusMessage.kt | Adds typed incoming messages for entity/add_to and entity/add_to/get_actions |
| app/src/main/kotlin/io/homeassistant/companion/android/frontend/externalbus/outgoing/OutgoingExternalBusMessage.kt | Refactors result message creation and adds actions result payload |
| app/src/main/kotlin/io/homeassistant/companion/android/frontend/handler/FrontendHandlerEvent.kt | Adds handler events for AddTo actions sent/executed |
| app/src/main/kotlin/io/homeassistant/companion/android/frontend/handler/FrontendMessageHandler.kt | Handles new AddTo incoming messages and sends typed results |
| app/src/main/kotlin/io/homeassistant/companion/android/frontend/navigation/FrontendEvent.kt | Adds LaunchWidgetConfig event |
| app/src/main/kotlin/io/homeassistant/companion/android/frontend/navigation/FrontendNavigation.kt | Adds navigation handling for widget-config launch |
| app/src/main/kotlin/io/homeassistant/companion/android/frontend/navigation/WidgetType.kt | New sealed WidgetType to map widget type → configure Intent |
| app/src/main/kotlin/io/homeassistant/companion/android/frontend/FrontendViewModel.kt | Forwards AddTo execution events and uses SuccessResultMessage |
| app/src/main/kotlin/io/homeassistant/companion/android/webview/WebViewActivity.kt | Switches legacy AddTo flow to shared handler returning FrontendEvents |
| app/src/main/kotlin/io/homeassistant/companion/android/webview/externalbus/ExternalBusMessage.kt | Uses snake_case JSON names for ExternalEntityAddToAction fields |
| app/src/main/kotlin/io/homeassistant/companion/android/webview/addto/EntityAddToHandler.kt | Removes legacy handler (logic moved to shared handler) |
| app/src/test/kotlin/io/homeassistant/companion/android/frontend/addto/FrontendEntityAddToHandlerTest.kt | New unit tests for shared AddTo handler behavior |
| app/src/test/kotlin/io/homeassistant/companion/android/frontend/handler/FrontendMessageHandlerTest.kt | Adds tests for new AddTo message handling + result sending |
| app/src/test/kotlin/io/homeassistant/companion/android/frontend/externalbus/incoming/IncomingExternalBusMessageTest.kt | Adds parsing coverage for new AddTo incoming messages |
| app/src/test/kotlin/io/homeassistant/companion/android/frontend/externalbus/outgoing/OutgoingExternalBusMessageTest.kt | Updates config-result test + asserts snake_case in actions result JSON |
| app/src/test/kotlin/io/homeassistant/companion/android/frontend/externalbus/FrontendExternalBusRepositoryImplTest.kt | Updates config-result creation to new factory object |
| app/src/test/kotlin/io/homeassistant/companion/android/frontend/navigation/FrontendEventHandlerTest.kt | Updates event handler setup for widget-config callback |
| app/src/test/kotlin/io/homeassistant/companion/android/frontend/FrontendViewModelTest.kt | Adds coverage for AddTo forwarding + updates success-result usage |
| app/src/test/kotlin/io/homeassistant/companion/android/webview/addto/EntityAddToHandlerTest.kt | Removes tests for deleted legacy handler |
48 tasks
jpelgrom
reviewed
May 7, 2026
| * @param entityId The entity to pre-fill in the widget configuration | ||
| * @param widgetType The type of widget to configure | ||
| */ | ||
| data class LaunchWidgetConfig(val entityId: String, val widgetType: WidgetType) : FrontendEvent |
Member
There was a problem hiding this comment.
Why not NavigateToWidgetConfig? Events forwarding you to another part of the app are NavigateTo...
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
Add the Add to feature to the
FrontendScreenwhile trying to mutualize the code with the WebViewActivity.I've also changed how we use the
ResultMessageto use object and invoke operator.Checklist