Skip to content

Add support for Add to feature within FrontendScreen#6792

Open
TimoPtr wants to merge 4 commits intomainfrom
feature/add-to
Open

Add support for Add to feature within FrontendScreen#6792
TimoPtr wants to merge 4 commits intomainfrom
feature/add-to

Conversation

@TimoPtr
Copy link
Copy Markdown
Member

@TimoPtr TimoPtr commented Apr 30, 2026

Summary

Add the Add to feature to the FrontendScreen while trying to mutualize the code with the WebViewActivity.

I've also changed how we use the ResultMessage to use object and invoke operator.

Checklist

  • New or updated tests have been added to cover the changes following the testing guidelines.
  • The code follows the project's code style and best_practices.
  • The changes have been thoroughly tested, and edge cases have been considered.
  • Changes are backward compatible whenever feasible. Any breaking changes are documented in the changelog for users and/or in the code for developers depending on the relevance.

Copilot AI review requested due to automatic review settings April 30, 2026 13:16
@TimoPtr TimoPtr requested a review from jpelgrom April 30, 2026 13:17
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

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 FrontendEntityAddToHandler and wires it into both FrontendMessageHandler (Frontend V2) and WebViewActivity (legacy)
  • Adds incoming/external-bus message types for entity/add_to and entity/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

@TimoPtr TimoPtr added the WebViewActivity replacement Ongoing work to replace the WebViewActivity in favor of a well tested compose screen using nav. label Apr 30, 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
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.

Why not NavigateToWidgetConfig? Events forwarding you to another part of the app are NavigateTo...

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