Skip to content

Add message typography and inline link styling theme keys - #210

Merged
josej-ea merged 7 commits into
adobe:devfrom
josej-ea:feature/theme-message-typography
Nov 17, 2026
Merged

josej-ea merged 7 commits into
adobe:devfrom
josej-ea:feature/theme-message-typography

Conversation

@josej-ea

@josej-ea josej-ea commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds four message typography theme keys for readability and brand customization:

Key Property Default
--message-font-size typography.fontSize Material text style default
--message-font-weight typography.fontWeight Material text style default
--message-concierge-link-font-weight typography.linkFontWeight Inherits body weight; Markdown-bold links remain at least 700
--message-concierge-link-underline typography.linkUnderline true

Body size/weight apply to user and concierge message bodies and the privacy notice sharing that style. Link overrides apply to inline concierge response links, including nested lists and blockquotes, not Sources rows or other UI links. Italic links retain italics.

Review follow-up

Commit 74ae7c3 addresses the review feedback and related rendering regressions:

  • Forward link weight and underline through nested renderers.
  • Validate CSS and programmatic sizes/weights, warning and retaining defaults for invalid values; weights accept 1–1000.
  • Preserve Markdown-bold and italic link semantics.
  • Distinguish absolute --line-height-body pixel values from unitless multipliers. "24px" maps to 24sp; "1.5" scales with body size. Programmatic lineHeightPx takes precedence over lineHeight.
  • Keep explicit body line height off headings and fenced code, including nested blocks; omitted line height preserves existing response spacing.
  • Supply the resolved base font size to both paragraph and list responses for consistent Compose accessibility font scaling.
  • Add permanent parser, renderer, production UI, streaming, caching, and scaling regressions.

Accessibility

These controls do not by themselves establish WCAG compliance. Underlining helps distinguish links but does not replace text/background contrast. Normal text requires 4.5:1 for WCAG AA; the 3:1 threshold applies only to qualifying large text. Heavier weight alone does not improve the contrast ratio. Check the actual message background.

Compatibility

Omitted new message keys preserve existing defaults. Explicit body line height is now honored in assistant response paragraphs, with corrected absolute pixel handling; these are intentional fixes.

ConciergeTypography is a public Kotlin data class. Added parameters change its JVM constructor and generated copy signatures: ordinary source calls that omit the new defaulted fields continue to compile, but previously compiled applications/libraries must be recompiled. This is not binary-compatible. Details are in Documentation/release-notes.md.

The iOS counterpart is adobe/aepsdk-concierge-ios#202. This follow-up changes Android only; iOS bold-link precedence still needs separate follow-up, so platform parity is not claimed.

Validation

  • 389 focused unit tests passed.
  • 138 UI/integration tests passed across two emulator runs, covering production responses, message integration, citations, padding, privacy notice, and parser caching.
  • Permanent accessibility matrix covers 96 combinations: font scales 1.0/1.3/1.5/2.0, body sizes 12/16/20sp, paragraphs/unordered lists/ordered lists/blockquotes, and absolute/multiplier line heights, compared with Material text layout.
  • Streaming matrix covers partial Markdown, CRLF, nested/specialized blocks, light/dark palettes, text/spans/annotations, and paragraph boundaries.
  • Regression sensitivity checks reproduced failures with fixes bypassed; restored fixes passed.
  • Kotlin formatting, editor diagnostics, and diff checks passed.
  • Android 17 emulator required a temporary external AndroidX test-tooling override; no repository dependencies were changed.
  • Full Java lint is blocked locally by the existing Java formatter/JDK 21 incompatibility. Existing JaCoCo/JDK warnings prevent a clean coverage claim. CI/Codecov results for the new commit remain to be evaluated; prior results are not evidence for this update.

Theme usage

"theme": {
  "--message-font-size": "17px",
  "--message-font-weight": "500",
  "--message-concierge-link-font-weight": "700",
  "--message-concierge-link-underline": "true",
  "--line-height-body": "1.5"
}

Values in the CSS-style theme block are strings, including "true" rather than boolean true.

Adds four theme keys so brands can tune message text for readability and
WCAG contrast compliance:

