Skip to content

Add native card renderers for custom response element types - #196

Merged
BNanda99 merged 26 commits into
adobe:devfrom
BNanda99:feature/native-card-plugins-v1
Nov 18, 2026
Merged

BNanda99 merged 26 commits into
adobe:devfrom
BNanda99:feature/native-card-plugins-v1

Conversation

@BNanda99

@BNanda99 BNanda99 commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Description

Adds preview APIs for native Compose renderers of custom response elements.

  • Apps register Concierge.registerCardRenderer(rendererId, renderer). Only elements with type: "custom" are matched, using their element-level rendererId with exact, case-sensitive matching. OOTB types retain their built-in rendering and cannot be overridden through this API. Re-registration affects subsequently activated cards, not existing ones.
  • Custom elements are never rendered as built-in cards. A custom element is omitted with a warning when its rendererId is missing, blank, or unregistered, or when native activation rejects it (invalid or over-limit JSON, or a repeated element ID for the same renderer). If that leaves a typed chat response with no text and nothing else to show, the chat replaces its thinking placeholder with the standard error message, as iOS does; a data handoff reports EMPTY_RESPONSE and leaves the transcript unchanged.
  • Renderers receive the complete element, including opaque entity_info and optional element-level rendererContext, plus the SDK's card context and a saveState callback. The renderer owns payload validation and interactions; the SDK does not interpret event metadata or update XDM on the app's behalf.
  • Each accepted native element has its own transcript row. Native/CTA rows retain their relative order; built-in cards are grouped at the first built-in card's position, so arbitrary mixed interleaving is not preserved.
  • isLatest is scoped per rendererId; rollback promotes the latest remaining card for that renderer. Element deduplication distinguishes renderer IDs, so different renderers can use the same element ID. sequence, isBusy, session identifiers and saved state support additional host-defined interaction rules. isStale is currently always false and reserved for possible future session-expiry handling.
  • Private in-memory card state survives configuration changes that retain the chat ViewModel, not process death or a new ViewModel. Cards are disposed on turn rollback, identity reset and ViewModel teardown. Disposal discards the card's saved state (as on iOS), and later saves are ignored. A transcript row whose card is no longer live draws nothing (as on iOS); its prompt suggestions still render. Element JSON and saved state are deep-copied with depth-64 and 100,000-node limits, and invalid input is logged. saveState can be called from any thread and is applied on the main thread.
  • Handoff Delivered means nonblank response text or accepted render targets, not renderer payload validity or business success. Streamed text survives final native activation rejection with no fallback. Typed chat with neither ends with the standard error message instead of an empty thinking bubble.
  • Unrecognized ---prefixed theme keys remain available in ConciergeThemeTokens.cssVariables for custom renderers (maximum 256 keys and 512 characters per value; numbers are converted to strings). Stable ChatMessage.localId values prevent duplicate or unstable transcript keys.
  • Restores the missing lastUserIndex declaration required for compilation and includes SDK tests and documentation updates. The Kings test app is maintained separately and is not included in this PR.

Related Issue

Motivation and Context

The BCOS contract identifies each custom element with type: "custom" and its own rendererId, while leaving its entity payload and optional interaction metadata to the host renderer. This enables different custom renderers and OOTB elements in the same response without requiring the SDK to understand renderer-specific schemas. Hosts must coordinate event context across related renderers; isLatest alone does not establish that relationship.

How Has This Been Tested?

  • cd code && ./gradlew :concierge:testPhoneDebugUnitTest :concierge:compilePhoneDebugAndroidTestKotlin :concierge:spotlessCheck :concierge:checkstyle --console=plain — passed for the isStale changes: 1,859 unit tests, 0 failures; instrumented tests compiled. Gradle reused up-to-date results on the final check.
  • Earlier PR revision: cd code && ./gradlew :concierge:testDebugUnitTest :testapp:testDebugUnitTest :testapp:assembleDebug :concierge:compilePhoneDebugAndroidTestKotlin :concierge:spotlessCheck :concierge:checkstyle :testapp:lintDebug --console=plain --quiet — passed locally: 1,847 SDK and 219 test-app unit tests; Android instrumented tests compiled. The test-app checks ran against the separate Kings branch with its local integration changes, not against files included in this PR.
  • cd code && ./gradlew :concierge:lintPhoneDebug --console=plain --quiet — failed on six existing errors outside this update: a lint detector crash in ChatInputPanel.kt and five NewApi errors in AppLinkUtils.kt and ConciergeConversationServiceClient.kt.
  • The new disposed-card instrumented test did not complete locally: Espresso failed before its assertions on the available API 37 emulator (NoSuchMethodException: InputManager.getInstance). CI Functional Test uses API 29 and remains the runtime gate. The retained-card lookup test verifies instance/state reuse, not an actual Activity recreation.
  • The screenshot is from earlier manual testing. The new payload and live add-to-cart flow have not been retested end to end; the separate F&B app's cross-event and rollback event-context handling still needs follow-up.

