Skip to content

Conversation

@Killusions
Copy link
Member

@Killusions Killusions commented Nov 10, 2025

Merge after #1231

An ai-chat-container wrapper (model based with a nice signal-based API for streaming), based on #600 (merged), potential follow-up (tool message) is here #967.


This PR adds a model-driven AI chat UI: SiAiChatContainerComponent plus supporting models, input components, renderer enhancements, tests, docs and examples.

Key changes

  • New chat message models and union types (UserChatMessage, AiChatMessage, TemplateChatMessage, BaseChatMessage) and consolidated MessageAction/Attachment types.
  • New SiAiChatContainerComponent: signal-based API for streaming, inputs for messages/loading/sending/interrupts, UI customization (icons, colorVariant, copy/download toggles, syntaxHighlighter/latex hooks), messageSent output, focus() and scrollToBottom()/scrollToTop() helpers, per-message action caching, translation and markdown integration.
  • SiChatInputComponent refactor: model-based sending/interruptible signals, registerParent() API, OnDestroy cleanup, wiring to parent container.
  • Enhanced Markdown renderer: MarkdownRendererOptions, optional syntax highlighting (highlight.js), LaTeX support (KaTeX), copy-code and download-table buttons, and SiMarkdownRenderer inputs for these features.
  • Chat container scrolling: debounced streaming scroll behavior and public scrollTop/scrollBottom methods.
  • Tests, Playwright snapshots, docs/examples and sample components updated/added.
  • Added translation keys and devDependencies for highlight.js and KaTeX.
  • Notes: follows prior work from feat: add chat container #600, references potential "tool message" follow-up (feat: add experimental tool message #967), should be merged after feat(chat-messages): add support for syntax highlighting, copying and downloading csv to markdown renderer #1158. Reviewer comment: API surface is fairly large/complex and an alternative service-based encapsulation was suggested for consideration.

Lines changed: substantial (new components, renderer, tests, docs, examples).

@Killusions Killusions requested a review from a team as a code owner November 10, 2025 10:47
Copilot AI review requested due to automatic review settings November 10, 2025 10:47
@Killusions Killusions changed the title feat/add ai chat continer in chat messages feat: add ai chat container Nov 10, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces two new chat container components (SiChatContainerComponent and SiAiChatContainerComponent) to provide complete chat interfaces for Angular applications. The changes include consolidating chat message models into a single file, converting some inputs to models for two-way binding, and adding comprehensive test coverage for the new components.

  • Adds container components for managing chat UI layout and state
  • Consolidates MessageAction and Attachment interfaces into a unified chat-message.model.ts
  • Changes sending and interruptible inputs to models in SiChatInputComponent for bidirectional state synchronization

Reviewed Changes

Copilot reviewed 40 out of 40 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
projects/element-ng/chat-messages/chat-message.model.ts New unified model file containing all chat message types and interfaces
projects/element-ng/chat-messages/si-chat-container.component.ts New base container component with auto-scroll and layout management
projects/element-ng/chat-messages/si-ai-chat-container.component.ts New high-level AI chat container with message rendering and state management
projects/element-ng/chat-messages/si-chat-input.component.ts Converted sending and interruptible from inputs to models; added registerStates method
projects/element-ng/chat-messages/si-user-message.component.html Added null-safe checks for actions arrays
projects/element-ng/chat-messages/si-ai-message.component.html Added null-safe checks for actions arrays
projects/element-ng/chat-messages/si-chat-message.component.scss Refactored CSS to move .message-wrapper styles outside media queries
projects/element-ng/chat-messages/message-action.model.ts Removed (consolidated into chat-message.model.ts)
src/app/examples/si-chat-messages/si-chat-container.ts Example implementation of base chat container
src/app/examples/si-chat-messages/si-ai-chat-container.ts Example implementation of AI chat container
docs/patterns/ai/ai-chat.md Documentation for new chat container components

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Killusions Killusions mentioned this pull request Nov 10, 2025
1 task
@Killusions Killusions force-pushed the feat/add-ai-chat-continer-in-chat-messages branch from 6b82cff to c073e0f Compare November 10, 2025 10:58
@Killusions Killusions force-pushed the feat/add-ai-chat-continer-in-chat-messages branch from c073e0f to da3e829 Compare November 10, 2025 11:01
@github-actions
Copy link

