Skip to content

Conversation

@anikiki
Copy link
Contributor

@anikiki anikiki commented Nov 5, 2025

Task/Issue URL: https://app.asana.com/1/137249556945/project/1200581511062568/task/1211783737656573?focus=true

Description

Added support in the RemoteMessage model for displaying remote messages on different surfaces.
This PR introduces a new Surface enum with two values: MODAL and NEW_TAB_PAGE and a new surfaces field in the RemoteMessage.

If no surfaces are specified in the JSON, messages will default to appearing on the NEW_TAB_PAGE surface.

Steps to test this PR

NO UI changes

Copy link
Contributor Author

anikiki commented Nov 5, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@anikiki anikiki marked this pull request as ready for review November 5, 2025 17:47
@anikiki anikiki requested review from cmonfortep and Copilot November 5, 2025 17:47
Copy link
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 adds a new surfaces field to the RemoteMessage data structure, allowing messages to specify which UI surfaces they should appear on (e.g., modal or new tab page). The PR introduces a Surface enum with a default fallback to NEW_TAB_PAGE when surfaces are not specified.

  • Adds Surface enum with MODAL and NEW_TAB_PAGE values
  • Updates RemoteMessage data class to include a surfaces field
  • Updates all test fixtures and test cases to accommodate the new field

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
RemoteMessage.kt Adds Surface enum and surfaces field to RemoteMessage data class with a fromList factory method that defaults to NEW_TAB_PAGE
JsonRemoteMessagingConfig.kt Adds nullable surfaces field to JSON model
JsonRemoteMessageMapper.kt Maps JSON surfaces list to Surface enum list using Surface.fromList
AppRemoteMessagingRepository.kt Provides empty list for surfaces when creating remote messages
RemoteMessageOM.kt Updates test fixture builders to accept surfaces parameter
JsonRemoteMessageOM.kt Updates JSON test fixture builder to accept surfaces parameter
RemoteMessageViewModelTest.kt Updates test cases to include empty surfaces list in RemoteMessage construction
RemoteMessagingModelTests.kt Updates test cases to include empty surfaces list in RemoteMessage construction
RemoteMessagingConfigJsonMapperTest.kt Updates test assertions to include NEW_TAB_PAGE in expected surfaces
JsonRemoteMessageMapperTest.kt Updates test expectations to include NEW_TAB_PAGE in expected surfaces
AppRemoteMessagingRepositoryTest.kt Updates test cases to include empty surfaces list in RemoteMessage construction

fun fromList(jsonValues: List<String>?): List<Surface> {
return jsonValues?.mapNotNull { value ->
values().firstOrNull { it.jsonValue == value }
} ?: listOf(NEW_TAB_PAGE)
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

The default fallback to NEW_TAB_PAGE when surfaces are null or empty could cause issues with messages intended for other surfaces. Consider returning an empty list for null/missing surfaces and handling the default at a higher level, or documenting this behavior clearly if it's intentional for backward compatibility.

Suggested change
} ?: listOf(NEW_TAB_PAGE)
} ?: emptyList()

Copilot uses AI. Check for mistakes.
val exclusionRules: List<Int>,
val matchingRules: List<Int>,
val translations: Map<String, JsonContentTranslations>,
val surfaces: List<String>?,
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

The nullable surfaces field in JSON model allows null values but silently converts them to [NEW_TAB_PAGE]. This could hide missing data in the JSON configuration. Consider making this non-nullable with a default empty list, or documenting that null explicitly means NEW_TAB_PAGE for backward compatibility.

Suggested change
val surfaces: List<String>?,
val surfaces: List<String> = emptyList(),

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@cmonfortep cmonfortep left a comment

Choose a reason for hiding this comment

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

LGTM

NEW_TAB_PAGE("new_tab_page"),
;

companion object {
Copy link
Contributor

Choose a reason for hiding this comment

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

I know there's a similar pattern on this same file, but I feel we don't need to follow it here. I'd propose to just declare the enum here, and keep it as pure data. The mapping logic + default value, make it part of the implementation logic inside the mapper.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, makes sense. Updated 👍

val content: Content,
val matchingRules: List<Int>,
val exclusionRules: List<Int>,
val surfaces: List<Surface>,
Copy link
Contributor

Choose a reason for hiding this comment

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

All good for now. This needs api proposal, I can review quick for visibility.

However, I'm interested on what's going to be final api interface as I can see different approaches. But will ask in Asana.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the proposal 👍

@anikiki anikiki merged commit 53a06fd into develop Nov 18, 2025
14 of 15 checks passed
@anikiki anikiki deleted the feature/ana/android_whats_new_promo_message_add_a_new_surfaces_field branch November 18, 2025 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants