Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 8 additions & 2 deletions Documentation/style-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,9 @@ Taps are tracked as link clicks with origin `privacyNotice`.
| `behavior.citations.linkIconStyle.size` | number | `16` | Inline link icon size, in dp. |
| `behavior.citations.linkIconStyle.spacing` | number | `2` | Gap between link text and its icon, in dp. |
| `behavior.citations.linkIconStyle.color` | string | `--message-concierge-link-color`, else `--color-text` | Inline link icon tint color (hex). |
| `behavior.citations.showCitationNumbers` | boolean | `true` | When `false`, hides the inline citation number badges in AI message text. The "Sources" footer below the message still appears. |

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 testapp themes (code/testapp/src/main/assets/themeDefault.json and themeDemo.json) don't include showCitationNumbers under behavior.citations. The iOS PR added it to theme-all-properties.json. could we add it here too for discoverability?


**SDK upgrade compatibility:** Adding `showCitationNumbers` to the public `ConciergeCitationsBehavior` data class changes its constructor and generated `copy` signatures. Kotlin source callers can continue using the default parameter, but consumers compiled against the previous SDK must be recompiled against the updated version.

`phoneIcon`/`storeIcon`/`defaultLinkIcon`/`linkIconStyle` only affect links rendered inline within AI message text. The citation list icon (in the expanded sources accordion) is a fixed 14dp size tinted with the citation URL color, and always uses the built-in pop-out icon — only `showLinkIcon` applies to it.

Expand Down Expand Up @@ -473,7 +476,8 @@ Taps are tracked as link clicks with origin `privacyNotice`.
"alwaysDisplay": false
},
"citations": {
"showLinkIcon": true
"showLinkIcon": true,
"showCitationNumbers": true
},
"welcomeCard": {
"closeButtonAlignment": "start",
Expand Down Expand Up @@ -1124,7 +1128,8 @@ Non-CSS `components.feedback` overrides for the feedback dialog.
"alwaysDisplay": false
},
"citations": {
"showLinkIcon": false
"showLinkIcon": false,
"showCitationNumbers": true
},
"welcomeCard": {
"closeButtonAlignment": "start",
Expand Down Expand Up @@ -1530,6 +1535,7 @@ This section documents which properties are fully implemented, partially impleme
| `behavior.citations.storeIcon` | ✅ | Icon for inline links with `kind: "store"` | `LinkHintUiUtils` |
| `behavior.citations.defaultLinkIcon` | ✅ | Icon for inline links with any other/unmatched `kind` | `LinkHintUiUtils` |
| `behavior.citations.linkIconStyle` | ✅ | Size/spacing/color for inline link icons | `ConciergeResponse` |
| `behavior.citations.showCitationNumbers` | ✅ | Inline citation number badges in AI message text; Sources footer unaffected | `ConciergeResponse` |

### Arrays

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import com.adobe.marketing.mobile.concierge.ui.state.ChatMessage
import com.adobe.marketing.mobile.concierge.ui.state.FeedbackEvent
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.ConciergeCitationsBehavior
import com.adobe.marketing.mobile.concierge.ui.theme.ConciergeThemeBehavior
import com.adobe.marketing.mobile.concierge.ui.theme.ConciergeStyles
import com.adobe.marketing.mobile.concierge.ui.theme.ConciergeTheme
import com.adobe.marketing.mobile.concierge.ui.theme.ConciergeTextStrings
Expand Down Expand Up @@ -201,6 +203,83 @@ class ChatMessageItemTest {
.assertIsDisplayed()
}

@Test
fun chatMessageItem_citationNumbersDisabled_hidesBadgesButKeepsSources() {
setCitationMessageContent(ConciergeCitationsBehavior(showCitationNumbers = false))

composeTestRule.onNodeWithText("1", useUnmergedTree = true).assertDoesNotExist()
composeTestRule.onNodeWithText("2", useUnmergedTree = true).assertDoesNotExist()
assertSourcesCanBeExpanded()
}

@Test
fun chatMessageItem_citationNumbersEnabled_showsBadgesAndSources() {
setCitationMessageContent(ConciergeCitationsBehavior(showCitationNumbers = true))

assertCitationBadgesAreDisplayed()
assertSourcesCanBeExpanded()
}

@Test
fun chatMessageItem_citationNumbersDefault_showsBadgesAndSources() {
setCitationMessageContent(ConciergeCitationsBehavior())

assertCitationBadgesAreDisplayed()
assertSourcesCanBeExpanded()
}

private fun setCitationMessageContent(citationsBehavior: ConciergeCitationsBehavior) {
val text = "First fact. Second fact."
val citations = listOf(
Citation(
url = "https://example.com/first",
title = "First source",
startIndex = 0,
endIndex = 11,
citationNumber = 1
),
Citation(
url = "https://example.com/second",
title = "Second source",
startIndex = 12,
endIndex = text.length,
citationNumber = 2
)
)
val message = ChatMessage(
content = MessageContent.Text(text),
isFromUser = false,
timestamp = 0L,
citations = citations,
uniqueCitations = citations,
interactionId = "citation-toggle-test"
)
val theme = ConciergeThemeData(
config = ConciergeThemeConfig(),
tokens = ConciergeThemeTokens(
behavior = ConciergeThemeBehavior(citations = citationsBehavior)
)
)

composeTestRule.setContent {
ConciergeTheme(theme = theme) {
ChatMessageItem(message = message)
}
}
composeTestRule.waitForIdle()
}

private fun assertCitationBadgesAreDisplayed() {
composeTestRule.onNodeWithText("1", useUnmergedTree = true).assertIsDisplayed()
composeTestRule.onNodeWithText("2", useUnmergedTree = true).assertIsDisplayed()
}

private fun assertSourcesCanBeExpanded() {
composeTestRule.onNodeWithText("Sources").assertIsDisplayed().performClick()
composeTestRule.onNodeWithText("First source", substring = true).assertIsDisplayed()
composeTestRule.onNodeWithText("Second source", substring = true).assertIsDisplayed()
}

@Test
fun chatMessageItem_triggersOnFeedbackCallback() {
var feedbackReceived: FeedbackEvent? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,14 @@ internal fun ConciergeResponse(
targetState = text.isEmpty(),
animationSpec = tween(durationMillis = 200)
) { isEmpty ->
// Apply citation annotations to the complete text first
val annotatedText = remember(text, sources) {
CitationAnnotator.annotateText(text.trimEnd(), sources)
val citationsBehavior = ConciergeTheme.tokens?.behavior?.citations ?: ConciergeCitationsBehavior()

// Apply citation annotations to the complete text first.
// When behavior.citations.showCitationNumbers is false, skip annotation so no inline
// citation number badges render; the Sources footer is driven separately by ChatFooter.
val annotatedText = remember(text, sources, citationsBehavior.showCitationNumbers) {
val effectiveSources = if (citationsBehavior.showCitationNumbers) sources else emptyList()

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 new tests only cover parsing, so reverting this line wouldn't fail anything. Could we add a small Compose UI test (e.g. alongside the existing ChatMessageItemTest) that sets showCitationNumbers = false with non-empty sources and asserts no citation badges render while the Sources footer is still shown?

CitationAnnotator.annotateText(text.trimEnd(), effectiveSources)
}

// Create inline content maps once for all child components to share
Expand All @@ -78,8 +83,6 @@ internal fun ConciergeResponse(
handleLink
)
}
val citationsBehavior = ConciergeTheme.tokens?.behavior?.citations ?: ConciergeCitationsBehavior()

// Compute style values from linkIconStyle, falling back to theme link color then onSurface
val iconStyle = citationsBehavior.linkIconStyle
val iconSize = iconStyle?.size?.dp ?: 16.dp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,9 @@ data class ConciergeCitationsBehavior(
val phoneIcon: String? = null,
val storeIcon: String? = null,
val defaultLinkIcon: String? = null,
val linkIconStyle: ConciergeLinkIconStyle? = null
val linkIconStyle: ConciergeLinkIconStyle? = null,
/** Whether inline citation number badges are rendered in the message text. The "Sources" footer is unaffected. */
val showCitationNumbers: Boolean = 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.

nit: ConciergeCitationsBehavior is a public data class, so adding a constructor param changes the constructor/copy signatures. This is source compatible for Kotlin callers but not binary compatible for anything compiled against the previous version. It follows the same pattern as linkIconStyle, so not blocking, just worth noting in the release notes.

)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,8 @@ internal object ThemeParser {
phoneIcon = DataReader.optString(it, "phoneIcon", null),
storeIcon = DataReader.optString(it, "storeIcon", null),
defaultLinkIcon = DataReader.optString(it, "defaultLinkIcon", null),
linkIconStyle = linkIconStyle
linkIconStyle = linkIconStyle,
showCitationNumbers = DataReader.optBoolean(it, "showCitationNumbers", true)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,44 @@ class ThemeParserTest {
assertEquals(1000, tokens?.behavior?.typingIndicatorDelay)
}

@Test
fun `parseThemeTokens parses citations behavior showCitationNumbers`() {
val json = """
{
"behavior": {
"citations": {
"showLinkIcon": true,
"showCitationNumbers": false
}
}
}
""".trimIndent()

val tokens = ThemeParser.parseThemeTokens(json)
val citations = tokens?.behavior?.citations

assertNotNull(citations)
assertEquals(true, citations?.showLinkIcon)
assertEquals(false, citations?.showCitationNumbers)
}

@Test
fun `parseThemeTokens defaults citations showCitationNumbers to true when key is missing`() {
val json = """
{
"behavior": {
"citations": {
"showLinkIcon": true
}
}
}
""".trimIndent()

val tokens = ThemeParser.parseThemeTokens(json)

assertEquals(true, tokens?.behavior?.citations?.showCitationNumbers)
}

@Test
fun `parseThemeTokens parses feedback behavior showCloseButton and showCancelButton`() {
val json = """
Expand Down
3 changes: 2 additions & 1 deletion code/testapp/src/main/assets/themeDefault.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"thumbsPlacement": "inline"
},
"citations": {
"showLinkIcon": false
"showLinkIcon": false,
"showCitationNumbers": true
},
"welcomeCard": {
"contentAlignment": "center"
Expand Down
3 changes: 2 additions & 1 deletion code/testapp/src/main/assets/themeDemo.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"thumbsPlacement": "below"
},
"citations": {
"showLinkIcon": true
"showLinkIcon": true,
"showCitationNumbers": true
},
"welcomeCard": {
"closeButtonAlignment": "start",
Expand Down
Loading