github-actions bot commented Nov 10, 2025

@Killusions Killusions force-pushed the feat/add-ai-chat-continer-in-chat-messages branch from da3e829 to 5ac3fdd Compare November 10, 2025 13:02
@Killusions Killusions force-pushed the feat/add-ai-chat-continer-in-chat-messages branch 7 times, most recently from c23c428 to 7eb4235 Compare November 12, 2025 13:23
@kfenner
Copy link
Member

kfenner commented Nov 12, 2025

@timowolf @spike-rabbit Can you please review this?

We already merged #600 that introduces a basic chat container that does handle some scrolling and stuff.
So this PR would provide a full-blown chat interface that handles loading state handling and provides a partially model driven API.

I'm discussed this with @Killusions offline and I understand why he is doing it like this. I'm just not so happy with the "declarative" API surface we're opening up here - looks a bit complex, but I don't have a good solution other than simply not exposing this as a component and fully hide it behind a service (that would need to be developed first).

WDYT? 🤔

@Killusions Killusions force-pushed the feat/add-ai-chat-continer-in-chat-messages branch 3 times, most recently from 2e35d3e to 5d6e0ca Compare November 17, 2025 15:57
@coderabbitai
Copy link

coderabbitai bot commented Nov 17, 2025

Warning

Rate limit exceeded

@Killusions has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 27 minutes and 5 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 9ef1259 and bcea117.

⛔ Files ignored due to path filters (7)
  • package-lock.json is excluded by !**/package-lock.json
  • playwright/snapshots/static.spec.ts-snapshots/si-chat-messages--si-ai-chat-container-element-examples-chromium-dark-linux.png is excluded by !**/*.png
  • playwright/snapshots/static.spec.ts-snapshots/si-chat-messages--si-ai-chat-container-element-examples-chromium-light-linux.png is excluded by !**/*.png
  • playwright/snapshots/static.spec.ts-snapshots/si-chat-messages--si-user-message-element-examples-chromium-dark-linux.png is excluded by !**/*.png
  • playwright/snapshots/static.spec.ts-snapshots/si-chat-messages--si-user-message-element-examples-chromium-light-linux.png is excluded by !**/*.png
  • playwright/snapshots/static.spec.ts-snapshots/si-markdown-renderer--si-markdown-renderer-element-examples-chromium-dark-linux.png is excluded by !**/*.png
  • playwright/snapshots/static.spec.ts-snapshots/si-markdown-renderer--si-markdown-renderer-element-examples-chromium-light-linux.png is excluded by !**/*.png
📒 Files selected for processing (48)
  • angular.json
  • api-goldens/element-ng/chat-messages/index.api.md
  • api-goldens/element-ng/markdown-renderer/index.api.md
  • api-goldens/element-ng/translate/index.api.md
  • docs/patterns/ai/ai-chat.md
  • package.json
  • playwright/e2e/element-examples/static.spec.ts
  • playwright/snapshots/static.spec.ts-snapshots/si-chat-messages--si-ai-chat-container.yaml
  • playwright/snapshots/static.spec.ts-snapshots/si-chat-messages--si-chat-container.yaml
  • playwright/snapshots/static.spec.ts-snapshots/si-chat-messages--si-chat-input.yaml
  • playwright/snapshots/static.spec.ts-snapshots/si-chat-messages--si-user-message.yaml
  • playwright/snapshots/static.spec.ts-snapshots/si-markdown-renderer--si-markdown-renderer.yaml
  • projects/element-ng/chat-messages/chat-message.model.ts
  • projects/element-ng/chat-messages/index.ts
  • projects/element-ng/chat-messages/message-action.model.ts
  • projects/element-ng/chat-messages/si-ai-chat-container.component.html
  • projects/element-ng/chat-messages/si-ai-chat-container.component.spec.ts
  • projects/element-ng/chat-messages/si-ai-chat-container.component.ts
  • projects/element-ng/chat-messages/si-ai-message.component.spec.ts
  • projects/element-ng/chat-messages/si-ai-message.component.ts
  • projects/element-ng/chat-messages/si-attachment-list.component.spec.ts
  • projects/element-ng/chat-messages/si-attachment-list.component.ts
  • projects/element-ng/chat-messages/si-chat-container.component.scss
  • projects/element-ng/chat-messages/si-chat-container.component.ts
  • projects/element-ng/chat-messages/si-chat-input.component.spec.ts
  • projects/element-ng/chat-messages/si-chat-input.component.ts
  • projects/element-ng/chat-messages/si-chat-message.component.scss
  • projects/element-ng/chat-messages/si-chat-message.component.ts
  • projects/element-ng/chat-messages/si-user-message.component.spec.ts
  • projects/element-ng/chat-messages/si-user-message.component.ts
  • projects/element-ng/link/si-link.directive.ts
  • projects/element-ng/markdown-renderer/markdown-renderer-helpers.ts
  • projects/element-ng/markdown-renderer/markdown-renderer.ts
  • projects/element-ng/markdown-renderer/si-markdown-renderer.component.spec.ts
  • projects/element-ng/markdown-renderer/si-markdown-renderer.component.ts
  • projects/element-ng/translate/si-translatable-keys.interface.ts
  • projects/element-theme/src/styles/components/_markdown-hljs-theme.scss
  • projects/element-theme/src/styles/components/_markdown.scss
  • src/app/examples/si-chat-messages/si-ai-chat-container.html
  • src/app/examples/si-chat-messages/si-ai-chat-container.ts
  • src/app/examples/si-chat-messages/si-ai-message.ts
  • src/app/examples/si-chat-messages/si-chat-container.html
  • src/app/examples/si-chat-messages/si-chat-container.ts
  • src/app/examples/si-chat-messages/si-chat-input.html
  • src/app/examples/si-chat-messages/si-user-message.ts
  • src/app/examples/si-markdown-renderer/si-markdown-renderer.html
  • src/app/examples/si-markdown-renderer/si-markdown-renderer.ts
  • src/assets/sample-markdown.md
📝 Walkthrough

Walkthrough

Adds a new AI chat container component (SiAiChatContainerComponent) and a strongly-typed chat message model (chat-message.model.ts) consolidating message/action/attachment types. Refactors SiChatInputComponent to use signals and a registerParent(...) API and adds lifecycle cleanup. Enhances SiChatContainerComponent with debounced scrolling and public scrollToTop/scrollToBottom methods. Extends markdown renderer with MarkdownRendererOptions, optional syntax highlighting and LaTeX rendering (KaTeX), related renderer inputs, caching, and helpers. Adds translatable keys and example apps/tests/snapshots exercising the new AI chat UI and markdown features.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Input as SiChatInputComponent
    participant AIContainer as SiAiChatContainerComponent
    participant Container as SiChatContainerComponent
    participant Renderer as MarkdownRenderer

    User->>Input: types message (+attachments)
    Input->>AIContainer: emits messageSent
    AIContainer->>AIContainer: append UserChatMessage to messages
    AIContainer->>Renderer: render message content
    Renderer-->>Container: provide rendered nodes
    Container->>User: display user message

    AIContainer->>AIContainer: set loading, start AI response
    AIContainer->>Container: show loading AI message
    loop streaming chunks
        AIContainer->>AIContainer: update AiChatMessage content (Signal)
        AIContainer->>Renderer: re-render updated content
        Renderer-->>Container: update displayed AI message
        Container->>Container: debounce scrollToBottomDuringStreaming()
    end
    AIContainer->>AIContainer: set loading=false
    Container->>User: display final AI response
Loading

Suggested labels

core-team-discussion

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add ai chat container' directly and clearly describes the main change—introduction of a new AI chat container component with signal-based streaming API.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]

This comment was marked as outdated.

@Killusions Killusions force-pushed the feat/add-ai-chat-continer-in-chat-messages branch 2 times, most recently from 4691f0d to 8c3b63e Compare November 18, 2025 12:37
coderabbitai[bot]

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as outdated.

@Killusions Killusions force-pushed the feat/add-ai-chat-continer-in-chat-messages branch from 73d5744 to 9b9f9d7 Compare January 19, 2026 13:23
@github-actions
Copy link

Code Coverage

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.

3 participants