- --message-font-size -> typography.fontSize; applied via
  ConciergeStyles.withThemeTypography (previously only lineHeight was)
- --message-font-weight -> typography.fontWeight; same path
- --message-concierge-link-font-weight -> typography.linkFontWeight;
  honored by renderLink/renderBoldLink/renderItalicLink
- --message-concierge-link-underline -> typography.linkUnderline;
  TextDecoration.Underline was hardcoded in all three link renderers,
  now theme-controlled

All keys default to prior behavior (Material defaults, inherit weight,
underlined) so existing themes are unaffected.

- Tests: 2 new ThemeParserTest cases (explicit values + missing-key
  defaults); 112/112 passing
- Docs: style-guide.md property and implementation tables
TokenType.LINK -> renderLink(token, builder, colorScheme, baseTextStyle, linkColor, linkHintByHref)
TokenType.BOLD_LINK -> renderBoldLink(token, builder, colorScheme, baseTextStyle, linkColor, linkHintByHref, linkFontWeight, linkUnderline)
TokenType.ITALIC_LINK -> renderItalicLink(token, builder, colorScheme, baseTextStyle, linkColor, linkHintByHref, linkFontWeight, linkUnderline)
TokenType.LINK -> renderLink(token, builder, colorScheme, baseTextStyle, linkColor, linkHintByHref, linkFontWeight, linkUnderline)

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.

[HIGH] linkFontWeight/linkUnderline are passed to the top-level link renderers but get lost on the nested path. renderList and renderBlockquote (lines 153–154) don't take them, and renderNestedMarkdown calls renderToken again at line 521 without them, so the defaults (null / true) come back. For example, > [Store](https://store.example.com) with --message-concierge-link-underline: "false" and a custom link weight still shows an underlined, weight-400 link. iOS passes linkUnderline through its nested renderers. Could you pass both values through renderList → renderNestedMarkdown → renderToken and renderBlockquote → renderNestedMarkdown → renderToken, and add a renderer test for a link inside a blockquote and a list?

// fontFamily = typography.fontFamily?.let { FontFamily(...) },
lineHeight = typography.lineHeight?.let { (this.fontSize.value * it).sp } ?: this.lineHeight
fontSize = typography.fontSize?.sp ?: this.fontSize,
fontWeight = typography.fontWeight?.let { FontWeight(it) } ?: this.fontWeight,

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.

[HIGH] parseFontWeight accepts any whole number, but Compose's FontWeight(Int) throws IllegalArgumentException outside 1–1000. A theme value like "0" or "1001" would then crash every message bubble, since this style is used by messageBubbleStyle. The disclaimer style already guards against this with FontWeight(w.coerceIn(100, 900)) (around line 961). Could you do the same here, or better, reject out-of-range values in CSSKeyMapper so the token never holds an invalid weight?

val darkTheme = isSystemInDarkTheme()
val linkColor = ConciergeTheme.colors.messageConciergeLink ?: ConciergeTheme.colors.onSurface
val typography = ConciergeTheme.tokens?.typography
val linkFontWeight = typography?.linkFontWeight?.let { FontWeight(it) }

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.

[HIGH] Same range problem as ConciergeStyles.kt:103. This runs for every bot message, even ones with no links, so an out-of-range --message-concierge-link-font-weight crashes plain assistant text too.

)
},
"message-concierge-link-font-weight" to { cssValue, theme ->
val linkFontWeight = CSSValueConverter.parseFontWeight(cssValue)

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] parseFontWeight turns an unreadable value (e.g. "heavy") into 400 instead of null. For link weight, that 400 then overrides FontWeight.Bold on **[text](url)** links. parseFontWeightOrNull plus a 1–1000 range check here (and for message-font-weight above) would fall back to the default look and also fix the crash.

textDecoration = TextDecoration.Underline,
fontWeight = FontWeight.Bold
textDecoration = if (linkUnderline) TextDecoration.Underline else null,
fontWeight = linkFontWeight ?: FontWeight.Bold

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] With linkFontWeight ?: FontWeight.Bold, a 500 or 600 link weight makes markdown-bold links lighter than the author's bold. Would taking the heavier of the two (maxOf(linkFontWeight ?: FontWeight.Bold, FontWeight.Bold)) be closer to what's intended? Either way, it would be good to match iOS here.

// Note: Font family would require loading custom fonts, which is not implemented yet
// fontFamily = typography.fontFamily?.let { FontFamily(...) },
lineHeight = typography.lineHeight?.let { (this.fontSize.value * it).sp } ?: this.lineHeight
fontSize = typography.fontSize?.sp ?: this.fontSize,

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] parsePxValue accepts "0" and negative values, which would hide or break message text. Should this only accept values above 0 (in the mapper or here)?

val lineHeight: Double? = null
val lineHeight: Double? = null,
/** Message body font size in sp. When null, the Material default for the text style is used. */
val fontSize: Double? = 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.

[LOW] ConciergeTypography is a public data class, so adding fields changes its JVM constructor and copy signatures. Apps already compiled against the old (String, Double) constructor would hit NoSuchMethodError until they recompile. This repo already changes public theme classes this way, so it's probably fine, but worth a line in the release notes rather than calling it fully backward compatible.

- Preserve link weight and underline settings through lists,
  blockquotes, and nested Markdown.
- Validate JSON and programmatic message sizes and font weights,
  logging warnings and retaining defaults for invalid values.
- Keep Markdown-bold links at least bold and preserve italics.
- Distinguish absolute pixel line heights from unitless multipliers.
- Apply body line height without overriding headings or fenced code.
- Supply the resolved base font size to paragraph and list responses
  for consistent accessibility font scaling.
- Add renderer, validation, production UI, streaming, and caching
  regression tests.
- Document theme behavior, accessibility guidance, and the public
  typography data class's binary compatibility impact.

Validation:
- 389 focused unit tests passed.
- 138 UI and integration tests passed across two runs.
- Accessibility scaling matrix: 96 combinations passed.
- Kotlin formatting and diff checks passed.

Full Java lint and coverage verification remain limited by existing
JDK/tooling incompatibilities.
@josej-ea

Copy link
Copy Markdown
Collaborator Author

@rymorale The review follow-up is pushed in 74ae7c3 and ready for another look. It addresses nested link styling, invalid CSS/programmatic typography values, bold-link precedence, and binary compatibility documentation, plus the line-height and accessibility-scaling issues found during follow-up validation. Permanent regression coverage includes 389 focused unit tests, 138 UI/integration tests across two runs, and a 96-combination scaling matrix. The PR description now distinguishes verified results, intentional behavior fixes, and local tooling limitations. This update is Android-only; iOS parity is called out separately. Thank you for reviewing.

Compare identical two-line text in response and reference layouts.
Assert line counts and expand the accessibility matrix to cover
narrow and wide layouts without weakening spacing checks.

@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.

A few remaining items, none blocking:

[LOW] CSSValueConverter.parseLineHeight (CSSValueConverter.kt:154) is no longer used by production code now that line-height-body goes through parsePxValue. Only its own tests reference it. It still silently falls back to 1.5 on invalid input, which is the behavior this PR moves away from. Consider removing it and its tests, or delegating it to the new parsing, so it doesn't get reused by mistake.

lineHeight = typography.lineHeight?.let { (this.fontSize.value * it).sp } ?: this.lineHeight
fontSize = typography.fontSize?.sp ?: this.fontSize,
fontWeight = typography.fontWeight?.let { FontWeight(it) } ?: this.fontWeight,
lineHeight = safeLineHeight?.sp ?: this.lineHeight

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] When a theme sets only --message-font-size and no line height, the ?: this.lineHeight fallback keeps the base style's line height. For the message bubble style that's Material3 bodyLarge's fixed 24.sp. User message bubbles (ChatMessageItem, Text(style = style.textStyle)) and the privacy notice use this style directly, so larger font sizes render with overlapping lines.

I confirmed this with a probe test on an API 31 emulator. With fontSize = 32 and no line height, the resolved style was fontSize=32.sp, lineHeight=24.sp, and the baseline-to-baseline gap was 63px for an 84px font.

