no duration for streaming messages

This commit is contained in:
Nate Kelley 2025-09-25 16:02:06 -06:00
parent 2705b180ac
commit 1a46465aaa
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
3 changed files with 14 additions and 7 deletions

View File

@ -15,9 +15,10 @@ export const CHAT_HEADER_TITLE_ID = 'chat-header-title';
export const ChatHeaderTitle: React.FC<{
chatTitle: string;
chatId: string;
isStreamFinished: boolean;
}> = ({ chatTitle, chatId, isStreamFinished }) => {
isStreamingMessage: boolean;
}> = ({ chatTitle, chatId, isStreamingMessage }) => {
const { mutateAsync: updateChat } = useUpdateChat();
const isStreamFinished = !isStreamingMessage;
if (!chatTitle) {
return <div />; //we need to return something for alignment
@ -26,8 +27,11 @@ export const ChatHeaderTitle: React.FC<{
return (
<AnimatePresence mode="wait" initial={isStreamFinished}>
<motion.div
{...(!isStreamFinished ? animation : {})}
{...(isStreamFinished ? {} : animation)}
key={chatTitle || 'initial'}
transition={{
duration: isStreamFinished ? 0 : 0.2,
}}
className="flex w-full items-center overflow-hidden"
>
<EditableTitle

View File

@ -22,9 +22,12 @@ export const useIsStreamingMessage = () => {
const isStreamingMessage = useQueries({
queries: stableQueries,
combine: useCallback(
(result: { data: boolean | undefined }[]) => result.some((res) => res.data === false),
[]
(result: { data: boolean | undefined }[]) => {
return result.some((res) => res.data === false);
},
[stableQueries]
),
});
return isStreamingMessage;
};

View File

@ -7,14 +7,14 @@ import { useGetChatId } from '@/context/Chats/useGetChatId';
export const ChatHeader: React.FC = React.memo(() => {
const chatId = useGetChatId();
const chatTitle = useGetActiveChatTitle();
const isStreamFinished = useIsStreamingMessage();
const isStreamingMessage = useIsStreamingMessage();
return (
<>
<ChatHeaderTitle
chatTitle={chatTitle || ''}
chatId={chatId || ''}
isStreamFinished={isStreamFinished}
isStreamingMessage={isStreamingMessage}
/>
<ChatHeaderOptions />
</>