From ef5237620be5bbf95f3591df9e68b73e5914c8ad Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sun, 27 Sep 2026 08:43:33 -0700 Subject: [PATCH] Use the markdown pipe --- .../app/components/chat/chat/chat.component.html | 8 +++++--- .../components/chat/chat/chat.component.spec.ts | 14 ++++++++++++++ .../src/app/components/chat/chat/chat.component.ts | 2 ++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src-ui/src/app/components/chat/chat/chat.component.html b/src-ui/src/app/components/chat/chat/chat.component.html index d8136fbaf..26cf0eefa 100644 --- a/src-ui/src/app/components/chat/chat/chat.component.html +++ b/src-ui/src/app/components/chat/chat/chat.component.html @@ -9,10 +9,12 @@ @for (message of messages(); track message) {
- - {{ message.content }} + @if (message.role === 'assistant') { +
@if (message.isStreaming) { | } -
+ } @else { + {{ message.content }} + } @if (message.role === 'assistant' && message.references?.length) {
@for (reference of message.references; track reference.id) { diff --git a/src-ui/src/app/components/chat/chat/chat.component.spec.ts b/src-ui/src/app/components/chat/chat/chat.component.spec.ts index 5b8e12af8..67d8459ac 100644 --- a/src-ui/src/app/components/chat/chat/chat.component.spec.ts +++ b/src-ui/src/app/components/chat/chat/chat.component.spec.ts @@ -207,4 +207,18 @@ describe('ChatComponent', () => { component.searchInputKeyDown(event) expect(component.sendMessage).not.toHaveBeenCalled() }) + + it('should render markdown for assistant messages only', () => { + component.messages.set([ + { role: 'user', content: '**user**' }, + { role: 'assistant', content: '**assistant** ' }, + ]) + fixture.detectChanges() + const el: HTMLElement = fixture.nativeElement + expect(el.querySelector('.chat-markdown strong')?.textContent).toBe( + 'assistant' + ) + expect(el.querySelector('.chat-markdown script')).toBeNull() + expect(el.textContent).toContain('**user**') + }) }) diff --git a/src-ui/src/app/components/chat/chat/chat.component.ts b/src-ui/src/app/components/chat/chat/chat.component.ts index 4525808a4..3b74a04bc 100644 --- a/src-ui/src/app/components/chat/chat/chat.component.ts +++ b/src-ui/src/app/components/chat/chat/chat.component.ts @@ -10,6 +10,7 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms' import { NavigationEnd, Router, RouterModule } from '@angular/router' import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap' import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons' +import { MarkdownPipe } from 'src/app/pipes/markdown.pipe' import { filter, map } from 'rxjs' import { ChatMessage, @@ -25,6 +26,7 @@ import { RouterModule, NgxBootstrapIconsModule, NgbDropdownModule, + MarkdownPipe, ], templateUrl: './chat.component.html', styleUrl: './chat.component.scss',