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 { ChatMessageBlock } from './ChatMessageBlock';
|
||||||
import { ChatInput } from './ChatInput';
|
import { ChatInput } from './ChatInput';
|
||||||
|
|
||||||
|
const autoClass = 'mx-auto max-w-[600px] w-full';
|
||||||
|
|
||||||
export const ChatContent: React.FC<{ chatContentRef: React.RefObject<HTMLDivElement> }> =
|
export const ChatContent: React.FC<{ chatContentRef: React.RefObject<HTMLDivElement> }> =
|
||||||
React.memo(({ chatContentRef }) => {
|
React.memo(({ chatContentRef }) => {
|
||||||
const chatMessageIds = useChatIndividualContextSelector((state) => state.chatMessageIds);
|
const chatMessageIds = useChatIndividualContextSelector((state) => state.chatMessageIds);
|
||||||
// const chatMessages = useBusterChatContextSelector((state) => state.chatsMessages);
|
|
||||||
|
|
||||||
const autoClass = 'mx-auto max-w-[600px] w-full';
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-full w-full flex-col overflow-hidden">
|
<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(({}) => {
|
export const ChatInput: React.FC<{}> = React.memo(({}) => {
|
||||||
const textAreaRef = useRef<HTMLTextAreaElement>(null);
|
const textAreaRef = useRef<HTMLTextAreaElement>(null);
|
||||||
const loading = useChatIndividualContextSelector((x) => x.isLoading);
|
const loading = useChatIndividualContextSelector((x) => x.isStreamingMessage);
|
||||||
const [inputValue, setInputValue] = useState('');
|
const [inputValue, setInputValue] = useState('');
|
||||||
|
|
||||||
const disableSubmit = useMemo(() => {
|
const disableSubmit = useMemo(() => {
|
||||||
|
|
|
@ -6,8 +6,8 @@ import {
|
||||||
} from '@fluentui/react-context-selector';
|
} from '@fluentui/react-context-selector';
|
||||||
import type { SelectedFile } from '../interfaces';
|
import type { SelectedFile } from '../interfaces';
|
||||||
import { useAutoChangeLayout } from './useAutoChangeLayout';
|
import { useAutoChangeLayout } from './useAutoChangeLayout';
|
||||||
import { useMessageIndividual } from '@/context/Chats';
|
|
||||||
import { useGetChat } from '@/api/buster_rest/chats';
|
import { useGetChat } from '@/api/buster_rest/chats';
|
||||||
|
import { useMessageIndividual } from '@/context/Chats';
|
||||||
|
|
||||||
export const useChatIndividualContext = ({
|
export const useChatIndividualContext = ({
|
||||||
chatId,
|
chatId,
|
||||||
|
@ -23,7 +23,6 @@ export const useChatIndividualContext = ({
|
||||||
|
|
||||||
//CHAT
|
//CHAT
|
||||||
const { data: chat } = useGetChat({ id: chatId || '' });
|
const { data: chat } = useGetChat({ id: chatId || '' });
|
||||||
|
|
||||||
const hasChat = !!chatId && !!chat;
|
const hasChat = !!chatId && !!chat;
|
||||||
const chatTitle = chat?.title;
|
const chatTitle = chat?.title;
|
||||||
const chatMessageIds = chat?.message_ids ?? [];
|
const chatMessageIds = chat?.message_ids ?? [];
|
||||||
|
@ -33,7 +32,7 @@ export const useChatIndividualContext = ({
|
||||||
|
|
||||||
//MESSAGES
|
//MESSAGES
|
||||||
const currentMessageId = chatMessageIds[chatMessageIds.length - 1];
|
const currentMessageId = chatMessageIds[chatMessageIds.length - 1];
|
||||||
const isLoading = useMessageIndividual(currentMessageId, (x) => !x?.isCompletedStream);
|
const isStreamingMessage = useMessageIndividual(currentMessageId, (x) => !x?.isCompletedStream);
|
||||||
|
|
||||||
useAutoChangeLayout({
|
useAutoChangeLayout({
|
||||||
lastMessageId: currentMessageId,
|
lastMessageId: currentMessageId,
|
||||||
|
@ -50,23 +49,23 @@ export const useChatIndividualContext = ({
|
||||||
selectedFileType,
|
selectedFileType,
|
||||||
chatMessageIds,
|
chatMessageIds,
|
||||||
chatId,
|
chatId,
|
||||||
isLoading
|
isStreamingMessage
|
||||||
}),
|
}),
|
||||||
[
|
[
|
||||||
hasChat,
|
hasChat,
|
||||||
hasFile,
|
hasFile,
|
||||||
|
isStreamingMessage,
|
||||||
selectedFileId,
|
selectedFileId,
|
||||||
currentMessageId,
|
currentMessageId,
|
||||||
chatTitle,
|
chatTitle,
|
||||||
selectedFileType,
|
selectedFileType,
|
||||||
chatMessageIds,
|
chatMessageIds,
|
||||||
chatId,
|
chatId
|
||||||
isLoading
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const IndividualChatContext = createContext<ReturnType<typeof useChatIndividualContext>>(
|
const IndividualChatContext = createContext<ReturnType<typeof useChatIndividualContext>>(
|
||||||
{} as ReturnType<typeof useChatIndividualContext>
|
{} as ReturnType<typeof useChatIndividualContext>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
import React, { useRef } from 'react';
|
import React, { useRef } from 'react';
|
||||||
import { AppSplitter, AppSplitterRef } from '@/components/ui/layouts/AppSplitter';
|
import { AppSplitter, AppSplitterRef } from '@/components/ui/layouts/AppSplitter';
|
||||||
import { ChatContainer } from './ChatContainer';
|
import { ChatContainer } from '../ChatContainer';
|
||||||
import { FileContainer } from './FileContainer';
|
import { FileContainer } from '../FileContainer';
|
||||||
import { ChatLayoutContextProvider } from './ChatLayoutContext';
|
import { ChatLayoutContextProvider } from '../ChatLayoutContext';
|
||||||
import { useChatLayout } from './ChatLayoutContext';
|
import { useChatLayout } from '../ChatLayoutContext';
|
||||||
import { useDefaultSplitterLayout, useSelectedFileByParams } from './hooks';
|
import { useDefaultSplitterLayout, useSelectedFileByParams } from '../hooks';
|
||||||
import { ChatContextProvider, useChatIndividualContext } from './ChatContext/ChatContext';
|
import { ChatContextProvider, useChatIndividualContext } from '../ChatContext/ChatContext';
|
||||||
import { DEFAULT_CHAT_OPTION_SIDEBAR_SIZE } from './ChatLayoutContext/config';
|
import { DEFAULT_CHAT_OPTION_SIDEBAR_SIZE } from '../ChatLayoutContext/config';
|
||||||
|
|
||||||
export interface ChatSplitterProps {
|
export interface ChatSplitterProps {
|
||||||
showChatCollapse?: boolean;
|
showChatCollapse?: boolean;
|
|
@ -0,0 +1 @@
|
||||||
|
export * from './ChatLayout';
|
Loading…
Reference in New Issue