Skip to content

Commit ca27b3e

Browse files
committed
nicer spinner, use unicode dots
1 parent 146e69c commit ca27b3e

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

contesto/src/chat/chat-message.tsx

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function ChatLoadingSpinner() {
2727
// We use a span for each sequence, only one visible at a time via keyframes.
2828
// Inline style for keyframes to avoid external CSS dependencies.
2929
return (
30-
<span className='ml-2 mt-2 inline-flex h-3 select-none text-base text-muted-foreground'>
30+
<span className='mt-2 font-mono inline-flex h-3 select-none text-base text-muted-foreground flex'>
3131
<style>
3232
{`
3333
@keyframes chatDot1 {
@@ -48,23 +48,18 @@ function ChatLoadingSpinner() {
4848
`}
4949
</style>
5050
<span style={{ animation: 'chatDot1 1.2s linear infinite' }}>
51-
.
51+
5252
</span>
53-
<span
54-
style={{ animation: 'chatDot2 1.2s linear infinite' }}
55-
className='ml-0.5'
56-
>
57-
.
53+
<span style={{ animation: 'chatDot2 1.2s linear infinite' }}>
54+
5855
</span>
59-
<span
60-
style={{ animation: 'chatDot3 1.2s linear infinite' }}
61-
className='ml-0.5'
62-
>
63-
.
56+
<span style={{ animation: 'chatDot3 1.2s linear infinite' }}>
57+
6458
</span>
6559
</span>
6660
)
6761
}
62+
6863
function isMessageAlmostEmpty(message: UIMessage) {
6964
if (message.parts.length === 0) {
7065
return true
@@ -112,14 +107,13 @@ export const ChatAssistantMessage = memo(function ChatMessage({
112107
message.role === 'assistant',
113108
)
114109

115-
let content = children
116-
if (
117-
isLastAssistantMessage &&
118-
isChatGenerating &&
119-
isMessageAlmostEmpty(message)
120-
) {
121-
content = <ChatLoadingSpinner />
122-
}
110+
// if (
111+
// isLastAssistantMessage &&
112+
// isChatGenerating &&
113+
// isMessageAlmostEmpty(message)
114+
// ) {
115+
// content = <ChatLoadingSpinner />
116+
// }
123117

124118
return (
125119
<article
@@ -137,7 +131,10 @@ export const ChatAssistantMessage = memo(function ChatMessage({
137131
'space-y-4 w-full',
138132
)}
139133
>
140-
{content}
134+
{children}
135+
{isLastAssistantMessage && isChatGenerating && (
136+
<ChatLoadingSpinner />
137+
)}
141138
</div>
142139
</article>
143140
)

0 commit comments

Comments
 (0)