Repository navigation
Add showCitationNumbers theme flag to toggle inline citation badges #209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| CitationAnnotator.annotateText(text.trimEnd(), effectiveSources) | ||
| } | ||
|
|
||
| // Create inline content maps once for all child components to share | ||
|
|
@@ -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 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: |
||
| ) | ||
|
|
||
| /** | ||
|
|
||
There was a problem hiding this comment.
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.jsonandthemeDemo.json) don't includeshowCitationNumbersunderbehavior.citations. The iOS PR added it totheme-all-properties.json. could we add it here too for discoverability?