diff --git a/web/src/app/app/_layouts/ChatLayout/ChatContext/useFileFallback.ts b/web/src/app/app/_layouts/ChatLayout/ChatContext/useFileFallback.ts index ee2ef7141..9e9c2bda9 100644 --- a/web/src/app/app/_layouts/ChatLayout/ChatContext/useFileFallback.ts +++ b/web/src/app/app/_layouts/ChatLayout/ChatContext/useFileFallback.ts @@ -82,7 +82,8 @@ const fallbackToFileChat = ({ id }: { id: string }): IBusterChat => { created_by: '', created_by_id: '', created_by_name: '', - created_by_avatar: '' + created_by_avatar: '', + isNewChat: false }; }; diff --git a/web/src/app/app/_layouts/ChatLayout/ChatLayout.tsx b/web/src/app/app/_layouts/ChatLayout/ChatLayout.tsx index c81b75b07..ccad8f19a 100644 --- a/web/src/app/app/_layouts/ChatLayout/ChatLayout.tsx +++ b/web/src/app/app/_layouts/ChatLayout/ChatLayout.tsx @@ -32,7 +32,7 @@ export const ChatLayout: React.FC = React.memo( chatId, defaultSelectedFile }); - const { isPureChat, isPureFile, onSetSelectedFile } = useChatLayoutProps; + const { renderViewLayoutKey, onSetSelectedFile } = useChatLayoutProps; const useChatContextValue = useChatIndividualContext({ chatId, @@ -47,12 +47,12 @@ export const ChatLayout: React.FC = React.memo( } + leftChildren={} rightChildren={} autoSaveId="chat-splitter" defaultLayout={defaultSplitterLayout} - rightHidden={isPureChat} - leftHidden={isPureFile} + rightHidden={renderViewLayoutKey === 'chat'} + leftHidden={renderViewLayoutKey === 'file'} preserveSide="left" leftPanelMinSize={hasFile ? DEFAULT_CHAT_OPTION : undefined} /> diff --git a/web/src/app/app/_layouts/ChatLayout/ChatLayoutContext/ChatLayoutContext.tsx b/web/src/app/app/_layouts/ChatLayout/ChatLayoutContext/ChatLayoutContext.tsx index b2dcd59ac..e6cdacf26 100644 --- a/web/src/app/app/_layouts/ChatLayout/ChatLayoutContext/ChatLayoutContext.tsx +++ b/web/src/app/app/_layouts/ChatLayout/ChatLayoutContext/ChatLayoutContext.tsx @@ -40,8 +40,7 @@ export const useChatLayout = ({ } else if (side === 'both') { //&& (isSideClosed('right') || isSideClosed('left')) animateWidth(DEFAULT_CHAT_OPTION, 'left'); - setIsPureChat(false); - setIsPureFile(false); + setRenderViewLayoutKey('both'); fileLayoutContext?.closeSecondaryView(); } } @@ -57,6 +56,7 @@ export const useChatLayout = ({ : createFileRoute({ assetId: fileId, type: fileType }); if (route) { + setRenderViewLayoutKey('both'); onChangePage(route); startTransition(() => { animateOpenSplitter('both'); @@ -77,16 +77,14 @@ export const useChatLayout = ({ animateOpenSplitter(!isCloseAction && defaultSelectedFile ? 'both' : 'right'); } else { // For other layouts, toggle between 'right' and 'both' - animateOpenSplitter(!isCloseAction ? 'right' : 'both'); + animateOpenSplitter(isCloseAction ? 'left' : 'both'); } }); const { - setIsPureChat, setIsCollapseOpen, - isPureFile, - isPureChat, - setIsPureFile, + setRenderViewLayoutKey, + renderViewLayoutKey, collapseDirection, isCollapseOpen } = useInitialChatLayout({ @@ -103,10 +101,9 @@ export const useChatLayout = ({ return { ...fileLayoutContext, + renderViewLayoutKey, collapseDirection, isCollapseOpen, - isPureFile, - isPureChat, onSetSelectedFile, onCollapseFileClick, animateOpenSplitter diff --git a/web/src/app/app/_layouts/ChatLayout/FileContainer/FileContainerHeader/DashboardContainerHeaderButtons.tsx b/web/src/app/app/_layouts/ChatLayout/FileContainer/FileContainerHeader/DashboardContainerHeaderButtons.tsx index 0f705ec12..3e068048a 100644 --- a/web/src/app/app/_layouts/ChatLayout/FileContainer/FileContainerHeader/DashboardContainerHeaderButtons.tsx +++ b/web/src/app/app/_layouts/ChatLayout/FileContainer/FileContainerHeader/DashboardContainerHeaderButtons.tsx @@ -17,7 +17,7 @@ import { BusterRoutes } from '@/routes'; export const DashboardContainerHeaderButtons: React.FC = React.memo( () => { - const isPureFile = useChatLayoutContextSelector((x) => x.isPureFile); + const renderViewLayoutKey = useChatLayoutContextSelector((x) => x.renderViewLayoutKey); const selectedFileId = useChatIndividualContextSelector((x) => x.selectedFileId)!; return ( @@ -25,7 +25,7 @@ export const DashboardContainerHeaderButtons: React.FC - + diff --git a/web/src/app/app/_layouts/ChatLayout/FileContainer/FileContainerHeader/FileContainerHeader.tsx b/web/src/app/app/_layouts/ChatLayout/FileContainer/FileContainerHeader/FileContainerHeader.tsx index ef7378bdd..f6da56908 100644 --- a/web/src/app/app/_layouts/ChatLayout/FileContainer/FileContainerHeader/FileContainerHeader.tsx +++ b/web/src/app/app/_layouts/ChatLayout/FileContainer/FileContainerHeader/FileContainerHeader.tsx @@ -26,9 +26,9 @@ export const FileContainerHeader: React.FC = React.memo(() => { const onCollapseFileClick = useChatLayoutContextSelector((state) => state.onCollapseFileClick); const collapseDirection = useChatLayoutContextSelector((state) => state.collapseDirection); const isCollapseOpen = useChatLayoutContextSelector((state) => state.isCollapseOpen); - const isPureFile = useChatLayoutContextSelector((state) => state.isPureFile); + const renderViewLayoutKey = useChatLayoutContextSelector((state) => state.renderViewLayoutKey); - const showCollapseButton = !isPureFile; + const showCollapseButton = renderViewLayoutKey !== 'isPureFile'; const SelectedFileSegment = React.useMemo( () => diff --git a/web/src/app/app/_layouts/ChatLayout/FileContainer/FileContainerHeader/MetricContainerHeaderButtons.tsx b/web/src/app/app/_layouts/ChatLayout/FileContainer/FileContainerHeader/MetricContainerHeaderButtons.tsx index 228cb401c..96a937ade 100644 --- a/web/src/app/app/_layouts/ChatLayout/FileContainer/FileContainerHeader/MetricContainerHeaderButtons.tsx +++ b/web/src/app/app/_layouts/ChatLayout/FileContainer/FileContainerHeader/MetricContainerHeaderButtons.tsx @@ -17,7 +17,7 @@ import { SelectableButton } from './SelectableButton'; import { useMetricFetched } from '@/context/Metrics'; export const MetricContainerHeaderButtons: React.FC = React.memo(() => { - const isPureFile = useChatLayoutContextSelector((x) => x.isPureFile); + const renderViewLayoutKey = useChatLayoutContextSelector((x) => x.renderViewLayoutKey); const selectedFileId = useChatIndividualContextSelector((x) => x.selectedFileId)!; const metricId = selectedFileId; const { fetched } = useMetricFetched({ metricId }); @@ -31,7 +31,7 @@ export const MetricContainerHeaderButtons: React.FC = - + diff --git a/web/src/app/app/_layouts/ChatLayout/hooks/useInitialChatLayout.tsx b/web/src/app/app/_layouts/ChatLayout/hooks/useInitialChatLayout.tsx index 54675054b..17f1494b3 100644 --- a/web/src/app/app/_layouts/ChatLayout/hooks/useInitialChatLayout.tsx +++ b/web/src/app/app/_layouts/ChatLayout/hooks/useInitialChatLayout.tsx @@ -16,11 +16,10 @@ export const useInitialChatLayout = ({ }) => { const getChatMemoized = useBusterChatContextSelector((x) => x.getChatMemoized); const isReasoningFile = defaultSelectedFile?.type === 'reasoning'; - const [isPureFile, setIsPureFile] = useState(defaultSelectedLayout === 'file'); - const [isPureChat, setIsPureChat] = useState(defaultSelectedLayout === 'chat'); - const [isCollapseOpen, setIsCollapseOpen] = useState( - isPureChat || isReasoningFile ? true : false + const [renderViewLayoutKey, setRenderViewLayoutKey] = useState<'chat' | 'file' | 'both'>( + defaultSelectedLayout || 'chat' ); + const [isCollapseOpen, setIsCollapseOpen] = useState(isReasoningFile ? true : false); const collapseDirection: 'left' | 'right' = useMemo(() => { if (defaultSelectedFile?.type === 'reasoning') return 'right'; @@ -30,12 +29,10 @@ export const useInitialChatLayout = ({ const resetChatForNewChat = useMemoizedFn(() => { onCollapseFileClick(true); - setIsPureChat(true); }); useUpdateLayoutEffect(() => { - if (isPureFile === true) setIsPureFile(defaultSelectedLayout === 'file'); - if (isPureChat === true) setIsPureChat(defaultSelectedLayout === 'chat'); + if (defaultSelectedLayout === 'both') setRenderViewLayoutKey('both'); }, [defaultSelectedLayout]); useUpdateEffect(() => { @@ -44,17 +41,15 @@ export const useInitialChatLayout = ({ } }, [chatId]); - // useEffect(() => { - // if (isReasoningFile) { - // setIsCollapseOpen(false); - // } - // }, [isReasoningFile]); + useEffect(() => { + if (isReasoningFile && !isCollapseOpen) { + setIsCollapseOpen(true); + } + }, [isReasoningFile]); return { - isPureFile, - isPureChat, - setIsPureChat, - setIsPureFile, + renderViewLayoutKey, + setRenderViewLayoutKey, collapseDirection, setIsCollapseOpen, isCollapseOpen diff --git a/web/src/context/Chats/ChatProvider/helpers/useFileFallback.ts b/web/src/context/Chats/ChatProvider/helpers/useFileFallback.ts index 8824e672c..34b63bf95 100644 --- a/web/src/context/Chats/ChatProvider/helpers/useFileFallback.ts +++ b/web/src/context/Chats/ChatProvider/helpers/useFileFallback.ts @@ -69,7 +69,8 @@ const fallbackToFileChat = ({ id }: { id: string }): IBusterChat => { created_by: '', created_by_id: '', created_by_name: '', - created_by_avatar: '' + created_by_avatar: '', + isNewChat: false }; };