Skip to content

Add support for displaying a bundled or remote icon next to agent responses#95

Open
rymorale wants to merge 9 commits intodevfrom
brand-icon-with-agent-messages
Open

Add support for displaying a bundled or remote icon next to agent responses#95
rymorale wants to merge 9 commits intodevfrom
brand-icon-with-agent-messages

Conversation

@rymorale
Copy link
Copy Markdown
Contributor

@rymorale rymorale commented Apr 7, 2026

Description

Adds support for displaying a company brand icon next to agent text message bubbles. The icon is configurable via assets.icons.company in the theme JSON and accepts either a remote URL or a local asset name resolved from the app's assets/icons/ folder (supports .png, .webp, .jpg, .jpeg).

When a non-empty icon is configured, agent text responses render with a circular icon to the left of the message card, with start padding removed from the card so text aligns flush with the gap. The no-icon layout is unchanged.

The icon is only shown on text responses — multimodal/product card messages are not affected.

New file:

  • LocalAssetImage.kt — composable that routes to the existing AsyncImage for remote URLs, or loads raster images from assets/icons/ via BitmapFactory

Modified file:

  • ChatMessageItem.kt — adds RenderTextMessageWithIcon for the icon layout; guards icon path with takeIf { it.isNotEmpty() } to handle themes that set company to an empty string

Related Issue

Motivation and Context

How Has This Been Tested?

  • Tested manually in the test app using the Demo Theme configuration, which sets assets.icons.company to local sold colored png. It was also tested with a remote CDN URL.
  • Tested with the Default Theme configuration, which sets assets.icons.company to an empty string — no icon is shown and the message layout is visually identical to upstream
  • Verified multimodal/product card messages are unaffected in both theme configurations

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 added 3 commits April 7, 2026 10:02
Add LocalAssetImage composable to load images from either remote URLs or the app's assets/icons folder (tries .png, .webp, .jpg, .jpeg). Update ChatMessageItem to render a circular company icon for non-user messages (39dp) when ConciergeTheme provides an asset, spacing the icon 12dp from the message. Refactor message rendering into a new TextMessageCard composable to handle layout and padding differences when an icon is present. Also add a sample logo.png to testapp assets.
Rework ChatMessageItem layout to standardize bot message rendering. Treat company icon as present only if non-empty and route those cases to a new RenderTextMessageWithIcon that places the icon left of the message card. Extract shared parts into AgentResponseContent (markdown + citations/footer) and BotMessageSuffix (prompt suggestions + CTA) and use them for both text and mixed messages. Also unify card padding/alignment and preserve user-message alignment/appearance.
@rymorale rymorale requested a review from timkimadobe April 7, 2026 18:44
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.Top
) {
LocalAssetImage(
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.

Could we use a fixed size parent here so that the image loading in doesnt cause shifting?

* Renders nothing if the remote request fails or no matching local file is found.
*/
@Composable
internal fun LocalAssetImage(
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.

is there any way to cache the resource (ex: remember or CompositionLocal) so multiple agent chat icons can reuse?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

its now cached in-memory via a hash map to prevent multiple asset loads / fetches

contentDescription = null,
modifier = Modifier
.padding(top = style.padding)
.size(39.dp)
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.

should we preemptively allow for theme customization of this value?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, we could make this customizable

.size(39.dp)
.clip(CircleShape)
)
Spacer(modifier = Modifier.width(12.dp))
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.

should we preemptively allow for theme customization of this value too?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this one too

rymorale added 4 commits April 8, 2026 11:12
Changes include: adding companyIconSize and companyIconSpacing to ConciergeLayout tokens and themeDemo.json, mapping CSS keys in CSSKeyMapper, exposing defaults in ConciergeStyles (39dp / 12dp), and introducing a simple bitmap cache in LocalAssetImage to avoid repeated asset decoding. Documentation (style-guide.md) updated to reflect the new properties.
Copy link
Copy Markdown
Contributor

@timkimadobe timkimadobe left a comment

Choose a reason for hiding this comment

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

Suggestion about naming for new styling properties, otherwise looks great thanks Ryan!

| `--message-border-radius` | `cssLayout.messageBorderRadius` | `Double` | `10.0` | Message bubble corner radius (dp) |
| `--message-padding` | `cssLayout.messagePadding` | `List<Double>` | `[8, 16]` | Message content padding (dp) |
| `--message-max-width` | `cssLayout.messageMaxWidth` | `Double?` | `null` | Max message width (dp or %) |
| `--company-icon-size` | `cssLayout.companyIconSize` | `Double?` | `39.0` | Size (dp) of the company icon shown to the left of agent text messages |
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.

what do you think of the naming scheme:
--agent-icon-size
--agent-icon-spacing
?

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