Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3a871f9
Merge pull request #187 from adobe/dev
rymorale Oct 9, 2026
f407466
Merge pull request #188 from adobe/staging
rymorale Oct 9, 2026
1d89653
Merge pull request #192 from adobe/dev
rymorale Oct 14, 2026
398f787
Merge pull request #193 from adobe/staging
rymorale Oct 14, 2026
955f0c5
Add native card renderers for custom response element types
Oct 19, 2026
89aa0c9
Merge remote-tracking branch 'origin/dev' into feature/native-card-pl…
Oct 27, 2026
e1eca42
nit: collapsing in one function
Oct 27, 2026
429eb66
Initial commit: Kings specific native card plugins
Oct 27, 2026
05305fa
Merge pull request #202 from adobe/dev
rymorale Oct 27, 2026
9aa3119
Merge pull request #204 from adobe/staging
rymorale Oct 27, 2026
b96888d
Fix native card delivery and fallback handling; add offline edge-case…
Oct 28, 2026
9e3fe32
Exclude local-only renderer edge-case demo from PR
Oct 28, 2026
c088d67
Clarify generic native card renderer documentation
Oct 28, 2026
6a52c85
Merge branch 'adobe:main' into feature/native-card-plugins-v1
BNanda99 Oct 28, 2026
43ffaae
Address native card review feedback
Nov 4, 2026
54aca35
Fix native card reset and suffix alignment
Nov 5, 2026
2ec024b
Add sequence and isLatest to native card context
Nov 6, 2026
b8b5523
[MAR-2699] Render CSS box-shadow for input bar and product cards
rymorale Nov 10, 2026
e475f67
[MAR-2699] Review update and add coverage
rymorale Nov 10, 2026
13dbfa8
Merge pull request #212 from rymorale/input-box-drop-shadow
rymorale Nov 10, 2026
4d26f1d
Route custom cards by renderer ID
Nov 16, 2026
ac41aba
Omit custom elements without an accepted renderer
Nov 16, 2026
cc524b4
Show errors and keep suggestions when nothing renders
Nov 16, 2026
d9e4996
Handle empty responses when the stream drops after completion
Nov 17, 2026
1262406
Keep native card staleness reserved
Nov 17, 2026
8c1f69d
Merge branch 'adobe:main' into feature/native-card-plugins-v1
BNanda99 Nov 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Documentation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ Documentation for integrating and customizing the Adobe Experience Platform Bran