Screenshots (if appropriate):

image

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

rymorale and others added 5 commits October 9, 2026 09:04
Dev to staging for 3.10.0 release
Dev to staging for 3.10.1 release
Staging to main for 3.10.1 release
Apps can register a Compose renderer per element type with
Concierge.registerCardRenderer. Matching elements render as their own
transcript rows with the complete element JSON, saved card state and
session/busy/stale context. Cards are disposed on rollback, transcript
clear, identity reset and view model teardown. Once any renderer is
registered, unknown element types without a renderer are hidden while
productCard, horizontalCard, ctaButton and untyped elements keep their
built-in rendering.

Also retains unrecognized --prefixed theme keys in
ConciergeThemeTokens.cssVariables for custom renderers, and keys
transcript rows by a stable localId.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@BNanda99

Copy link
Copy Markdown
Member Author

@BNanda99
BNanda99 requested a review from shushinde October 19, 2026 16:46
Biswajit Nanda and others added 6 commits October 27, 2026 10:15
…ugins-v2

# Conflicts:
#	code/concierge/src/main/kotlin/com/adobe/marketing/mobile/concierge/ui/components/messages/MessageList.kt
Dev to staging for 3.10.2 release
Staging to main for 3.10.2 release
… demo

Count accepted render targets for handoff delivery, preserve legacy unknown-type fallback and streamed text, localize unavailable content, and clarify retained-card test coverage. Add 40 isolated static renderer scenarios with regression tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@BNanda99
BNanda99 force-pushed the feature/native-card-plugins-v1 branch from 4747fed to b96888d Compare October 28, 2026 09:19
Biswajit Nanda and others added 3 commits October 28, 2026 14:52
Remove the demo screen, fixtures, tests, launcher, documentation and controller injection from tracked sources. Keep SDK behavior fixes and regression tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Document payload handling, renderer replacement, state lifetime, fallback and delivery semantics, and custom theme value rules.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@BNanda99
BNanda99 marked this pull request as ready for review October 28, 2026 15:54
@BNanda99

Copy link
Copy Markdown
Member Author

@shushinde can you please provide an initial review on this PR. Thanks!

removeLastAssistantPlaceholder()
}
appendOrderedElementMessages(parsedMessage.orderedElements, parsedMessage.promptSuggestions)
appendOrderedElementMessages(renderTargets, parsedMessage.promptSuggestions)

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.