Bot responses aren't affected because ClickableText there gets only fontSize. Suggested fix: when typography.fontSize is set and no line height is configured, either scale the inherited line height proportionally (this.lineHeight * resolvedSize / fontSize.value) or drop it (TextUnit.Unspecified) so the font's natural metrics apply. A UI test for a user bubble with a large font size would cover it.

### Message typography

Added optional message body size/weight and inline link weight/underline theme
overrides. Defaults preserve existing behavior. Invalid CSS sizes and weights

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] "Defaults preserve existing behavior" undersells one visible change. --line-height-body previously never reached bot markdown responses, because toSpanStyle() drops lineHeight. It now does, via ParagraphStyle. Every bundled sample theme sets it (1.5–1.75), and most customer themes probably do too, so bot response spacing will change on upgrade. This matches iOS, which already applies the multiplier to agent messages, but it's worth stating explicitly as a behavior change so integrators expect it.

Log.w(LOG_TAG, "Ignoring invalid --line-height-body; expected a finite positive multiplier or pixel value.")
theme
} else {
val absolute = cssValue.trim().endsWith("px")

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] endsWith("px") and parsePxValue are case-sensitive, so "24PX" is rejected with a warning, while parseFontWeightOrNull lowercases its input. This matches existing parsePxValue behavior elsewhere, so it's fine to leave. Just flagging the inconsistency.

Delete parseLineHeight, which is no longer used in production and
silently defaults invalid values to 1.5. Remove its obsolete tests;
the active line-height parsing behavior is unchanged.
@rymorale

Copy link
Copy Markdown
Contributor

it looks like the legacy line-height parser was addressed but can you also take a look at the medium priority issue (as well as the nit if possible)?

When only a message font size is configured, scale the inherited line height
proportionally to avoid cramped message text. Also accept case-insensitive
px suffixes when parsing and classifying absolute line heights.

Add regression tests for font-size-only line-height scaling and mixed-case
pixel units, and update the style guide and release notes.
Replace the incorrect previous-multiplier expectation with explicit
checks for unspecified line height and no paragraph override.

Compare fallback dimensions and baselines against a Material text
reference while retaining multiplier and absolute-height precedence
checks.

Test-only change; no production code or dependency changes.

Validation: all 11 typography UI tests passed locally. Kotlin formatting
and instrumentation-test compilation passed.

@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.

Re-review at 43dec3a: thanks for the follow-ups. The font-size-only line-height scaling fixes the overlapping lines in user bubbles, and px is now case-insensitive, which also matches iOS. The overflow fallback to TextUnit.Unspecified is a nice improvement too.

Validation, with the PR merged onto current dev (clean merge):

  • make checkformat: pass
  • make unit-test: 1,801 tests, 0 failures
  • MessageTypographyTest and MarkdownParserComposeTest on an API 31 emulator: pass

One non-blocking edge case is inline. Approving.

val resolvedSize = themedFontSize ?: fontSize.value
val inheritedScaledLineHeight = themedFontSize?.let { size ->
if (fontSize != TextUnit.Unspecified && lineHeight != TextUnit.Unspecified && fontSize.value > 0) {
lineHeight * (size / fontSize.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, non-blocking] TextUnit.times keeps the unit type, so this only works when the inherited lineHeight is in sp. ConciergeTheme inherits the host app's MaterialTheme.typography. If a host defines bodyLarge with an em line height, that value already scales with font size, so multiplying it by the size ratio applies the scaling twice.

I checked this with a probe on an API 31 emulator: host bodyLarge = TextStyle(fontSize = 16.sp, lineHeight = 1.5.em) plus --message-font-size: 32px resolved to lineHeight = 3.0.em, giving a 96px baseline gap instead of 48px. Material's defaults use sp, so this is rare. Guarding the scaling with lineHeight.isSp (and leaving em values unchanged) would cover it.

Scale only sp values when theming message size, retaining inherited em values and explicit overrides. Add a regression layout test for the preserved line heights.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@josej-ea
josej-ea merged commit cf07643 into adobe:dev Nov 17, 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.

2 participants