mirror of https://github.com/buster-so/buster.git
chat layout update
This commit is contained in:
parent
f3dcba3c86
commit
905e70e3c5
|
@ -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">
|
||||
|
|
|
@ -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(() => {
|
||||
|
|
|
@ -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>
|
||||
);
|
||||
|
||||
|
|
|
@ -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;
|
|
@ -0,0 +1 @@
|
|||
export * from './ChatLayout';
|
Loading…
Reference in New Issue