- [Implementation Guide](implementation-guide.md) - Learn how to integrate Brand Concierge into your Android app
- [Data handoff](implementation-guide.md#data-handoff) - Send application data to Brand Concierge without a chat message
- [Native card renderers (preview)](implementation-guide.md#native-card-renderers-preview) - Render `custom` elements with your own Compose cards, matched by `rendererId`
- [Style Guide](style-guide.md) - Complete reference for theming and customization options
88 changes: 88 additions & 0 deletions Documentation/implementation-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,94 @@ app owns any failure UI based on the completion result.

---

## Native card renderers (preview)

Register a Compose renderer for a `rendererId`. Brand Concierge marks custom UX elements with
`"type": "custom"` and names the client renderer in `rendererId`. When an element in
`multimodalElements.elements` is `custom` and its `rendererId` is registered, the chat renders your
card inline in the transcript, after its assistant turn completes.

```json
{
"id": "1364190",
"type": "custom",
"rendererId": "catalogRenderer",
"rendererContext": { "eventId": "event-12345" },
"entity_info": { "productName": "Veggie Nachos" }
}
```

Only `custom` elements are matched; other element types always keep their built-in rendering, even
if their `type` equals a registered id. Custom `entity_info` is opaque to the SDK and is never
parsed as a built-in card. A custom element is omitted with a warning if its `rendererId` is
missing, blank, or unregistered, or if native activation rejects it. `ctaButton` elements use CTA
parsing; other non-custom types use the existing card parser.
`rendererId` matching is exact and case-sensitive.
Within one response, the same element ID may be used by different renderers, but repeated IDs for
the same renderer are rejected for native rendering.
Replacing a registration affects subsequently activated cards; existing cards retain their renderer.
Native cards and CTAs have separate transcript rows; built-in cards are grouped into a carousel
at the first built-in card's position, so mixed responses do not preserve every element's interleaving.
Native cards do not emit the SDK's `CardsRendered` analytics event; tracking native-card impressions
and other app-specific interactions is the host app's responsibility. The SDK does not send native
card payloads through product-oriented card analytics.

```kotlin
// Once at app start, after MobileCore setup. The last registration for a rendererId wins.
Concierge.registerCardRenderer("catalogRenderer") { element, context, saveState ->
CatalogCard(element, context, saveState)
}
```

- **`element`**: the complete, deeply read-only element dictionary, including null values.
`entity_info` (the renderer-owned entity data) and `rendererContext` (optional metadata such as
an `eventId` for later interactions) are passed through unchanged. Their schemas are not
validated: either may be null or absent, and the renderer must handle that safely. Elements are copied with depth-64 and 100,000-node limits;
invalid or over-limit elements are rejected and logged before rendering.
- **`context`**: the SDK's card context, not the element's `rendererContext`. Updated when card state or busy/stale/latest flags change. `cardId`; `sessionId`, `conversationId`,
`interactionId` (each may be absent); `sequence` (Int, this card's activation order in the chat);
`isBusy` (a chat or handoff turn is in progress); `isStale` (the identity was reset); `isLatest`
(this is the most recently activated card of its `rendererId` in the chat); `state` (this card's last
saved state, if any).
- **`saveState(map)`**: replaces this card's private, in-memory state while its chat ViewModel
survives (including scrolling, hiding the chat, and configuration changes that retain that
ViewModel). It is not persisted across process death or a new ViewModel. Callable from any
thread; applied on the main thread and never sent to Brand Concierge. Values must be JSON data
within the same depth/node limits; invalid saves are logged and ignored.

Cards are disposed when their rows are rolled back, on transcript clear/identity reset, and on
ViewModel teardown. Identity reset marks cards stale before disposal. Saves after disposal are ignored.

Cards talk back with the existing APIs: `Concierge.sendDataHandoff` to start a turn with data, and
`Concierge.updateXDMContext` for committed facts later turns need.
The `sendDataHandoff` completion runs on a background thread, and the SDK doesn't deduplicate calls.
`Delivered` means the response supplied nonblank text or accepted render targets, not that a
custom renderer's business payload is valid or its UI shows useful content. A renderer that
shows its own unavailable placeholder does not change that result.

Each card gates its own controls: disable handoff controls while `isBusy` or `isStale`, and on tap,
since `isBusy` can lag it. Read both from the current `context` rather than copying them into
`remember`. The SDK keeps older cards active when newer ones arrive; keep workflow flags such as
`submitted` in `saveState`. Put only business facts Brand Concierge needs in `updateXDMContext`.

Card order comes from the SDK, never from composition: Compose doesn't compose transcript rows in
transcript order (lazy rows, recomposition), so "the last card my effect saw" is not the newest card.
- `isLatest` covers the common rule "only the newest card of a renderer is actionable": gate controls on
`isLatest && !isStale && !isBusy`. It reports order, not availability, so a stale card can still be
latest. Activating a newer card with the same `rendererId` flips the older one to `false`. If the newest card
is rolled back, the newest remaining card of that `rendererId` becomes latest again.
- `sequence` supports other cross-card rules (for example, newest per location): it strictly increases in
transcript order (including element order within one response), is fixed for the card's lifetime,
and is never reused in the chat. Rejected elements don't use a number. Compare it only between cards of
the same chat; it is not meaningful across chats or app launches.

The SDK draws no card surface: cards
render at their natural height, full width.
Renderers must not throw, must not start work during composition, and, since they are held for
the life of the process, must not capture an `Activity` or a `View`.

---

## Integration

### Managed Integration
Expand Down
8 changes: 8 additions & 0 deletions Documentation/style-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ The theme JSON file contains these top-level keys:
| `components` | Non-CSS component overrides (currently feedback dialog only) |
| `theme` | Visual styling tokens (CSS variables) |

**Custom theme keys.** Unrecognized keys in the `theme` block with a nonempty name after `--`
are retained as strings (up to 256 keys, values up to 512 characters) and exposed to your own
composables through `ConciergeTheme.tokens?.cssVariables`, keyed with its `--` prefix.
Keys and string values are trimmed; empty values are ignored. Numeric values are converted
to strings; booleans, nulls, objects and arrays are ignored.
Custom renderers can use this to read their own theme values
(for example, `--my-card-accent-color`); the SDK does not interpret them.

---

## Value Formats
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ class ExtendedProductCardTest {
content = mapOf(
"productName" to "Practice Facility Garage",
"productDescription" to "\$0.00 · Covered, Guaranteed spot",
"primaryText" to "Book on ParkWhiz",
"primaryText" to "Book now",
"primaryUrl" to "https://widget.example.com/checkout",
"secondaryText" to "Get directions",
"secondaryUrl" to "https://maps.example.com/directions"
Expand All @@ -616,7 +616,7 @@ class ExtendedProductCardTest {
}

composeTestRule.waitForIdle()
composeTestRule.onNodeWithText("Book on ParkWhiz").assertExists()
composeTestRule.onNodeWithText("Book now").assertExists()
composeTestRule.onNodeWithText("Get directions").assertExists()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
/*
* Copyright 2026 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/

package com.adobe.marketing.mobile.concierge.ui.components.messages

import android.graphics.Bitmap
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.width
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.getUnclippedBoundsInRoot
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.compose.ui.unit.DpRect
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp
import com.adobe.marketing.mobile.concierge.ConciergeCardRenderer
import com.adobe.marketing.mobile.concierge.cards.NativeCardController
import com.adobe.marketing.mobile.concierge.network.CtaButton
import com.adobe.marketing.mobile.concierge.ui.components.image.assetBitmapCache
import com.adobe.marketing.mobile.concierge.ui.state.ChatMessage
import com.adobe.marketing.mobile.concierge.ui.state.MessageContent
import com.adobe.marketing.mobile.concierge.ui.theme.ConciergeIconAssets
import com.adobe.marketing.mobile.concierge.ui.theme.ConciergeTheme
import com.adobe.marketing.mobile.concierge.ui.theme.ConciergeThemeAssets
import com.adobe.marketing.mobile.concierge.ui.theme.ConciergeThemeConfig
import com.adobe.marketing.mobile.concierge.ui.theme.ConciergeThemeData
import com.adobe.marketing.mobile.concierge.ui.theme.ConciergeThemeTokens
import com.adobe.marketing.mobile.concierge.utils.image.ImageProvider
import com.adobe.marketing.mobile.concierge.utils.image.LocalImageProvider
import java.io.IOException
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.cancel
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized

@RunWith(Parameterized::class)
class NativeCardSuggestionAlignmentTest(
private val icon: String?,
private val layoutDirection: LayoutDirection
) {
@get:Rule
val composeTestRule = createComposeRule()

private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Main.immediate)
private val imageProvider = object : ImageProvider {
override fun getCached(url: String): Bitmap? = null
override suspend fun get(url: String): Bitmap = throw IOException("Image unavailable")
override fun clear() = Unit
}

@After
fun tearDown() {
scope.cancel()
assetBitmapCache.clear()
}

private fun setMessages(
textMessage: ChatMessage,
nativeMessage: ChatMessage,
onSuggestionClick: (String) -> Unit = {},
onCtaButtonClick: (CtaButton) -> Unit = {}
) {
if (icon == "native-test-icon") {
assetBitmapCache[icon] = Bitmap.createBitmap(2, 2, Bitmap.Config.ARGB_8888).asImageBitmap()
}
val theme = ConciergeThemeData(
config = ConciergeThemeConfig(),
tokens = ConciergeThemeTokens(
assets = ConciergeThemeAssets(icons = ConciergeIconAssets(company = icon))
)
)
val renderer: ConciergeCardRenderer = { _, _, _ ->
Box(Modifier.fillMaxWidth().height(40.dp).testTag("NativeTestRenderer"))
}
val controller = NativeCardController(
scope = scope,
cardIdGenerator = { "native-card" },
rendererLookup = { rendererId -> renderer.takeIf { rendererId == "example.card" } }
)
composeTestRule.runOnUiThread {
val result = controller.activate(
NativeCardController.ActivationRequest(
element = mapOf("type" to "custom", "rendererId" to "example.card", "id" to "one"),
rendererId = "example.card",
turnId = "turn-1",
position = 0
)
)
assertTrue(result is NativeCardController.ActivationResult.Activated)
}
composeTestRule.setContent {
ConciergeTheme(theme = theme) {
CompositionLocalProvider(
LocalLayoutDirection provides layoutDirection,
LocalImageProvider provides imageProvider,
LocalNativeCardController provides controller
) {
Column(Modifier.width(360.dp)) {
ChatMessageItem(textMessage)
ChatMessageItem(
nativeMessage,
onSuggestionClick = onSuggestionClick,
onCtaButtonClick = onCtaButtonClick
)
}
}
}
}
}

private fun assertMatchingLeadingEdges(expected: DpRect, actual: DpRect) {
if (layoutDirection == LayoutDirection.Ltr) {
assertEquals(expected.left.value, actual.left.value, 1f)
} else {
assertEquals(expected.right.value, actual.right.value, 1f)
}
}

@Test
fun nativeSuggestionsMatchTextSuggestionsAndKeepActionsUsable() {
val cta = CtaButton(label = "Open details", url = "https://example.com/details")
val textMessage = ChatMessage(
content = MessageContent.Text("Agent reply"),
isFromUser = false,
timestamp = 0,
promptSuggestions = listOf("Text suggestion")
)
val nativeMessage = ChatMessage(
content = MessageContent.NativeCard("native-card"),
isFromUser = false,
timestamp = 0,
promptSuggestions = listOf("Native suggestion", "Second suggestion"),
ctaButton = cta
)
var selectedSuggestion: String? = null
var selectedCta: CtaButton? = null
setMessages(
textMessage,
nativeMessage,
onSuggestionClick = { selectedSuggestion = it },
onCtaButtonClick = { selectedCta = it }
)

composeTestRule.onNodeWithTag("NativeTestRenderer").assertIsDisplayed()
val textSuggestion = composeTestRule.onNodeWithText("Text suggestion")
val nativeSuggestion = composeTestRule.onNodeWithText("Native suggestion")
val secondSuggestion = composeTestRule.onNodeWithText("Second suggestion")
textSuggestion.assertIsDisplayed()
nativeSuggestion.assertIsDisplayed()
secondSuggestion.assertIsDisplayed()
assertMatchingLeadingEdges(textSuggestion.getUnclippedBoundsInRoot(), nativeSuggestion.getUnclippedBoundsInRoot())
val ctaNode = composeTestRule.onNodeWithTag("CtaButton")
ctaNode.assertIsDisplayed()
assertTrue(ctaNode.getUnclippedBoundsInRoot().top >= secondSuggestion.getUnclippedBoundsInRoot().bottom)

nativeSuggestion.performClick()
assertEquals("Native suggestion", selectedSuggestion)
secondSuggestion.performClick()
assertEquals("Second suggestion", selectedSuggestion)
ctaNode.performClick()
assertEquals(cta, selectedCta)
}

@Test
fun nativeCtaWithoutSuggestionsMatchesTextCta() {
val textCta = CtaButton(label = "Text action", url = "https://example.com/text")
val nativeCta = CtaButton(label = "Native action", url = "https://example.com/native")
var selectedCta: CtaButton? = null
setMessages(
ChatMessage(
content = MessageContent.Text("Agent reply"),
isFromUser = false,
timestamp = 0,
ctaButton = textCta
),
ChatMessage(
content = MessageContent.NativeCard("native-card"),
isFromUser = false,
timestamp = 0,
ctaButton = nativeCta
),
onCtaButtonClick = { selectedCta = it }
)

composeTestRule.onNodeWithTag("NativeTestRenderer").assertIsDisplayed()
val textAction = composeTestRule.onNodeWithText("Text action")
val nativeAction = composeTestRule.onNodeWithText("Native action")
textAction.assertIsDisplayed()
nativeAction.assertIsDisplayed()
assertMatchingLeadingEdges(textAction.getUnclippedBoundsInRoot(), nativeAction.getUnclippedBoundsInRoot())
nativeAction.performClick()
assertEquals(nativeCta, selectedCta)
}

companion object {
@JvmStatic
@Parameterized.Parameters(name = "icon={0}, direction={1}")
fun cases(): List<Array<Any?>> =
listOf(null, "native-test-icon", "missing-native-test-icon", "https://example.invalid/icon.png")
.flatMap { icon ->
listOf(LayoutDirection.Ltr, LayoutDirection.Rtl).map { direction ->
arrayOf(icon, direction)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
package com.adobe.marketing.mobile.concierge

import com.adobe.marketing.mobile.Extension
import com.adobe.marketing.mobile.concierge.cards.ConciergeCardRenderers
import com.adobe.marketing.mobile.concierge.ui.chat.ConciergeChat
import com.adobe.marketing.mobile.concierge.ui.chat.ConciergeChatView

Expand Down Expand Up @@ -55,6 +56,24 @@ object Concierge {
ConciergeAuthTokenHolder.setProvider(provider, timeoutMillis)
}

/**
* Renders `custom` response elements whose `rendererId` exactly matches [rendererId] with
* [renderer], inline in the transcript. Registering a `rendererId` again replaces its renderer
* for cards activated afterwards. Other element types keep their built-in rendering. Custom
* elements without a valid registered `rendererId`, or rejected during activation, are omitted
* and logged.
*
* Register once at app start; renderers are held for the life of the process, so they must not
* capture an `Activity` or a `View`. Cards talk back to Brand Concierge with [sendDataHandoff]
* and [updateXDMContext].
*
* @throws IllegalArgumentException if [rendererId] is blank.
*/
@JvmStatic
fun registerCardRenderer(rendererId: String, renderer: ConciergeCardRenderer) {
ConciergeCardRenderers.register(rendererId, renderer)
}

/**
* Applies an RFC 7396 JSON Merge Patch to XDM context included in every conversational turn.
*
Expand Down
Loading
Loading