From f9401c6becfc65cf35ac700f27845579f994a7a5 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Wed, 5 Mar 2025 22:30:11 -0700 Subject: [PATCH] update reasoning controller --- .../(chat_experience)/chats/[chatId]/page.tsx | 6 +-- .../AppChatMessageContainer.tsx | 19 ------- .../messages/AppChatMessageContainer/index.ts | 2 - .../AppChatMessageContainer/interfaces.ts | 50 ------------------- .../BusterAppLayout/AppLayoutProvider.tsx | 44 ++++++++++++---- .../Chats/NewChatProvider/NewChatProvider.tsx | 2 - .../ReasoningController.tsx | 9 +--- .../ChatLayout/ChatLayout/ChatLayout.tsx | 4 +- .../useSelectedFileAndLayout.ts | 2 +- 9 files changed, 38 insertions(+), 100 deletions(-) delete mode 100644 web/src/components/ui/messages/AppChatMessageContainer/AppChatMessageContainer.tsx delete mode 100644 web/src/components/ui/messages/AppChatMessageContainer/index.ts delete mode 100644 web/src/components/ui/messages/AppChatMessageContainer/interfaces.ts diff --git a/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/page.tsx b/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/page.tsx index 9a304d6b2..7413a769f 100644 --- a/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/page.tsx +++ b/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/page.tsx @@ -1,9 +1,5 @@ 'use client'; -import { useParams } from 'next/navigation'; - export default function Page() { - const params = useParams(); - console.log(params); - return <>why? just why?; //we need this page to be able to load the chat page + return <>If you are seeing this there is probably an error; //we need this page to be able to load the chat page } diff --git a/web/src/components/ui/messages/AppChatMessageContainer/AppChatMessageContainer.tsx b/web/src/components/ui/messages/AppChatMessageContainer/AppChatMessageContainer.tsx deleted file mode 100644 index d386c15cb..000000000 --- a/web/src/components/ui/messages/AppChatMessageContainer/AppChatMessageContainer.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import React from 'react'; -import type { AppChatMessage, AppChatMessageFileType } from './interfaces'; - -interface AppChatMessageContainerProps { - message: AppChatMessage[]; - isStreaming?: boolean; - className?: string; - inputPlaceholder?: string; - onSendMessage: (message: string) => Promise; - onEditMessage: (id: string, messageText: string) => Promise; - onFileClick: (file: { type: AppChatMessageFileType; id: string }) => void; - onPillClick: (pill: { id: string; type: AppChatMessageFileType }) => void; -} - -export const AppChatMessageContainer: React.FC = React.memo(() => { - return
HERE
; -}); - -AppChatMessageContainer.displayName = 'AppChatMessageContainer'; diff --git a/web/src/components/ui/messages/AppChatMessageContainer/index.ts b/web/src/components/ui/messages/AppChatMessageContainer/index.ts deleted file mode 100644 index 93166451e..000000000 --- a/web/src/components/ui/messages/AppChatMessageContainer/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './AppChatMessageContainer'; -export * from './interfaces'; diff --git a/web/src/components/ui/messages/AppChatMessageContainer/interfaces.ts b/web/src/components/ui/messages/AppChatMessageContainer/interfaces.ts deleted file mode 100644 index 4a723f4d4..000000000 --- a/web/src/components/ui/messages/AppChatMessageContainer/interfaces.ts +++ /dev/null @@ -1,50 +0,0 @@ -export type AppChatMessage = { - id: string; - sentMessage: AppChatSentMessage; - responseMessage: AppChatResponseMessage; -}; - -export type AppChatSentMessage = { - name: string; - avatar?: string; - text: string; -}; - -export type AppChatResponseMessage = ( - | AppChatMessageMarkdown - | AppChatMessageThought - | AppChatMessageFile -) & { - hidden?: boolean; -}; - -export type AppChatMessageMarkdown = string; - -export type AppChatMessageThought = { - text: string; - type: 'dataset' | 'terms' | 'values'; - timestamp?: number; - pills?: { - text: string; - id: string; - }[]; -}; - -export enum AppChatMessageFileType { - Dataset = 'dataset', - Collection = 'collection', - Metric = 'metric', - Dashboard = 'dashboard' -} - -export type AppChatMessageFile = { - type: AppChatMessageFileType; - id: string; - name: string; - version: string; - metadata: { - status: 'loading' | 'completed' | 'failed'; - message: string; - timestamp?: number; - }[]; -}; diff --git a/web/src/context/BusterAppLayout/AppLayoutProvider.tsx b/web/src/context/BusterAppLayout/AppLayoutProvider.tsx index 91e104583..de39701e4 100644 --- a/web/src/context/BusterAppLayout/AppLayoutProvider.tsx +++ b/web/src/context/BusterAppLayout/AppLayoutProvider.tsx @@ -4,7 +4,7 @@ import { BusterRoutesWithArgsRoute, createBusterRoute } from '@/routes/busterRou import { pathNameToRoute } from '@/routes/helpers'; import { useMemoizedFn, usePrevious } from 'ahooks'; import { useRouter, usePathname, useSelectedLayoutSegment, useParams } from 'next/navigation'; -import React, { PropsWithChildren } from 'react'; +import React, { PropsWithChildren, useLayoutEffect, useRef } from 'react'; import { createContext, ContextSelector, @@ -18,7 +18,6 @@ export const useAppLayout = () => { const currentSegment = useSelectedLayoutSegment(); const currentRoute = pathNameToRoute(pathname, params); const previousRoute = usePrevious(currentRoute); - const previousPath = usePrevious(pathname); const [openInviteModal, setOpenInviteModal] = React.useState(false); const [openSupportModal, setOpenSupportModal] = React.useState(false); @@ -34,14 +33,40 @@ export const useAppLayout = () => { return createBusterRoute(params); }); - const onChangePage = useMemoizedFn((params: BusterRoutesWithArgsRoute | string) => { - console.log('onChangePage', params); - if (typeof params === 'string') { - push(params); - } else { - push(createBusterRoute(params)); + const onChangePage = useMemoizedFn( + (params: BusterRoutesWithArgsRoute | string): Promise => { + return new Promise((resolve) => { + const targetPath = typeof params === 'string' ? params : createBusterRoute(params); + const currentPath = window.location.pathname; + + // If we're already on the target path, resolve immediately + if (currentPath === targetPath) { + resolve(); + return; + } + + // Set up an effect to watch for pathname changes + const checkPathChange = (waitTime: number = 25, iteration: number = 0) => { + if (window.location.pathname !== currentPath) { + resolve(); + } else if (iteration >= 10) { + // Resolve after 10 attempts to prevent infinite loops + resolve(); + } else { + // Check again in a short while if the path hasn't changed yet + const newWaitTime = waitTime * 1.25; + setTimeout(() => checkPathChange(newWaitTime, iteration + 1), newWaitTime); + } + }; + + // Start the navigation + push(targetPath); + + // Start checking for path changes + checkPathChange(); + }); } - }); + ); return { createPageLink, @@ -51,7 +76,6 @@ export const useAppLayout = () => { openInviteModal, onChangePage, pathname, - previousPath, openSupportModal, previousRoute, onToggleSupportModal diff --git a/web/src/context/Chats/NewChatProvider/NewChatProvider.tsx b/web/src/context/Chats/NewChatProvider/NewChatProvider.tsx index 48cbb76ba..72864b3cf 100644 --- a/web/src/context/Chats/NewChatProvider/NewChatProvider.tsx +++ b/web/src/context/Chats/NewChatProvider/NewChatProvider.tsx @@ -51,8 +51,6 @@ export const useBusterNewChat = () => { } }); - console.log('res', res); - busterSocket.once({ route: '/chats/post:complete', callback: completeChatCallback diff --git a/web/src/controllers/ReasoningController/ReasoningController.tsx b/web/src/controllers/ReasoningController/ReasoningController.tsx index c639dab19..d2fe7a1bd 100644 --- a/web/src/controllers/ReasoningController/ReasoningController.tsx +++ b/web/src/controllers/ReasoningController/ReasoningController.tsx @@ -3,7 +3,6 @@ import React from 'react'; import { useChatIndividualContextSelector } from '@chatLayout/ChatContext'; import { useMessageIndividual } from '@/context/Chats'; -import { useWhyDidYouUpdate } from 'ahooks'; import { ReasoningMessageSelector } from './ReasoningMessages'; interface ReasoningControllerProps { @@ -17,16 +16,10 @@ export const ReasoningController: React.FC = ({ chatId const isCompletedStream = useMessageIndividual(messageId, (x) => x?.isCompletedStream); if (!hasChat || !reasoningMessageIds) - return ( - <> - Has chat? {hasChat ? 'true' : 'false'} Reasoning messages?{' '} - {reasoningMessageIds ? 'true' : 'false'} {messageId} - - ); + return <>If you are seeing this there is probably an error...; return (
-
HERE {reasoningMessageIds.length}
{reasoningMessageIds?.map((reasoningMessageId) => ( = ({ children }) => { const rightHidden = renderViewLayoutKey === 'chat'; const leftHidden = renderViewLayoutKey === 'file'; - console.log(children); - return ( = ({ children }) => { rightChildren={{children}} autoSaveId="chat-splitter" defaultLayout={defaultSplitterLayout} - rightHidden={false} + rightHidden={rightHidden} leftHidden={leftHidden} preserveSide="left" leftPanelMinSize={selectedFile ? DEFAULT_CHAT_OPTION_SIDEBAR_SIZE : undefined} diff --git a/web/src/layouts/ChatLayout/hooks/useSelectedFileAndLayout/useSelectedFileAndLayout.ts b/web/src/layouts/ChatLayout/hooks/useSelectedFileAndLayout/useSelectedFileAndLayout.ts index d92318da3..272e4ee5a 100644 --- a/web/src/layouts/ChatLayout/hooks/useSelectedFileAndLayout/useSelectedFileAndLayout.ts +++ b/web/src/layouts/ChatLayout/hooks/useSelectedFileAndLayout/useSelectedFileAndLayout.ts @@ -50,7 +50,7 @@ export const useSelectedFileAndLayout = ({ setRenderViewLayoutKey('both'); setSelectedFile(file); - onChangePage(route); + await onChangePage(route); startTransition(() => { animateOpenSplitter('both');