Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 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 element types with your own Compose cards
- [Style Guide](style-guide.md) - Complete reference for theming and customization options
59 changes: 59 additions & 0 deletions Documentation/implementation-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,65 @@ app owns any failure UI based on the completion result.

---

## Native card renderers (preview)

Register a Compose renderer for a response element `type`. When an element in
`multimodalElements.elements` has that type, the chat renders your card inline in the transcript,
after its assistant turn completes. Without a matching renderer, elements keep their existing
built-in rendering when parsing succeeds, including unknown types and untyped elements.
`ctaButton` elements use CTA parsing; all other types use the existing card parser.
If native activation rejects an element, it uses its parsed built-in representation when available. Elements that
cannot be parsed for built-in rendering and have no accepted native renderer are omitted.
Type matching is exact and case-sensitive. Registering a built-in type overrides its 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 type wins.
Concierge.registerCardRenderer("customCard") { element, context, saveState ->
CustomCard(element, context, saveState)
}
```

- **`element`**: the complete, deeply read-only element dictionary, including null values.
Custom payload schemas are not validated: `entity_info` may be null or absent, and the
renderer must handle it safely. Elements are copied with depth-64 and 100,000-node limits;
invalid or over-limit elements are rejected and logged before rendering.
- **`context`**: updated when card state or busy/stale flags change. `cardId`; `sessionId`, `conversationId`,
`interactionId` (each may be absent); `isBusy` (a chat or handoff turn is in progress);
`isStale` (the identity was reset); `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 trigger built-in fallback or 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`. Rules that span cards, such as allowing actions only on the newest
card of a given type, belong to the app: coordinate them in app-owned state keyed by `cardId`, and put only
business facts Brand Concierge needs in `updateXDMContext`. 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
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,22 @@ object Concierge {
ConciergeAuthTokenHolder.setProvider(provider, timeoutMillis)
}

/**
* Renders response elements whose `type` exactly matches [type] with [renderer], inline in the
* transcript. Registering a type again replaces its renderer for cards activated afterwards.
* Unregistered types keep their built-in rendering.
*
* 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 [type] is blank.
*/
@JvmStatic
fun registerCardRenderer(type: String, renderer: ConciergeCardRenderer) {
ConciergeCardRenderers.register(type, renderer)
}

/**
* Applies an RFC 7396 JSON Merge Patch to XDM context included in every conversational turn.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* 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

import androidx.compose.runtime.Composable

/**
* Renders one transcript card for a response element whose `type` was registered with
* [Concierge.registerCardRenderer].
*
* - `element`: the complete, read-only element dictionary from `multimodalElements.elements`.
* - `context`: read-only card context, rebuilt on every recomposition: `cardId`, `sessionId`,
* `conversationId`, `interactionId` (each may be absent), `isBusy`, `isStale`, and `state`
* (this card's last saved state, if any).
* - `saveState`: replaces this card's private state. Callable from any thread; applied on the main
* thread. Never sent to Brand Concierge.
*
* Renderers must not throw, and must not start work during composition.
*/
typealias ConciergeCardRenderer = @Composable (
element: Map<String, Any?>,
context: Map<String, Any?>,
saveState: (Map<String, Any?>) -> Unit
) -> Unit
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* 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.cards

import java.math.BigDecimal
import java.math.BigInteger
import java.util.Collections

/**
* JSON value model for response elements, renderer actions, and action results:
* `String`, `Boolean`, finite `Number`, `null`, `List`, and string-keyed `Map`.
*/
internal object CardJson {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am wondering if it is safe to replace  CardJson  with a small  toJsonSafe()  extension something like below

/** Returns a deep copy of this map. Throws IllegalArgumentException if it is not JSON-safe. */
internal fun Map<*, *>.toJsonSafe(depth: Int = 0): Map<String, Any?> {
    require(depth < MAX_DEPTH) { "Value is nested deeper than $MAX_DEPTH levels" }
    return entries.associate { (key, value) ->
        require(key is String) { "Map keys must be strings" }
        key to value.toJsonValue(depth + 1)
    }
}
private fun Any?.toJsonValue(depth: Int): Any? = when (this) {
    null, is String, is Boolean -> this
    is Number -> also { require(toDouble().isFinite()) { "Numbers must be finite" } }
    is Map<*, *> -> toJsonSafe(depth)
    is List<*> -> {
        require(depth < MAX_DEPTH) { "Value is nested deeper than $MAX_DEPTH levels" }
        map { it.toJsonValue(depth + 1) }
    }
    else -> throw IllegalArgumentException("Unsupported type: ${this::class.simpleName}")
}

private const val MAX_DEPTH = 64
private const val MAX_NODES = 100_000

private class CopyBudget(var remaining: Int = MAX_NODES) {
fun consume(path: String) {
require(remaining > 0) { "$path exceeds the $MAX_NODES value limit" }
remaining--
}
}

/**
* Returns a deep, read-only copy of [value], preserving nulls and number types.
*
* @throws IllegalArgumentException naming the path of the first unsupported value.
*/
fun readOnlyCopy(value: Map<*, *>): Map<String, Any?> = copyObject(value, "$", 0, CopyBudget())

private fun copyObject(value: Map<*, *>, path: String, depth: Int, budget: CopyBudget): Map<String, Any?> {
require(depth < MAX_DEPTH) { "$path nests deeper than $MAX_DEPTH levels" }
budget.consume(path)
require(value.size <= budget.remaining) { "$path exceeds the $MAX_NODES value limit" }
val copy = LinkedHashMap<String, Any?>(value.size)
for ((key, entry) in value) {
require(key is String) { "$path has a non-string key" }
copy[key] = copyValue(entry, "$path.$key", depth + 1, budget)
}
return Collections.unmodifiableMap(copy)
}

private fun copyValue(value: Any?, path: String, depth: Int, budget: CopyBudget): Any? = when (value) {
is Map<*, *> -> copyObject(value, path, depth, budget)
is List<*> -> {
require(depth < MAX_DEPTH) { "$path nests deeper than $MAX_DEPTH levels" }
budget.consume(path)
require(value.size <= budget.remaining) { "$path exceeds the $MAX_NODES value limit" }
Collections.unmodifiableList(value.mapIndexed { index, item -> copyValue(item, "$path[$index]", depth + 1, budget) })
}
null, is String, is Boolean -> value.also { budget.consume(path) }
is Double, is Float -> value.also {
require((value as Number).toDouble().isFinite()) { "$path is not a finite number" }
budget.consume(path)
}
is Int, is Long, is Short, is Byte, is BigDecimal, is BigInteger -> value.also { budget.consume(path) }
else -> throw IllegalArgumentException("$path has an unsupported ${value.javaClass.simpleName} value")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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.cards

import com.adobe.marketing.mobile.concierge.ConciergeCardRenderer
import java.util.concurrent.ConcurrentHashMap

/** Process-wide card renderers by exact element `type`; the last registration wins. */
internal object ConciergeCardRenderers {
private val renderers = ConcurrentHashMap<String, ConciergeCardRenderer>()

fun register(type: String, renderer: ConciergeCardRenderer) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we also need a way to un-register the renderer?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this can be added as an enhancement for later.

require(type.isNotBlank()) { "Card renderer type must not be blank." }
renderers[type] = renderer
}

fun rendererFor(type: String?): ConciergeCardRenderer? = type?.let(renderers::get)

val hasAnyRenderer: Boolean
get() = renderers.isNotEmpty()

internal fun clear() = renderers.clear()
}
Loading
Loading