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';
|
'use client';
|
||||||
|
|
||||||
import { useParams } from 'next/navigation';
|
|
||||||
|
|
||||||
export default function Page() {
|
export default function Page() {
|
||||||
const params = useParams();
|
return <>If you are seeing this there is probably an error</>; //we need this page to be able to load the chat page
|
||||||
console.log(params);
|
|
||||||
return <>why? just why?</>; //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 { pathNameToRoute } from '@/routes/helpers';
|
||||||
import { useMemoizedFn, usePrevious } from 'ahooks';
|
import { useMemoizedFn, usePrevious } from 'ahooks';
|
||||||
import { useRouter, usePathname, useSelectedLayoutSegment, useParams } from 'next/navigation';
|
import { useRouter, usePathname, useSelectedLayoutSegment, useParams } from 'next/navigation';
|
||||||
import React, { PropsWithChildren } from 'react';
|
import React, { PropsWithChildren, useLayoutEffect, useRef } from 'react';
|
||||||
import {
|
import {
|
||||||
createContext,
|
createContext,
|
||||||
ContextSelector,
|
ContextSelector,
|
||||||
|
@ -18,7 +18,6 @@ export const useAppLayout = () => {
|
||||||
const currentSegment = useSelectedLayoutSegment();
|
const currentSegment = useSelectedLayoutSegment();
|
||||||
const currentRoute = pathNameToRoute(pathname, params);
|
const currentRoute = pathNameToRoute(pathname, params);
|
||||||
const previousRoute = usePrevious(currentRoute);
|
const previousRoute = usePrevious(currentRoute);
|
||||||
const previousPath = usePrevious(pathname);
|
|
||||||
const [openInviteModal, setOpenInviteModal] = React.useState(false);
|
const [openInviteModal, setOpenInviteModal] = React.useState(false);
|
||||||
const [openSupportModal, setOpenSupportModal] = React.useState(false);
|
const [openSupportModal, setOpenSupportModal] = React.useState(false);
|
||||||
|
|
||||||
|
@ -34,14 +33,40 @@ export const useAppLayout = () => {
|
||||||
return createBusterRoute(params);
|
return createBusterRoute(params);
|
||||||
});
|
});
|
||||||
|
|
||||||
const onChangePage = useMemoizedFn((params: BusterRoutesWithArgsRoute | string) => {
|
const onChangePage = useMemoizedFn(
|
||||||
console.log('onChangePage', params);
|
(params: BusterRoutesWithArgsRoute | string): Promise<void> => {
|
||||||
if (typeof params === 'string') {
|
return new Promise((resolve) => {
|
||||||
push(params);
|
const targetPath = typeof params === 'string' ? params : createBusterRoute(params);
|
||||||
} else {
|
const currentPath = window.location.pathname;
|
||||||
push(createBusterRoute(params));
|
|
||||||
|
// 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 {
|
return {
|
||||||
createPageLink,
|
createPageLink,
|
||||||
|
@ -51,7 +76,6 @@ export const useAppLayout = () => {
|
||||||
openInviteModal,
|
openInviteModal,
|
||||||
onChangePage,
|
onChangePage,
|
||||||
pathname,
|
pathname,
|
||||||
previousPath,
|
|
||||||
openSupportModal,
|
openSupportModal,
|
||||||
previousRoute,
|
previousRoute,
|
||||||
onToggleSupportModal
|
onToggleSupportModal
|
||||||
|
|
|
@ -51,8 +51,6 @@ export const useBusterNewChat = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('res', res);
|
|
||||||
|
|
||||||
busterSocket.once({
|
busterSocket.once({
|
||||||
route: '/chats/post:complete',
|
route: '/chats/post:complete',
|
||||||
callback: completeChatCallback
|
callback: completeChatCallback
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useChatIndividualContextSelector } from '@chatLayout/ChatContext';
|
import { useChatIndividualContextSelector } from '@chatLayout/ChatContext';
|
||||||
import { useMessageIndividual } from '@/context/Chats';
|
import { useMessageIndividual } from '@/context/Chats';
|
||||||
import { useWhyDidYouUpdate } from 'ahooks';
|
|
||||||
import { ReasoningMessageSelector } from './ReasoningMessages';
|
import { ReasoningMessageSelector } from './ReasoningMessages';
|
||||||
|
|
||||||
interface ReasoningControllerProps {
|
interface ReasoningControllerProps {
|
||||||
|
@ -17,16 +16,10 @@ export const ReasoningController: React.FC<ReasoningControllerProps> = ({ chatId
|
||||||
const isCompletedStream = useMessageIndividual(messageId, (x) => x?.isCompletedStream);
|
const isCompletedStream = useMessageIndividual(messageId, (x) => x?.isCompletedStream);
|
||||||
|
|
||||||
if (!hasChat || !reasoningMessageIds)
|
if (!hasChat || !reasoningMessageIds)
|
||||||
return (
|
return <>If you are seeing this there is probably an error...</>;
|
||||||
<>
|
|
||||||
Has chat? {hasChat ? 'true' : 'false'} Reasoning messages?{' '}
|
|
||||||
{reasoningMessageIds ? 'true' : 'false'} {messageId}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="h-full flex-col space-y-2 overflow-y-auto p-5">
|
<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) => (
|
{reasoningMessageIds?.map((reasoningMessageId) => (
|
||||||
<ReasoningMessageSelector
|
<ReasoningMessageSelector
|
||||||
key={reasoningMessageId}
|
key={reasoningMessageId}
|
||||||
|
|
|
@ -29,8 +29,6 @@ export const ChatLayout: React.FC<ChatSplitterProps> = ({ children }) => {
|
||||||
const rightHidden = renderViewLayoutKey === 'chat';
|
const rightHidden = renderViewLayoutKey === 'chat';
|
||||||
const leftHidden = renderViewLayoutKey === 'file';
|
const leftHidden = renderViewLayoutKey === 'file';
|
||||||
|
|
||||||
console.log(children);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ChatLayoutContextProvider useChatLayoutProps={useChatLayoutProps}>
|
<ChatLayoutContextProvider useChatLayoutProps={useChatLayoutProps}>
|
||||||
<ChatContextProvider
|
<ChatContextProvider
|
||||||
|
@ -43,7 +41,7 @@ export const ChatLayout: React.FC<ChatSplitterProps> = ({ children }) => {
|
||||||
rightChildren={<FileContainer>{children}</FileContainer>}
|
rightChildren={<FileContainer>{children}</FileContainer>}
|
||||||
autoSaveId="chat-splitter"
|
autoSaveId="chat-splitter"
|
||||||
defaultLayout={defaultSplitterLayout}
|
defaultLayout={defaultSplitterLayout}
|
||||||
rightHidden={false}
|
rightHidden={rightHidden}
|
||||||
leftHidden={leftHidden}
|
leftHidden={leftHidden}
|
||||||
preserveSide="left"
|
preserveSide="left"
|
||||||
leftPanelMinSize={selectedFile ? DEFAULT_CHAT_OPTION_SIDEBAR_SIZE : undefined}
|
leftPanelMinSize={selectedFile ? DEFAULT_CHAT_OPTION_SIDEBAR_SIZE : undefined}
|
||||||
|
|
|
@ -50,7 +50,7 @@ export const useSelectedFileAndLayout = ({
|
||||||
|
|
||||||
setRenderViewLayoutKey('both');
|
setRenderViewLayoutKey('both');
|
||||||
setSelectedFile(file);
|
setSelectedFile(file);
|
||||||
onChangePage(route);
|
await onChangePage(route);
|
||||||
|
|
||||||
startTransition(() => {
|
startTransition(() => {
|
||||||
animateOpenSplitter('both');
|
animateOpenSplitter('both');
|
||||||
|
|
Loading…
Reference in New Issue