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 e8c5f4022..9432c4af8 100644 --- a/src-ui/src/app/components/chat/chat/chat.component.html +++ b/src-ui/src/app/components/chat/chat/chat.component.html @@ -9,7 +9,12 @@ @for (message of messages(); track message) {
- @if (message.role === 'assistant') { + @if (message.isStreaming && !message.content) { +
+
+ Thinking... +
+ } @else if (message.role === 'assistant') {
@if (message.isStreaming) { | } } @else { 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 67d8459ac..a9b76011e 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 @@ -80,8 +80,15 @@ describe('ChatComponent', () => { expect(component.messages()[0].content).toBe('Hello') expect(component.loading()).toBe(true) + fixture.detectChanges() + const messagesEl = fixture.nativeElement.querySelector('.chat-messages') + expect(messagesEl.querySelector('.spinner-border')).not.toBeNull() + expect(messagesEl.textContent).toContain('Thinking...') + mockStream$.next('Hi') expect(component.messages()[1].content).toBe('H') + fixture.detectChanges() + expect(messagesEl.querySelector('.spinner-border')).toBeNull() mockStream$.next('Hi there') // advance time to process the typewriter effect await jest.runAllTimersAsync()