mirror of https://github.com/buster-so/buster.git
fallback to view key
This commit is contained in:
parent
2ba75e242b
commit
08a1600ed2
|
@ -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
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ export const ChatLayout: React.FC<ChatSplitterProps> = 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<ChatSplitterProps> = React.memo(
|
|||
<ChatContextProvider value={useChatContextValue}>
|
||||
<AppSplitter
|
||||
ref={appSplitterRef}
|
||||
leftChildren={isPureFile ? null : <ChatContainer ref={chatContentRef} />}
|
||||
leftChildren={<ChatContainer ref={chatContentRef} />}
|
||||
rightChildren={<FileContainer children={children} />}
|
||||
autoSaveId="chat-splitter"
|
||||
defaultLayout={defaultSplitterLayout}
|
||||
rightHidden={isPureChat}
|
||||
leftHidden={isPureFile}
|
||||
rightHidden={renderViewLayoutKey === 'chat'}
|
||||
leftHidden={renderViewLayoutKey === 'file'}
|
||||
preserveSide="left"
|
||||
leftPanelMinSize={hasFile ? DEFAULT_CHAT_OPTION : undefined}
|
||||
/>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -17,7 +17,7 @@ import { BusterRoutes } from '@/routes';
|
|||
|
||||
export const DashboardContainerHeaderButtons: React.FC<FileContainerButtonsProps> = 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<FileContainerButtonsProps
|
|||
<SaveToCollectionButton />
|
||||
<ShareDashboardButton dashboardId={selectedFileId} /> <AddContentToDashboardButton />
|
||||
<ThreeDotMenu dashboardId={selectedFileId} />
|
||||
<HideButtonContainer show={isPureFile}>
|
||||
<HideButtonContainer show={renderViewLayoutKey === 'file'}>
|
||||
<CreateChatButton />
|
||||
</HideButtonContainer>
|
||||
</FileButtonContainer>
|
||||
|
|
|
@ -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(
|
||||
() =>
|
||||
|
|
|
@ -17,7 +17,7 @@ import { SelectableButton } from './SelectableButton';
|
|||
import { useMetricFetched } from '@/context/Metrics';
|
||||
|
||||
export const MetricContainerHeaderButtons: React.FC<FileContainerButtonsProps> = 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<FileContainerButtonsProps> =
|
|||
<SaveToCollectionButton metricId={metricId} />
|
||||
<SaveToDashboardButton />
|
||||
<ShareMetricButton metricId={metricId} />
|
||||
<HideButtonContainer show={isPureFile}>
|
||||
<HideButtonContainer show={renderViewLayoutKey === 'file'}>
|
||||
<CreateChatButton />
|
||||
</HideButtonContainer>
|
||||
</FileButtonContainer>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
};
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue