mirror of https://github.com/buster-so/buster.git
use update effect with logging
This commit is contained in:
parent
94d3c52ae9
commit
4bb83dbf17
|
@ -101,10 +101,7 @@ export const StreamingMessageCode: React.FC<
|
||||||
{lineSegments.map((segment, index) => (
|
{lineSegments.map((segment, index) => (
|
||||||
<div
|
<div
|
||||||
key={`${segment.lineNumber}-${index}`}
|
key={`${segment.lineNumber}-${index}`}
|
||||||
className={cn(
|
className={cn('line-number pr-1', !isCompletedStream && 'fade-in duration-500')}>
|
||||||
'line-number pr-1',
|
|
||||||
!isCompletedStream && 'animate-in fade-in duration-700'
|
|
||||||
)}>
|
|
||||||
{segment.type === 'text' ? (
|
{segment.type === 'text' ? (
|
||||||
<MemoizedSyntaxHighlighter lineNumber={segment.lineNumber} text={segment.content} />
|
<MemoizedSyntaxHighlighter lineNumber={segment.lineNumber} text={segment.content} />
|
||||||
) : (
|
) : (
|
||||||
|
|
|
@ -55,8 +55,7 @@ const AnimatedSpan: React.FC<{ children: React.ReactNode; isCompletedStream: boo
|
||||||
isCompletedStream
|
isCompletedStream
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<span
|
<span className={cn('leading-1.5', !isCompletedStream ? 'fade-in duration-500' : '')}>
|
||||||
className={cn('leading-1.5', !isCompletedStream ? 'animate-in fade-in duration-700' : '')}>
|
|
||||||
{children}
|
{children}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|
|
@ -38,7 +38,7 @@ export const CustomParagraph: React.FC<
|
||||||
<p
|
<p
|
||||||
className={cn(
|
className={cn(
|
||||||
'text-size-inherit!',
|
'text-size-inherit!',
|
||||||
showLoader && 'fade-in transform-none! transition-none duration-700'
|
showLoader && 'fade-in transform-none! transition-none duration-500'
|
||||||
)}>
|
)}>
|
||||||
{children}
|
{children}
|
||||||
</p>
|
</p>
|
||||||
|
@ -55,7 +55,7 @@ export const CustomParagraph: React.FC<
|
||||||
<p
|
<p
|
||||||
className={cn(
|
className={cn(
|
||||||
'text-size-inherit!',
|
'text-size-inherit!',
|
||||||
showLoader && 'fade-in transform-none! transition-none duration-700'
|
showLoader && 'fade-in transform-none! transition-none duration-500'
|
||||||
)}>
|
)}>
|
||||||
{children}
|
{children}
|
||||||
</p>
|
</p>
|
||||||
|
@ -91,7 +91,7 @@ export const CustomHeading: React.FC<
|
||||||
<HeadingTag
|
<HeadingTag
|
||||||
className={cn(
|
className={cn(
|
||||||
headingVariants({ level: stripFormatting ? 'base' : level }),
|
headingVariants({ level: stripFormatting ? 'base' : level }),
|
||||||
showLoader && 'fade-in transform-none! transition-none duration-700'
|
showLoader && 'fade-in transform-none! transition-none duration-500'
|
||||||
)}>
|
)}>
|
||||||
{children}
|
{children}
|
||||||
</HeadingTag>
|
</HeadingTag>
|
||||||
|
@ -109,7 +109,7 @@ export const CustomList: React.FC<
|
||||||
const ListTag = ordered ? 'ol' : 'ul';
|
const ListTag = ordered ? 'ol' : 'ul';
|
||||||
return (
|
return (
|
||||||
<ListTag
|
<ListTag
|
||||||
className={cn('', showLoader && 'fade-in transform-none! transition-none duration-700')}
|
className={cn('', showLoader && 'fade-in transform-none! transition-none duration-500')}
|
||||||
{...rest}>
|
{...rest}>
|
||||||
{children}
|
{children}
|
||||||
</ListTag>
|
</ListTag>
|
||||||
|
@ -130,7 +130,7 @@ export const CustomOrderedList: React.FC<
|
||||||
start={start}
|
start={start}
|
||||||
className={cn(
|
className={cn(
|
||||||
'mt-1 space-y-1',
|
'mt-1 space-y-1',
|
||||||
showLoader && 'fade-in transform-none! transition-none duration-700'
|
showLoader && 'fade-in transform-none! transition-none duration-500'
|
||||||
)}>
|
)}>
|
||||||
{children}
|
{children}
|
||||||
</ol>
|
</ol>
|
||||||
|
@ -149,7 +149,7 @@ export const CustomUnorderedList: React.FC<
|
||||||
<ul
|
<ul
|
||||||
className={cn(
|
className={cn(
|
||||||
'mt-1 space-y-1',
|
'mt-1 space-y-1',
|
||||||
showLoader && 'fade-in transform-none! transition-none duration-700'
|
showLoader && 'fade-in transform-none! transition-none duration-500'
|
||||||
)}
|
)}
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
start={start}>
|
start={start}>
|
||||||
|
@ -169,7 +169,7 @@ export const CustomListItem: React.FC<
|
||||||
<li
|
<li
|
||||||
className={cn(
|
className={cn(
|
||||||
'space-y-1',
|
'space-y-1',
|
||||||
showLoader && 'fade-in transform-none! transition-none duration-700'
|
showLoader && 'fade-in transform-none! transition-none duration-500'
|
||||||
)}>
|
)}>
|
||||||
{children}
|
{children}
|
||||||
</li>
|
</li>
|
||||||
|
@ -185,7 +185,7 @@ export const CustomBlockquote: React.FC<
|
||||||
> = ({ children, markdown, showLoader, ...rest }) => {
|
> = ({ children, markdown, showLoader, ...rest }) => {
|
||||||
return (
|
return (
|
||||||
<blockquote
|
<blockquote
|
||||||
className={cn('', showLoader && 'fade-in transform-none! transition-none duration-700')}>
|
className={cn('', showLoader && 'fade-in transform-none! transition-none duration-500')}>
|
||||||
{children}
|
{children}
|
||||||
</blockquote>
|
</blockquote>
|
||||||
);
|
);
|
||||||
|
@ -199,7 +199,7 @@ export const CustomTable: React.FC<
|
||||||
} & ExtraPropsExtra
|
} & ExtraPropsExtra
|
||||||
> = ({ children, markdown, showLoader, ...rest }) => {
|
> = ({ children, markdown, showLoader, ...rest }) => {
|
||||||
return (
|
return (
|
||||||
<table className={cn('', showLoader && 'fade-in transform-none! transition-none duration-700')}>
|
<table className={cn('', showLoader && 'fade-in transform-none! transition-none duration-500')}>
|
||||||
{children}
|
{children}
|
||||||
</table>
|
</table>
|
||||||
);
|
);
|
||||||
|
@ -213,7 +213,7 @@ export const CustomSpan: React.FC<
|
||||||
} & ExtraPropsExtra
|
} & ExtraPropsExtra
|
||||||
> = ({ children, markdown, showLoader, ...rest }) => {
|
> = ({ children, markdown, showLoader, ...rest }) => {
|
||||||
return (
|
return (
|
||||||
<span className={cn('', showLoader && 'fade-in transform-none! transition-none duration-700')}>
|
<span className={cn('', showLoader && 'fade-in transform-none! transition-none duration-500')}>
|
||||||
{children}
|
{children}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,20 +1,14 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useAppLayoutContextSelector } from '@/context/BusterAppLayout';
|
import { useAppLayoutContextSelector } from '@/context/BusterAppLayout';
|
||||||
import { useParams, useSearchParams } from 'next/navigation';
|
import { useParams, usePathname, useSearchParams } from 'next/navigation';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { FileViewSecondary } from './useLayoutConfig';
|
import { FileViewSecondary } from './useLayoutConfig';
|
||||||
|
import { useWhyDidYouUpdate } from '@/hooks';
|
||||||
|
import { pathNameToRoute } from '@/routes/helpers';
|
||||||
|
|
||||||
export const useGetChatParams = () => {
|
export const useGetChatParams = () => {
|
||||||
const {
|
const params = useParams() as {
|
||||||
chatId,
|
|
||||||
versionNumber: versionNumberPath,
|
|
||||||
metricId,
|
|
||||||
dashboardId,
|
|
||||||
collectionId,
|
|
||||||
datasetId,
|
|
||||||
messageId
|
|
||||||
} = useParams() as {
|
|
||||||
versionNumber: string | undefined;
|
versionNumber: string | undefined;
|
||||||
chatId: string | undefined;
|
chatId: string | undefined;
|
||||||
metricId: string | undefined;
|
metricId: string | undefined;
|
||||||
|
@ -23,11 +17,22 @@ export const useGetChatParams = () => {
|
||||||
datasetId: string | undefined;
|
datasetId: string | undefined;
|
||||||
messageId: string | undefined;
|
messageId: string | undefined;
|
||||||
};
|
};
|
||||||
|
const {
|
||||||
|
chatId,
|
||||||
|
versionNumber: versionNumberPath,
|
||||||
|
metricId,
|
||||||
|
dashboardId,
|
||||||
|
collectionId,
|
||||||
|
datasetId,
|
||||||
|
messageId
|
||||||
|
} = params;
|
||||||
|
const pathname = usePathname();
|
||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
const queryMetricVersionNumber = searchParams.get('metric_version_number');
|
const queryMetricVersionNumber = searchParams.get('metric_version_number');
|
||||||
const queryDashboardVersionNumber = searchParams.get('dashboard_version_number');
|
const queryDashboardVersionNumber = searchParams.get('dashboard_version_number');
|
||||||
const secondaryView = searchParams.get('secondary_view') as FileViewSecondary | undefined;
|
const secondaryView = searchParams.get('secondary_view') as FileViewSecondary | undefined;
|
||||||
const currentRoute = useAppLayoutContextSelector((x) => x.currentRoute);
|
const currentRoute = pathNameToRoute(pathname, params);
|
||||||
|
const iCurrentRoute = useAppLayoutContextSelector((x) => x.currentRoute);
|
||||||
|
|
||||||
const metricVersionNumber = useMemo(() => {
|
const metricVersionNumber = useMemo(() => {
|
||||||
if (!metricId) return undefined;
|
if (!metricId) return undefined;
|
||||||
|
@ -50,6 +55,7 @@ export const useGetChatParams = () => {
|
||||||
|
|
||||||
return useMemo(
|
return useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
|
currentRoute,
|
||||||
isVersionHistoryMode,
|
isVersionHistoryMode,
|
||||||
chatId,
|
chatId,
|
||||||
metricId,
|
metricId,
|
||||||
|
@ -59,10 +65,11 @@ export const useGetChatParams = () => {
|
||||||
messageId,
|
messageId,
|
||||||
metricVersionNumber,
|
metricVersionNumber,
|
||||||
dashboardVersionNumber,
|
dashboardVersionNumber,
|
||||||
currentRoute,
|
|
||||||
secondaryView
|
secondaryView
|
||||||
}),
|
}),
|
||||||
|
//So... currentRoute was always one render cycle behind the app context selector. So we calculate it here.
|
||||||
[
|
[
|
||||||
|
currentRoute,
|
||||||
isVersionHistoryMode,
|
isVersionHistoryMode,
|
||||||
chatId,
|
chatId,
|
||||||
metricId,
|
metricId,
|
||||||
|
@ -72,7 +79,6 @@ export const useGetChatParams = () => {
|
||||||
messageId,
|
messageId,
|
||||||
metricVersionNumber,
|
metricVersionNumber,
|
||||||
dashboardVersionNumber,
|
dashboardVersionNumber,
|
||||||
currentRoute,
|
|
||||||
secondaryView
|
secondaryView
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue