From 9a4d32ce7a0cfa9ce23556206ba8aaeb6db9e68a Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Sat, 29 Mar 2025 22:01:07 -0600 Subject: [PATCH] make secondary for sql not appear --- .../ChatHeader/ChatHeaderTitle.tsx | 4 +-- .../useLayoutConfig/interfaces.ts | 1 - .../useLayoutConfig/useLayoutConfig.ts | 27 ++++++++++++------- .../MetricContainerHeaderSegment.tsx | 3 +-- .../secondaryPanelsConfig/allConfigs.tsx | 7 ++++- .../secondaryPanelsConfig/metricPanels.tsx | 4 +++ 6 files changed, 30 insertions(+), 16 deletions(-) diff --git a/web/src/layouts/ChatLayout/ChatContainer/ChatHeader/ChatHeaderTitle.tsx b/web/src/layouts/ChatLayout/ChatContainer/ChatHeader/ChatHeaderTitle.tsx index 3c9252434..dfbb2c823 100644 --- a/web/src/layouts/ChatLayout/ChatContainer/ChatHeader/ChatHeaderTitle.tsx +++ b/web/src/layouts/ChatLayout/ChatContainer/ChatHeader/ChatHeaderTitle.tsx @@ -18,7 +18,7 @@ export const ChatHeaderTitle: React.FC<{ chatTitle: string; chatId: string; isCompletedStream: boolean; -}> = React.memo(({ chatTitle, chatId }) => { +}> = React.memo(({ chatTitle, chatId, isCompletedStream }) => { const { mutateAsync: updateChat } = useUpdateChat(); if (!chatTitle) return
; @@ -26,7 +26,7 @@ export const ChatHeaderTitle: React.FC<{ return ( >; diff --git a/web/src/layouts/ChatLayout/ChatLayoutContext/useLayoutConfig/useLayoutConfig.ts b/web/src/layouts/ChatLayout/ChatLayoutContext/useLayoutConfig/useLayoutConfig.ts index bf0cdc54a..3ea97ddd2 100644 --- a/web/src/layouts/ChatLayout/ChatLayoutContext/useLayoutConfig/useLayoutConfig.ts +++ b/web/src/layouts/ChatLayout/ChatLayoutContext/useLayoutConfig/useLayoutConfig.ts @@ -10,6 +10,7 @@ import type { SelectedFile } from '../../interfaces'; import { timeout } from '@/lib'; import { useRouter } from 'next/navigation'; import { BusterRoutes, createBusterRoute } from '@/routes'; +import { SelectedFileSecondaryRenderRecord } from '../../FileContainer/FileContainerSecondary/secondaryPanelsConfig'; export const useLayoutConfig = ({ selectedFile, @@ -48,24 +49,31 @@ export const useLayoutConfig = ({ }, [selectedFileViewConfig, selectedFileId, selectedFileView]); const selectedFileViewRenderSecondary: boolean = useMemo(() => { - if (!selectedFileId || !selectedFileViewConfig || !selectedFileView) return false; - if (selectedFileViewConfig?.[selectedFileView]?.secondaryView) { - return selectedFileViewConfig?.[selectedFileView]?.renderView !== false; + if (!selectedFileViewSecondary || !selectedFileType) return false; + if ( + selectedFileType in SelectedFileSecondaryRenderRecord && + SelectedFileSecondaryRenderRecord[selectedFileType as FileType]?.[ + selectedFileViewSecondary + ] !== undefined + ) { + return ( + SelectedFileSecondaryRenderRecord[selectedFileType as FileType]?.[ + selectedFileViewSecondary + ] ?? false + ); } - return false; - }, [selectedFileViewConfig]); + return true; + }, [selectedFileViewConfig, selectedFileId, selectedFileView, selectedFileType]); const onSetFileView = useMemoizedFn( async ({ fileView, fileId: fileIdProp, - secondaryView, - renderView + secondaryView }: { fileView?: FileView; fileId?: string | undefined; secondaryView?: FileViewSecondary; - renderView?: boolean; }) => { const fileId = fileIdProp ?? selectedFileId; if (!fileId) return; @@ -102,8 +110,7 @@ export const useLayoutConfig = ({ draft[fileId].fileViewConfig[usedFileView] = { ...(draft[fileId].fileViewConfig[usedFileView] || {}), - secondaryView, - renderView + secondaryView }; } }); diff --git a/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/MetricContainerHeaderSegment.tsx b/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/MetricContainerHeaderSegment.tsx index 44d4224d4..201b6f82f 100644 --- a/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/MetricContainerHeaderSegment.tsx +++ b/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/MetricContainerHeaderSegment.tsx @@ -17,8 +17,7 @@ export const MetricContainerHeaderSegment: React.FC = const onSetFileView = useChatLayoutContextSelector((x) => x.onSetFileView); const onChange = useMemoizedFn((fileView: SegmentedItem) => { - const renderView = fileView.value === 'results' ? false : true; - onSetFileView({ fileView: fileView.value, renderView }); + onSetFileView({ fileView: fileView.value }); }); return ( diff --git a/web/src/layouts/ChatLayout/FileContainer/FileContainerSecondary/secondaryPanelsConfig/allConfigs.tsx b/web/src/layouts/ChatLayout/FileContainer/FileContainerSecondary/secondaryPanelsConfig/allConfigs.tsx index 0c0c43fa9..09b5d3881 100644 --- a/web/src/layouts/ChatLayout/FileContainer/FileContainerSecondary/secondaryPanelsConfig/allConfigs.tsx +++ b/web/src/layouts/ChatLayout/FileContainer/FileContainerSecondary/secondaryPanelsConfig/allConfigs.tsx @@ -1,7 +1,7 @@ import type { FileType } from '@/api/asset_interfaces/chat'; import type { FileContainerSecondaryProps } from '../interfaces'; import React from 'react'; -import { MetricSecondaryRecord } from './metricPanels'; +import { MetricSecondaryRecord, MetrucSecondaryRenderRecord } from './metricPanels'; import { DashboardSecondaryRecord } from './dashboardPanels'; export const SelectedFileSecondaryRecord: Record< @@ -12,3 +12,8 @@ export const SelectedFileSecondaryRecord: Record< dashboard: DashboardSecondaryRecord, reasoning: {} }; + +export const SelectedFileSecondaryRenderRecord: Partial>> = + { + metric: MetrucSecondaryRenderRecord + }; diff --git a/web/src/layouts/ChatLayout/FileContainer/FileContainerSecondary/secondaryPanelsConfig/metricPanels.tsx b/web/src/layouts/ChatLayout/FileContainer/FileContainerSecondary/secondaryPanelsConfig/metricPanels.tsx index 8ac26d630..78286de22 100644 --- a/web/src/layouts/ChatLayout/FileContainer/FileContainerSecondary/secondaryPanelsConfig/metricPanels.tsx +++ b/web/src/layouts/ChatLayout/FileContainer/FileContainerSecondary/secondaryPanelsConfig/metricPanels.tsx @@ -32,3 +32,7 @@ export const MetricSecondaryRecord: Record< ) }; + +export const MetrucSecondaryRenderRecord: Partial> = { + 'sql-edit': false //we don't want to render the sql edit view in the secondary view because it is vertical +};