make secondary for sql not appear

This commit is contained in:
Nate Kelley 2025-03-29 22:01:07 -06:00
parent 9fa8c6a2d3
commit 9a4d32ce7a
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
6 changed files with 30 additions and 16 deletions

View File

@ -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 <div></div>;
@ -26,7 +26,7 @@ export const ChatHeaderTitle: React.FC<{
return (
<AnimatePresence mode="wait" initial={false}>
<motion.div
{...animation}
{...(isCompletedStream ? animation : {})}
key={chatTitle}
className="flex w-full items-center overflow-hidden">
<EditableTitle

View File

@ -8,7 +8,6 @@ export type FileViewConfig = Partial<
FileView,
{
secondaryView: FileViewSecondary;
renderView?: boolean; //this is really just used for metric because it has a vertical view and we don't want to render a right panel. undefined defaults to true
}
>
>;

View File

@ -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
};
}
});

View File

@ -17,8 +17,7 @@ export const MetricContainerHeaderSegment: React.FC<FileContainerSegmentProps> =
const onSetFileView = useChatLayoutContextSelector((x) => x.onSetFileView);
const onChange = useMemoizedFn((fileView: SegmentedItem<FileView>) => {
const renderView = fileView.value === 'results' ? false : true;
onSetFileView({ fileView: fileView.value, renderView });
onSetFileView({ fileView: fileView.value });
});
return (

View File

@ -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<Record<FileType, Record<string, boolean>>> =
{
metric: MetrucSecondaryRenderRecord
};

View File

@ -32,3 +32,7 @@ export const MetricSecondaryRecord: Record<
<VersionHistoryPanel assetId={selectedFile?.id || ''} type="metric" />
)
};
export const MetrucSecondaryRenderRecord: Partial<Record<MetricFileViewSecondary, boolean>> = {
'sql-edit': false //we don't want to render the sql edit view in the secondary view because it is vertical
};