[MEDIUM] Prompt suggestions can be dropped here. appendOrderedElementMessages only attaches promptSuggestions to the built-in card carousel or to the last native card. When the response has text and every element resolves to nothing (for example a registered element that's rejected with no built-in fallback) or only CTAs, nothing receives the suggestions. The text message above is updated with emptyList(), so the suggestions never render.

The text + CTA-only case already behaved this way, but native-card rejection makes it easier to hit. I reproduced it locally with a registered type whose payload exceeds the nesting limit: the text renders and the suggestions don't.

Suggestion: when no render target will carry the suggestions, pass them to the text message's updateAssistantMessageContent call instead of emptyList(). A test for text plus a rejected element with no fallback would cover it.

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.

When native activation rejects an element and no rendered card target can carry suggestions, they now attach to the text response. The pre-existing CTA-only behavior is unchanged. Added coverage for both cases.

val displayMode = if (cardElements.size == 1) "single" else "carousel"
val elementDicts = cardElements.map { element -> buildCardElementDict(element.content) }
if (builtInCardElements.isNotEmpty()) {
val displayMode = if (builtInCardElements.size == 1) "single" else "carousel"

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.

[LOW] CardsRendered is only dispatched for built-in cards, so native cards emit no render tracking. If that's intentional (the host owns analytics for its own cards), it would be worth documenting; otherwise native cards are invisible in rendering metrics.

}

/** Converts a value of the JSON model to org.json types (null becomes [JSONObject.NULL]). */
fun toJsonValue(value: Any?): Any = when (value) {

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.

[LOW] toJsonValue is only used from tests (ConciergeCardRenderersTest). ConciergeConversationServiceClient has its own private toJsonValue. Either reuse this one there or drop it.

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.

Removed

val parsedBuiltIn: ParsedMultimodalItem?
) {

val builtInFallback: ParsedMultimodalItem?

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.

[LOW] builtInFallback just returns parsedBuiltIn, so there are two names for the same value. Consider keeping one.

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.

Removed. using parsedBuiltIn directly.

@rymorale

rymorale commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Nice work overall. The renderer API, card lifecycle and fallback handling look solid, and the unit tests and CI pass locally. I also ran the change in a local demo with custom renderers (menu, parking, mixed, fallback, stream error and theme variables scenarios) and it behaved as described, except for the suggestions issue noted inline.

A few notes that aren't tied to a specific line:

  • Please squash-merge. Commit 429eb66f ("Initial commit: Kings specific native card plugins") adds about 13k lines of customer-specific test-app code (fnb/**, parking/ParkWhizBooking.kt) plus captured stage fixtures (tapin2_stage_*.json). A later merge removes them, so the final diff is clean, but a regular merge would keep them in dev history. If those fixtures contain anything sensitive, rebuilding the branch without that commit would be safer.
  • [LOW] ConversationResponseParserRawElementsTest.kt:71,86 uses "Book on ParkWhiz". Consider a generic label.
  • Version bump. This adds new public API (Concierge.registerCardRenderer, ConciergeCardRenderer) in a backwards-compatible way, so it should ship as a minor release. The version should be bumped to 3.11.0 in both code/gradle.properties (moduleVersion) and ConciergeConstants.VERSION. One thing to call out in the release notes: ConciergeThemeTokens gains a defaulted cssVariables parameter, which is source-compatible but changes the constructor/copy signatures for anything precompiled against the old class.

Preserve suggestions on text when native cards are rejected, document app-owned tracking, and remove redundant JSON and fallback helpers.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

@rymorale rymorale left a comment

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.

The updates look good to me.

@prudrabhat prudrabhat left a comment

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.

Sharing some thoughts on making this more compose friendly and simplifying card management. Please take a look and let me know if this fits the requirements and your long term plans.

* 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}")
}

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.

* Owns the native cards of one chat: their element, saved state, and the busy/stale flags their
* `context` reports. Main-thread confined, except [RenderableCard.saveState].
*/
internal class NativeCardController(

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.

How do you feel about dropping NativeCardController and keep card data in the message list. I feel that Following way more Compose native in my view. Here is the gist for the patch in case you want to see hte suggestion locally

  • The message list holds the card. You do not keep a second store in sync.
  • When the app removes a message (rollback, clear or error), the card is removed too. You do not need  disposeAll ,  disposeAllExcept  or an  isDisposed  flag.
  • If a card is already removed,  saveState  finds no message and does nothing.
  • The view model holds the state. The UI shows the state and sends events up.  update { copy(...) }  is atomic, so you do not need to switch to the main thread.

Primary idea:
The chat view model already owns the transcript ( _messages ). Each native card is one message in that list. I suggest that the message holds the card data. Then the controller, its maps and its flows are not needed.

  1. Card model
// ChatScreenState.kt
internal data class NativeCard(
    /** Identifies the element within its turn, e.g. `turn-3/abc`. */
    val key: String,
    val element: Map<String, Any?>,
    val identifiers: Map<String, String> = emptyMap(),
    val state: Map<String, Any?>? = null,
    val isStale: Boolean = false
) : MessageContent()

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.

  1. Build the card and skip repeats
// ConciergeChatViewModel.kt
private fun resolveElementRenderTargets(parsedMessage: ParsedConversationMessage): ElementResolution {
    if (!ConciergeCardRenderers.hasAnyRenderer || parsedMessage.rawElements.isEmpty()) {
        return ElementResolution(parsedMessage.orderedElements.map(::toBuiltInRenderTarget), false)
    }
    val seenKeys = _messages.value.mapNotNullTo(HashSet()) { (it.content as? MessageContent.NativeCard)?.key }
    var hasRejectedNativeCard = false
    val renderTargets = parsedMessage.rawElements.mapNotNull { element ->
        if (!hasRenderer(element.type)) return@mapNotNull element.parsedBuiltIn?.let(::toBuiltInRenderTarget)
        val card = try {
            toNativeCard(element)
        } catch (e: IllegalArgumentException) {
            Log.warning(ConciergeConstants.EXTENSION_NAME, TAG, "Element ${element.position} isn't valid JSON data: ${e.message}")
            hasRejectedNativeCard = true
            return@mapNotNull element.parsedBuiltIn?.let(::toBuiltInRenderTarget)
        }
        if (seenKeys.add(card.key)) ElementRenderTarget.NativeCard(card) else null
    }
    return ElementResolution(renderTargets, hasRejectedNativeCard)
}

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.

  1. Save state and mark stale
internal fun saveNativeCardState(cardKey: String, state: Map<String, Any?>) {
    val safeState = try {
        state.toJsonSafe()
    } catch (e: IllegalArgumentException) {
        Log.warning(ConciergeConstants.EXTENSION_NAME, TAG, "Ignoring saveState for card $cardKey: ${e.message}")
        return
    }
    _messages.update { messages ->
        messages.map { message ->
            val card = message.content as? MessageContent.NativeCard
            if (card?.key == cardKey) message.copy(content = card.copy(state = safeState)) else message
        }
    }
}

private fun markNativeCardsStale() = _messages.update { messages ->
    messages.map { message ->
        val card = message.content as? MessageContent.NativeCard
        if (card == null) message else message.copy(content = card.copy(isStale = true))
    }
}

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.

  1. Finally UI reads from the message and a flow for the busy state:
internal class NativeCardHost(
    val isBusy: Boolean,
    val saveState: (cardKey: String, state: Map<String, Any?>) -> Unit
)
internal val LocalNativeCardHost = compositionLocalOf<NativeCardHost?> { null }

// ConciergeChat.kt
val isBusy by viewModel.isBusy.collectAsStateWithLifecycle()
val nativeCardHost = remember(isBusy, viewModel) { NativeCardHost(isBusy, viewModel::saveNativeCardState) }
CompositionLocalProvider(LocalNativeCardHost provides nativeCardHost) { /* ... */ }

// NativeCardMessage.kt: build the context from the message
val context = remember(card, host.isBusy) {
    mutableMapOf<String, Any?>().apply {
        put("cardId", card.key)
        putAll(card.identifiers)
        put("isBusy", host.isBusy)
        put("isStale", card.isStale)
        card.state?.let { put("state", it) }
    }
}

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.

Yes this fits compose style better. But it might introduce some challenges with changing renderer selection, duplicate-card handling, cleanup and there might be some performance impact as the transcript grows. This can be discussed further with the long term plans and also the IOS equivalent for this to maintain parity.

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.

so for now, keeping these enhancements out for this initial v1 draft

@prudrabhat prudrabhat Nov 5, 2026 •

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.

  • Renderer selection can be fixed by just resolving the renderer when the card is created and store it in NativeCard
  • Duplicate cards can be avoided with if seenKeys.add fails, treat it as rejected
  • Which cleanup are you referring to? Rollback, clear and reset all go through _messages. I would say that this is where the proposal helps more. Removing a message removes its card (without the need to disposeAll, disposeAllExcept, markAllStale and a disposed flags)
  • Performance at the scale of few tens to a few hundred messages will not be a concern imo.

Anyway, if you choose to go with the suggested approach at later time, please ensure that the public api surface is tight and that it allows changing internals.

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.

Agree that renderer selection and duplicate fallback can be handled in the message-based approach and we have to verify that late saves are still ignored after ViewModel teardown, along with rollback/reset. This would need some discussion on the IOS side as well to maintain parity. I will try out these suggested changes in a parallel branch - but considering the scope of the changes I am more inclined to push these as part of a fast follow up - how does that sound?

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Hosts can't infer card order from composition: LazyColumn composes rows lazily and out of transcript order, so "newest card" rules built on LaunchedEffect order pick the wrong card.

- sequence: fixed Int per card, strictly increasing in activation (transcript) order, never reused within a chat; rejected elements don't use a number.
- isLatest: live flag, true while the card is the newest of its type in the chat; a rolled-back latest card hands it to the newest remaining card of that type.
- Renderer context, KDoc and implementation guide document both keys.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
BNanda99 pushed a commit to BNanda99/aepsdk-concierge-android that referenced this pull request Nov 6, 2026
…ngs testapp branch

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
BNanda99 pushed a commit to BNanda99/aepsdk-concierge-android that referenced this pull request Nov 6, 2026
…ngs testapp branch

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Consume the --input-box-shadow theme token, which was parsed but never
rendered, and move --multimodal-card-box-shadow onto the same
implementation.

- Add ConciergeBoxShadow (offset, blur, spread, color) and a
  Modifier.conciergeBoxShadow that draws the shadow itself on API 28+
  (BlurMaskFilter + clipOutPath) so offset, spread and low-alpha colors
  match the web. Modifier.shadow scaled the color's alpha down by the
  system shadow alpha, which made subtle shadows invisible.
- Below API 28, fall back to Modifier.shadow elevation. Offset, spread
  and color are ignored there.
- Cache the shadow path and paint in a Modifier.Node so typing in the
  input bar doesn't rebuild them on every recomposition.
- Replace ExtendedProductCardStyle.shadowElevation/shadowColor with
  boxShadow and apply it to the input panel and product cards.
- Add shadows to the debug Product Card Demo theme.
- Add unit and instrumented tests, and update the style guide Shadows
  section and support status.
Address review feedback: --multimodal-card-box-shadow was only applied to
productDetail cards (ExtendedProductCard) while the default actionButton
ProductCard kept a hardcoded 1dp elevation. iOS applies the token to both
card styles, so ProductCard now uses the same conciergeBoxShadow modifier.

- Add boxShadow to ConciergeStyles.ProductCardStyle, resolved from the
  multimodalCardBoxShadow token via ConciergeBoxShadow.fromTokens.
- Apply conciergeBoxShadow in ProductCard; keep the 1dp elevation only as a
  fallback when no shadow token is configured (no change to default appearance).
- Add parity instrumented tests: shadow renders beyond the card bounds when
  the token is set, and no custom shadow when it is not.
- Add Robolectric SDK-gated unit tests and an instrumented recomposition test
  covering the below-API-28 elevation fallback and the draw-node update path
  flagged by Codecov.
- Update the style guide to note the card shadow applies to both the
  actionButton ProductCard and the productDetail ExtendedProductCard.
[MAR-2699] Render CSS box-shadow for input bar and product cards
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@BNanda99

Copy link
Copy Markdown
Member Author

Hey @rymorale requesting another round of review after few more changes to the BC response schema.

} else {
null
}
val parsedBuiltIn: ParsedMultimodalItem? = if (elementType == ELEMENT_TYPE_CUSTOM && rendererId == null) {

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.

Only custom elements without a rendererId skip built-in parsing. A custom element with a rendererId falls through to parseMultimodalElement(elementMap) (L215), which only needs an id and reads productName/productImageURL/primary etc. from entity_info. That gives it a ParsedMultimodalItem.Card, so it renders as a built-in product card (and fires CardsRendered analytics) whenever:

  • no renderer is registered at all (!hasAnyRenderer / legacy Mixed path),
  • its rendererId isn't registered, or
  • native activation rejects it (invalid JSON, over limits, duplicate id for the same renderer).

Per the decision record, for type: "custom" entity_info is an opaque renderer-owned payload that only the identified renderer interprets. For example, the spec's own {"type":"custom","rendererId":"catalogRenderer","entity_info":{"productName":"Veggie Nachos"}} would show as an OOTB product card on a client without that renderer, and a seatMapRenderer payload would show as an empty product card in the carousel.

Suggestion: never produce a built-in representation for custom elements, e.g.

val parsedBuiltIn: ParsedMultimodalItem? = if (elementType == ELEMENT_TYPE_CUSTOM) {
    if (rendererId == null) {
        Log.warning(ConciergeConstants.EXTENSION_NAME, TAG, "Dropping custom element ${i + 1}: missing rendererId.")
    }
    null
} else if (elementType == ELEMENT_TYPE_CTA_BUTTON) {

and log when a custom element's rendererId has no registered renderer at resolution time. The unregistered renderer ids remain on built-in rendering test and related parser/VM tests would need updating too.

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.

Yes makes sense. I had kept the builtin fallback to match the existing behaviour but with custom renderer that does not make sense. Made the required changes !

is NativeCardController.ActivationResult.Activated -> ElementRenderTarget.NativeCard(activation.cardId)
// Already in the transcript from an earlier pass over this same response.
is NativeCardController.ActivationResult.AlreadyActive -> null
NativeCardController.ActivationResult.Rejected -> {

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.

Related to the parser comment: for a custom element, a rejected activation (and the unregistered-rendererId / !hasAnyRenderer paths above) falls back to element.parsedBuiltIn, which renders the renderer-owned payload as a built-in card. If the parser stops producing parsedBuiltIn for custom elements, these paths will omit them instead, matching the existing "no accepted native renderer and no built-in representation → omitted" rule.

Comment thread Documentation/implementation-guide.md Outdated

Only `custom` elements are matched; other element types always keep their built-in rendering, even
if their `type` equals a registered id. A `custom` element without a `rendererId` is not rendered
and a warning is logged. A `custom` element whose `rendererId` isn't registered keeps the existing

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.

This documents the built-in fallback for custom elements with an unregistered rendererId, which conflicts with the decision record (entity_info is opaque and renderer-owned for type: "custom"). Suggest stating that unregistered or rejected custom elements are not rendered and a warning is logged, consistent with the missing-rendererId case.

Custom entity_info is opaque, so custom elements never fall back to
built-in card rendering. Missing, blank, or unregistered rendererIds and
rejected activations are omitted and logged.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
// Native cards are activated here, once the turn has completed.
val resolution = resolveElementRenderTargets(parsedMessage)
val renderTargets = resolution.renderTargets
if (renderTargets.isEmpty() && parsedMessage.messageContent.isBlank()) {

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.

If a typed-chat response has a blank message and only custom elements that get omitted (e.g. a rendererId only iOS registers), the empty placeholder is left in the transcript. Since isThinking is true for any empty assistant text message, the thinking dots stay on screen forever, and the response's prompt suggestions are lost. On dev this element rendered as a built-in card, so this is new for these payloads.

Could we remove the placeholder in this case (or keep a message with the prompt suggestions if there are any) and add a typed-chat test for it?

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.

A typed turn with nothing renderable now shows the standard error message with the response's prompt suggestions, matching iOS.

is ParsedMultimodalItem.Cta -> {
val ctaMessage = ChatMessage(
content = MessageContent.CtaButton(element.button),
val promptSuggestionsNativeCardIndex = if (builtInCardElements.isEmpty()) renderTargets.indexOfLast { it is ElementRenderTarget.NativeCard } else -1

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.

Related: with a blank message and [custom (unregistered), ctaButton], only the CTA remains, and prompt suggestions are dropped since they only attach to card messages. Could they fall back to the last CTA row?

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.

Suggestions now attach to the card carousel, else the last native card, else the last CTA, else the text, so they're never dropped. CTA rows render them. Added tests for this case and for text with CTAs only.

- Typed chat with nothing renderable now replaces the thinking
  placeholder with the standard error message (carrying the response's
  prompt suggestions), matching iOS. Handoffs still report EMPTY_RESPONSE.
- ChatMessage.isThinking requires an open stream, so a completed empty
  message never keeps animating.
- A row whose native card is no longer live draws nothing (as on iOS)
  and keeps its suggestions; remove the unavailable-card placeholder.
- Disposing a native card discards its saved state, per the spec.
- Prompt suggestions are never dropped: carousel, else last native card,
  else last CTA, else response text. CTA rows render attached suggestions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
currentMessages.take(turnStartIndex) + assistantMessage
}
disposeRemovedNativeCards()
handleConversationError(

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.

This fallback is skipped if the connection drops after COMPLETED. The catch block below (~L1535) returns Delivered whenever hasCompleted is true, without checking hasVisibleContent. So a blank COMPLETED with only unsupported custom elements, followed by an IOException on teardown, leaves an empty bubble with no error text and no suggestions. Could that check be hasCompleted && hasVisibleContent, so this path falls through to the empty/error handling?

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.

Fixed. A teardown failure after COMPLETED now ends the turn through the same handling as a cleanly closed stream: a delivered answer is kept, and an empty response shows the standard error with its suggestions.

Biswajit Nanda and others added 2 commits November 17, 2026 11:07
A transport failure after a typed chat COMPLETED response always reported
Delivered, so a blank response with only unsupported custom elements left
an empty bubble with no error text or suggestions. Both a clean stream end
and a teardown failure after COMPLETED now end the turn through shared
handling: delivered answers are kept, and empty responses show the
standard error with the response's prompt suggestions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@BNanda99

Copy link
Copy Markdown
Member Author

@rymorale updated the PR with changes. could you please do another round of review. Thanks!

@rymorale rymorale left a comment

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.

Thanks for the latest updates. The PR looks good to me.

@BNanda99
BNanda99 merged commit 84318e3 into adobe:dev Nov 18, 2026
11 checks passed
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.

3 participants