mirror of https://github.com/buster-so/buster.git
update reasoning controller
This commit is contained in:
parent
b2df36b624
commit
f9401c6bec
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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<void>;
|
||||
onEditMessage: (id: string, messageText: string) => Promise<void>;
|
||||
onFileClick: (file: { type: AppChatMessageFileType; id: string }) => void;
|
||||
onPillClick: (pill: { id: string; type: AppChatMessageFileType }) => void;
|
||||
}
|
||||
|
||||
export const AppChatMessageContainer: React.FC<AppChatMessageContainerProps> = React.memo(() => {
|
||||
return <div>HERE</div>;
|
||||
});
|
||||
|
||||
AppChatMessageContainer.displayName = 'AppChatMessageContainer';
|
|
@ -1,2 +0,0 @@
|
|||
export * from './AppChatMessageContainer';
|
||||
export * from './interfaces';
|
|
@ -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;
|
||||
}[];
|
||||
};
|
|
@ -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<void> => {
|
||||
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
|
||||
|
|
|
@ -51,8 +51,6 @@ export const useBusterNewChat = () => {
|
|||
}
|
||||
});
|
||||
|
||||
console.log('res', res);
|
||||
|
||||
busterSocket.once({
|
||||
route: '/chats/post:complete',
|
||||
callback: completeChatCallback
|
||||
|
|
|
@ -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<ReasoningControllerProps> = ({ 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 (
|
||||
<div className="h-full flex-col space-y-2 overflow-y-auto p-5">
|
||||
<div className="bg-red-200">HERE {reasoningMessageIds.length}</div>
|
||||
{reasoningMessageIds?.map((reasoningMessageId) => (
|
||||
<ReasoningMessageSelector
|
||||
key={reasoningMessageId}
|
||||
|
|
|
@ -29,8 +29,6 @@ export const ChatLayout: React.FC<ChatSplitterProps> = ({ children }) => {
|
|||
const rightHidden = renderViewLayoutKey === 'chat';
|
||||
const leftHidden = renderViewLayoutKey === 'file';
|
||||
|
||||
console.log(children);
|
||||
|
||||
return (
|
||||
<ChatLayoutContextProvider useChatLayoutProps={useChatLayoutProps}>
|
||||
<ChatContextProvider
|
||||
|
@ -43,7 +41,7 @@ export const ChatLayout: React.FC<ChatSplitterProps> = ({ children }) => {
|
|||
rightChildren={<FileContainer>{children}</FileContainer>}
|
||||
autoSaveId="chat-splitter"
|
||||
defaultLayout={defaultSplitterLayout}
|
||||
rightHidden={false}
|
||||
rightHidden={rightHidden}
|
||||
leftHidden={leftHidden}
|
||||
preserveSide="left"
|
||||
leftPanelMinSize={selectedFile ? DEFAULT_CHAT_OPTION_SIDEBAR_SIZE : undefined}
|
||||
|
|
|
@ -50,7 +50,7 @@ export const useSelectedFileAndLayout = ({
|
|||
|
||||
setRenderViewLayoutKey('both');
|
||||
setSelectedFile(file);
|
||||
onChangePage(route);
|
||||
await onChangePage(route);
|
||||
|
||||
startTransition(() => {
|
||||
animateOpenSplitter('both');
|
||||
|
|
Loading…
Reference in New Issue