chat layout update

This commit is contained in:
Nate Kelley 2025-03-05 17:05:34 -07:00
parent f3dcba3c86
commit 905e70e3c5
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
5 changed files with 17 additions and 18 deletions

View File

@ -5,12 +5,11 @@ import { useChatIndividualContextSelector } from '../../ChatContext';
import { ChatMessageBlock } from './ChatMessageBlock';
import { ChatInput } from './ChatInput';
const autoClass = 'mx-auto max-w-[600px] w-full';
export const ChatContent: React.FC<{ chatContentRef: React.RefObject<HTMLDivElement> }> =
React.memo(({ chatContentRef }) => {
const chatMessageIds = useChatIndividualContextSelector((state) => state.chatMessageIds);
// const chatMessages = useBusterChatContextSelector((state) => state.chatsMessages);
const autoClass = 'mx-auto max-w-[600px] w-full';
return (
<div className="flex h-full w-full flex-col overflow-hidden">

View File

@ -11,7 +11,7 @@ const autoResizeConfig = { minRows: 3, maxRows: 16 };
export const ChatInput: React.FC<{}> = React.memo(({}) => {
const textAreaRef = useRef<HTMLTextAreaElement>(null);
const loading = useChatIndividualContextSelector((x) => x.isLoading);
const loading = useChatIndividualContextSelector((x) => x.isStreamingMessage);
const [inputValue, setInputValue] = useState('');
const disableSubmit = useMemo(() => {

View File

@ -6,8 +6,8 @@ import {
} from '@fluentui/react-context-selector';
import type { SelectedFile } from '../interfaces';
import { useAutoChangeLayout } from './useAutoChangeLayout';
import { useMessageIndividual } from '@/context/Chats';
import { useGetChat } from '@/api/buster_rest/chats';
import { useMessageIndividual } from '@/context/Chats';
export const useChatIndividualContext = ({
chatId,
@ -23,7 +23,6 @@ export const useChatIndividualContext = ({
//CHAT
const { data: chat } = useGetChat({ id: chatId || '' });
const hasChat = !!chatId && !!chat;
const chatTitle = chat?.title;
const chatMessageIds = chat?.message_ids ?? [];
@ -33,7 +32,7 @@ export const useChatIndividualContext = ({
//MESSAGES
const currentMessageId = chatMessageIds[chatMessageIds.length - 1];
const isLoading = useMessageIndividual(currentMessageId, (x) => !x?.isCompletedStream);
const isStreamingMessage = useMessageIndividual(currentMessageId, (x) => !x?.isCompletedStream);
useAutoChangeLayout({
lastMessageId: currentMessageId,
@ -50,23 +49,23 @@ export const useChatIndividualContext = ({
selectedFileType,
chatMessageIds,
chatId,
isLoading
isStreamingMessage
}),
[
hasChat,
hasFile,
isStreamingMessage,
selectedFileId,
currentMessageId,
chatTitle,
selectedFileType,
chatMessageIds,
chatId,
isLoading
chatId
]
);
};
export const IndividualChatContext = createContext<ReturnType<typeof useChatIndividualContext>>(
const IndividualChatContext = createContext<ReturnType<typeof useChatIndividualContext>>(
{} as ReturnType<typeof useChatIndividualContext>
);

View File

@ -2,13 +2,13 @@
import React, { useRef } from 'react';
import { AppSplitter, AppSplitterRef } from '@/components/ui/layouts/AppSplitter';
import { ChatContainer } from './ChatContainer';
import { FileContainer } from './FileContainer';
import { ChatLayoutContextProvider } from './ChatLayoutContext';
import { useChatLayout } from './ChatLayoutContext';
import { useDefaultSplitterLayout, useSelectedFileByParams } from './hooks';
import { ChatContextProvider, useChatIndividualContext } from './ChatContext/ChatContext';
import { DEFAULT_CHAT_OPTION_SIDEBAR_SIZE } from './ChatLayoutContext/config';
import { ChatContainer } from '../ChatContainer';
import { FileContainer } from '../FileContainer';
import { ChatLayoutContextProvider } from '../ChatLayoutContext';
import { useChatLayout } from '../ChatLayoutContext';
import { useDefaultSplitterLayout, useSelectedFileByParams } from '../hooks';
import { ChatContextProvider, useChatIndividualContext } from '../ChatContext/ChatContext';
import { DEFAULT_CHAT_OPTION_SIDEBAR_SIZE } from '../ChatLayoutContext/config';
export interface ChatSplitterProps {
showChatCollapse?: boolean;

View File

@ -0,0 +1 @@
export * from './ChatLayout';