Add blinking typing cursing (#619)
This commit is contained in:
parent
f849a2e924
commit
fa3f6e93bb
|
@ -1,5 +1,4 @@
|
||||||
import { IconRobot } from '@tabler/icons-react';
|
import { IconRobot } from '@tabler/icons-react';
|
||||||
import { IconDots } from '@tabler/icons-react';
|
|
||||||
import { FC } from 'react';
|
import { FC } from 'react';
|
||||||
|
|
||||||
interface Props { }
|
interface Props { }
|
||||||
|
@ -14,7 +13,7 @@ export const ChatLoader: FC<Props> = () => {
|
||||||
<div className="min-w-[40px] items-end">
|
<div className="min-w-[40px] items-end">
|
||||||
<IconRobot size={30} />
|
<IconRobot size={30} />
|
||||||
</div>
|
</div>
|
||||||
<IconDots className="animate-pulse" />
|
<span className="animate-pulse cursor-default mt-1">▍</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -33,7 +33,7 @@ export const ChatMessage: FC<Props> = memo(({ message, messageIndex, onEdit }) =
|
||||||
const { t } = useTranslation('chat');
|
const { t } = useTranslation('chat');
|
||||||
|
|
||||||
const {
|
const {
|
||||||
state: { selectedConversation, conversations, currentMessage },
|
state: { selectedConversation, conversations, currentMessage, messageIsStreaming },
|
||||||
dispatch: homeDispatch,
|
dispatch: homeDispatch,
|
||||||
} = useContext(HomeContext);
|
} = useContext(HomeContext);
|
||||||
|
|
||||||
|
@ -215,6 +215,14 @@ export const ChatMessage: FC<Props> = memo(({ message, messageIndex, onEdit }) =
|
||||||
rehypePlugins={[rehypeMathjax]}
|
rehypePlugins={[rehypeMathjax]}
|
||||||
components={{
|
components={{
|
||||||
code({ node, inline, className, children, ...props }) {
|
code({ node, inline, className, children, ...props }) {
|
||||||
|
if (children.length) {
|
||||||
|
if (children[0] == '▍') {
|
||||||
|
return <span className="animate-pulse cursor-default mt-1">▍</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
children[0] = (children[0] as string).replace("`▍`", "▍")
|
||||||
|
}
|
||||||
|
|
||||||
const match = /language-(\w+)/.exec(className || '');
|
const match = /language-(\w+)/.exec(className || '');
|
||||||
|
|
||||||
return !inline ? (
|
return !inline ? (
|
||||||
|
@ -253,7 +261,9 @@ export const ChatMessage: FC<Props> = memo(({ message, messageIndex, onEdit }) =
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{message.content}
|
{`${message.content}${
|
||||||
|
messageIsStreaming && messageIndex == (selectedConversation?.messages.length ?? 0) - 1 ? '`▍`' : ''
|
||||||
|
}`}
|
||||||
</MemoizedReactMarkdown>
|
</MemoizedReactMarkdown>
|
||||||
|
|
||||||
<div className="md:-mr-8 ml-1 md:ml-0 flex flex-col md:flex-row gap-4 md:gap-1 items-center md:items-start justify-end md:justify-start">
|
<div className="md:-mr-8 ml-1 md:ml-0 flex flex-col md:flex-row gap-4 md:gap-1 items-center md:items-start justify-end md:justify-start">
|
||||||
|
|
Loading…
Reference in New Issue