Skip to content

feat(chat-messages): add source chip AI pattern#2266

Open
robertwilde wants to merge 3 commits into
mainfrom
feat/ai-patterns/source-chip
Open

feat(chat-messages): add source chip AI pattern#2266
robertwilde wants to merge 3 commits into
mainfrom
feat/ai-patterns/source-chip

Conversation

@robertwilde

@robertwilde robertwilde commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Closes #2064

Add two new components for surfacing AI message source citations in the chat messages.

What

SiSourceChipInlineComponent

A compact inline pill rendered at the end of the AI message body. Shows the title of the first cited source, with a "+N" suffix when there are multiple. Opens a CDK popover listing all sources (title, excerpt, link) on click. Optionally shows a prefix icon.

SiSourceChipSummaryComponent

A summary pill for the actions row. Renders a globe icon and a translatable "Sources" label. Same popover behaviour as the inline chip. Intended to be used alongside the siAiMessageAction directive.

SiAiMessageActionDirective

A new marker directive ([siAiMessageAction]) that enables projecting arbitrary action elements into the si-ai-message actions row via contentChildren. Fixes the case where the actions bar would not render when only a source chip (and no built-in actions) was present.

SiAiMessage changes

  • New sources input (SiAiSource[]) — the inline chip is now rendered internally by si-ai-message and does not need to be projected by consumers.
  • New chipClicked output forwarded from the inline chip.
  • Actions bar visibility condition extended to account for siAiMessageAction content.

SiAiSource model

New exported interface: { title: string; excerpt: string; url: string }.

Usage

<si-ai-message [sources]="citations" (chipClicked)="onInlineClick()">
  <!-- optional summary chip in the actions row -->
  <si-source-chip-summary siAiMessageAction [sources]="citations" />
</si-ai-message>

Documentation.
Examples.
Dashboards Demo.
Playwright report.

Coverage Reports:

Code Coverage

@robertwilde robertwilde force-pushed the feat/ai-patterns/source-chip branch from 5b5ace3 to d7aa7ea Compare July 2, 2026 15:39

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces inline and summary source chips (SiSourceChipInlineComponent and SiSourceChipSummaryComponent) for AI messages, allowing citations to be displayed either inline at the end of the text or as a summary alongside action buttons. The review feedback points out two correctness issues in the DOM manipulation logic of SiAiMessageComponent: a caching bug that prevents dynamic updates of inline chips (e.g., during streaming), and a layout bug where chips are incorrectly appended if the message does not end with a paragraph element. A code suggestion is provided to resolve both issues.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread projects/element-ng/chat-messages/si-ai-message.component.ts
@robertwilde robertwilde force-pushed the feat/ai-patterns/source-chip branch 7 times, most recently from ad67a41 to 01ebb90 Compare July 6, 2026 09:39
@robertwilde robertwilde changed the title Feat/ai patterns/source chip feat(chat-messages): add source chip AI pattern Jul 6, 2026
@robertwilde robertwilde marked this pull request as ready for review July 6, 2026 12:06
@robertwilde robertwilde requested review from a team as code owners July 6, 2026 12:06
@robertwilde robertwilde force-pushed the feat/ai-patterns/source-chip branch from c9773b4 to 320192f Compare July 7, 2026 07:44

@spike-rabbit spike-rabbit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just had a discussion with @panch1739, we need a few changes here:

  • the chips should reuse the summary-chip style, so at first you need to extract the summary-chip styling into element-theme (in another PR).
  • then we need a chip-sm size which has modified paddings for inline source (in another PR)
  • the inline source and the summary source can exist at the same time
  • no need to have any logic around whether the response is currently streamed or not
  • the inline source can be at the end of any paragraph, so we can currently not integrate this into the ai-chat-message, just show how it can be used in the normal chat message. We need to think about a solution later
  • I guess splitting summary and inline sources in different PRs would be a good idea too

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.

AI patterns: Add source chip to AI chat messages

2 participants