From be13ce221df277d12365ee2e2ce166a7c747315e Mon Sep 17 00:00:00 2001 From: dal Date: Thu, 7 Aug 2025 14:58:59 -0600 Subject: [PATCH 1/5] think and prep minimal effort --- .../src/agents/think-and-prep-agent/think-and-prep-agent.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/ai/src/agents/think-and-prep-agent/think-and-prep-agent.ts b/packages/ai/src/agents/think-and-prep-agent/think-and-prep-agent.ts index 8d8a8c6d2..52c9f0bc3 100644 --- a/packages/ai/src/agents/think-and-prep-agent/think-and-prep-agent.ts +++ b/packages/ai/src/agents/think-and-prep-agent/think-and-prep-agent.ts @@ -16,6 +16,10 @@ const DEFAULT_OPTIONS = { anthropic: { disableParallelToolCalls: true, }, + openai: { + disableParallelToolCalls: true, + reasoningEffort: 'minimal', + }, }, }; From fe22aabbbb2dac07709f18be298ec066e419e199 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Thu, 7 Aug 2025 14:59:41 -0600 Subject: [PATCH 2/5] Fixed context selector --- apps/web/src/components/ui/grid/SortableItemContext.tsx | 2 +- .../DashboardMetricItem/DashboardMetricItem.tsx | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/web/src/components/ui/grid/SortableItemContext.tsx b/apps/web/src/components/ui/grid/SortableItemContext.tsx index 72214542f..463bef3b0 100644 --- a/apps/web/src/components/ui/grid/SortableItemContext.tsx +++ b/apps/web/src/components/ui/grid/SortableItemContext.tsx @@ -1,5 +1,5 @@ import type { DraggableAttributes, DraggableSyntheticListeners } from '@dnd-kit/core'; -import React, { createContext } from 'react'; +import { createContext } from 'react'; interface Context { attributes: DraggableAttributes; diff --git a/apps/web/src/controllers/DashboardController/DashboardViewDashboardController/DashboardContentController/DashboardMetricItem/DashboardMetricItem.tsx b/apps/web/src/controllers/DashboardController/DashboardViewDashboardController/DashboardContentController/DashboardMetricItem/DashboardMetricItem.tsx index ad0129515..4b6556ce4 100644 --- a/apps/web/src/controllers/DashboardController/DashboardViewDashboardController/DashboardContentController/DashboardMetricItem/DashboardMetricItem.tsx +++ b/apps/web/src/controllers/DashboardController/DashboardViewDashboardController/DashboardContentController/DashboardMetricItem/DashboardMetricItem.tsx @@ -1,11 +1,10 @@ 'use client'; -import React, { useMemo } from 'react'; +import React, { useMemo,useContext } from 'react'; import { useMemoizedFn } from '@/hooks'; import { useDashboardMetric } from './useDashboardMetric'; import { assetParamsToRoute } from '@/lib/assets'; import { MetricCard } from '@/components/ui/metric'; -import { useContext } from 'use-context-selector'; import { SortableItemContext } from '@/components/ui/grid/SortableItemContext'; import { useMetricCardThreeDotMenuItems } from './metricCardThreeDotMenuItems'; From 358e74149ae16a19d1959175bf100ec641bce025 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Thu, 7 Aug 2025 15:09:49 -0600 Subject: [PATCH 3/5] try catch wrap --- apps/server/src/api/v2/reports/[id]/GET.ts | 33 +++++++++++++--------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/apps/server/src/api/v2/reports/[id]/GET.ts b/apps/server/src/api/v2/reports/[id]/GET.ts index 7eb956a6c..ce2c2b1af 100644 --- a/apps/server/src/api/v2/reports/[id]/GET.ts +++ b/apps/server/src/api/v2/reports/[id]/GET.ts @@ -11,23 +11,30 @@ export async function getReportHandler( ): Promise { const report = await getReport({ reportId, userId: user.id }); - const platejsResult = await markdownToPlatejs(report.content); + try { + const platejsResult = await markdownToPlatejs(report.content); - if (platejsResult.error) { - console.error('Error converting markdown to PlateJS:', platejsResult.error); + if (platejsResult.error) { + console.error('Error converting markdown to PlateJS:', platejsResult.error); + throw new HTTPException(500, { + message: 'Error converting markdown to PlateJS', + }); + } + + const content = platejsResult.elements ?? []; + + const response: GetReportIndividualResponse = { + ...report, + content, + }; + + return response; + } catch (error) { + console.error('Error converting markdown to PlateJS:', error); throw new HTTPException(500, { - message: 'Error converting markdown to PlateJS', + message: 'Error converting markdown', }); } - - const content = platejsResult.elements ?? []; - - const response: GetReportIndividualResponse = { - ...report, - content, - }; - - return response; } const app = new Hono() From 991dd172f6711c88c72fbb08eec37a78d1a372ad Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Thu, 7 Aug 2025 15:26:52 -0600 Subject: [PATCH 4/5] Fix dropdown on metric title --- .../ui/metric/MetricCardThreeMenuContainer.tsx | 16 +++++++--------- .../web/src/components/ui/metric/MetricTitle.tsx | 8 ++++---- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/apps/web/src/components/ui/metric/MetricCardThreeMenuContainer.tsx b/apps/web/src/components/ui/metric/MetricCardThreeMenuContainer.tsx index 9da5a72d5..7d5a7936c 100644 --- a/apps/web/src/components/ui/metric/MetricCardThreeMenuContainer.tsx +++ b/apps/web/src/components/ui/metric/MetricCardThreeMenuContainer.tsx @@ -22,16 +22,14 @@ export const MetricCardThreeMenuContainer = React.memo( }} className={cn( // Use opacity and pointer-events instead of display:none to maintain positioning context - 'w-8.5 rounded transition-opacity duration-75', - 'pointer-events-none opacity-0 group-hover:pointer-events-auto group-hover:opacity-100', - className, - isOpen && 'pointer-events-auto opacity-100' + '-mr-2 hidden group-hover:block', + 'group-hover:pointer-events-auto', + isOpen && 'pointer-events-auto block', + className )}> -
- - {children} - -
+ + {children} + ); } diff --git a/apps/web/src/components/ui/metric/MetricTitle.tsx b/apps/web/src/components/ui/metric/MetricTitle.tsx index 4ea387f90..233b64f26 100644 --- a/apps/web/src/components/ui/metric/MetricTitle.tsx +++ b/apps/web/src/components/ui/metric/MetricTitle.tsx @@ -37,8 +37,8 @@ export const MetricTitle: React.FC<{ }); return ( - <> -
+
+
- <Button variant="ghost" className="bg-item-hover!" prefix={<DotsVertical />} /> + <Button variant="ghost" className="hover:bg-item-active" prefix={<DotsVertical />} /> </MetricCardThreeMenuContainer> )} - </> + </div> ); } ); From 2f324baa620710b84464ff0b9414d528e89f4c5d Mon Sep 17 00:00:00 2001 From: Nate Kelley <nate@buster.so> Date: Thu, 7 Aug 2025 15:28:53 -0600 Subject: [PATCH 5/5] Remove some unecssary memo --- .../src/components/ui/metric/MetricCard.tsx | 190 +++++++++--------- .../metric/MetricCardThreeMenuContainer.tsx | 60 +++--- .../src/components/ui/metric/MetricTitle.tsx | 94 +++++---- .../DashboardMetricItem.tsx | 10 +- 4 files changed, 172 insertions(+), 182 deletions(-) diff --git a/apps/web/src/components/ui/metric/MetricCard.tsx b/apps/web/src/components/ui/metric/MetricCard.tsx index 46e0b2db2..1ba4656b3 100644 --- a/apps/web/src/components/ui/metric/MetricCard.tsx +++ b/apps/web/src/components/ui/metric/MetricCard.tsx @@ -9,105 +9,101 @@ import type { DropdownItems } from '../dropdown'; import Link from 'next/link'; import { PreparingYourRequestLoader } from '../charts/LoadingComponents'; -export const MetricCard = React.memo( - React.forwardRef< - HTMLDivElement, +export const MetricCard = React.forwardRef< + HTMLDivElement, + { + className?: string; + metricId: string; + metricLink: string; + isDragOverlay: boolean; + readOnly: boolean; + metricData: BusterMetricData | undefined; + metric: Pick<BusterMetric, 'name' | 'time_frame' | 'chart_config' | 'description'> | undefined; + renderChart: boolean; + loading: boolean; + error: string | undefined; + animate: boolean; + onInitialAnimationEnd?: () => void; + attributes?: DraggableAttributes; + listeners?: DraggableSyntheticListeners; + threeDotMenuItems: DropdownItems; + } +>( + ( { - className?: string; - metricId: string; - metricLink: string; - isDragOverlay: boolean; - readOnly: boolean; - metricData: BusterMetricData | undefined; - metric: - | Pick<BusterMetric, 'name' | 'time_frame' | 'chart_config' | 'description'> - | undefined; - renderChart: boolean; - loading: boolean; - error: string | undefined; - animate: boolean; - onInitialAnimationEnd?: () => void; - attributes?: DraggableAttributes; - listeners?: DraggableSyntheticListeners; - threeDotMenuItems: DropdownItems; - } - >( - ( - { - className = '', - metricId, - metricLink, - readOnly, - metricData, - metric, - isDragOverlay, - renderChart = true, - loading = false, - animate = true, - error, - attributes, - listeners, - threeDotMenuItems, - onInitialAnimationEnd - }, - ref - ) => { - const isTable = metric?.chart_config?.selectedChartType === 'table'; - const chartOptions = metric?.chart_config; - const data = metricData?.data || null; - const hideChart = isDragOverlay && data && data.length > 50; + className = '', + metricId, + metricLink, + readOnly, + metricData, + metric, + isDragOverlay, + renderChart = true, + loading = false, + animate = true, + error, + attributes, + listeners, + threeDotMenuItems, + onInitialAnimationEnd + }, + ref + ) => { + const isTable = metric?.chart_config?.selectedChartType === 'table'; + const chartOptions = metric?.chart_config; + const data = metricData?.data || null; + const hideChart = isDragOverlay && data && data.length > 50; - const content = () => { - if (renderChart && chartOptions && !hideChart) { - return ( - <BusterChartDynamic - data={data} - loading={loading} - error={error} - onInitialAnimationEnd={onInitialAnimationEnd} - animate={!isDragOverlay && animate} - animateLegend={false} - columnMetadata={metricData?.data_metadata?.column_metadata} - readOnly={true} - {...chartOptions} + const content = () => { + if (renderChart && chartOptions && !hideChart) { + return ( + <BusterChartDynamic + data={data} + loading={loading} + error={error} + onInitialAnimationEnd={onInitialAnimationEnd} + animate={!isDragOverlay && animate} + animateLegend={false} + columnMetadata={metricData?.data_metadata?.column_metadata} + readOnly={true} + {...chartOptions} + /> + ); + } + + return <PreparingYourRequestLoader />; + }; + + return ( + <Card + ref={ref} + className={cn('metric-item flex h-full w-full flex-col overflow-auto', className)}> + <Link className="swag flex" href={metricLink} prefetch {...attributes} {...listeners}> + <CardHeader + size="small" + data-testid={`metric-item-${metricId}`} + className="hover:bg-item-hover group relative min-h-13! w-full justify-center overflow-hidden border-b px-4 py-2"> + <MetricTitle + name={metric?.name || ''} + timeFrame={metric?.time_frame} + metricLink={metricLink} + isDragOverlay={false} + readOnly={readOnly} + description={metric?.description} + threeDotMenuItems={threeDotMenuItems} /> - ); - } + </CardHeader> + </Link> - return <PreparingYourRequestLoader />; - }; - - return ( - <Card - ref={ref} - className={cn('metric-item flex h-full w-full flex-col overflow-auto', className)}> - <Link className="swag flex" href={metricLink} prefetch {...attributes} {...listeners}> - <CardHeader - size="small" - data-testid={`metric-item-${metricId}`} - className="hover:bg-item-hover group relative min-h-13! w-full justify-center overflow-hidden border-b px-4 py-2"> - <MetricTitle - name={metric?.name || ''} - timeFrame={metric?.time_frame} - metricLink={metricLink} - isDragOverlay={false} - readOnly={readOnly} - description={metric?.description} - threeDotMenuItems={threeDotMenuItems} - /> - </CardHeader> - </Link> - - <div - className={cn( - 'h-full w-full overflow-hidden bg-transparent', - isTable ? '' : 'p-3', - isDragOverlay ? 'pointer-events-none' : 'pointer-events-auto' - )}> - {content()} - </div> - </Card> - ); - } - ) + <div + className={cn( + 'h-full w-full overflow-hidden bg-transparent', + isTable ? '' : 'p-3', + isDragOverlay ? 'pointer-events-none' : 'pointer-events-auto' + )}> + {content()} + </div> + </Card> + ); + } ); diff --git a/apps/web/src/components/ui/metric/MetricCardThreeMenuContainer.tsx b/apps/web/src/components/ui/metric/MetricCardThreeMenuContainer.tsx index 7d5a7936c..8947e7f6a 100644 --- a/apps/web/src/components/ui/metric/MetricCardThreeMenuContainer.tsx +++ b/apps/web/src/components/ui/metric/MetricCardThreeMenuContainer.tsx @@ -2,37 +2,35 @@ import { cn } from '@/lib/classMerge'; import React, { useState } from 'react'; import { Dropdown, type DropdownItems } from '../dropdown'; -export const MetricCardThreeMenuContainer = React.memo( - ({ - children, - dropdownItems, - className - }: { - className?: string; - children: React.ReactNode; - dropdownItems: DropdownItems; - }) => { - const [isOpen, setIsOpen] = useState(false); +export const MetricCardThreeMenuContainer = ({ + children, + dropdownItems, + className +}: { + className?: string; + children: React.ReactNode; + dropdownItems: DropdownItems; +}) => { + const [isOpen, setIsOpen] = useState(false); - return ( - <div - onClick={(e) => { - e.stopPropagation(); - e.preventDefault(); - }} - className={cn( - // Use opacity and pointer-events instead of display:none to maintain positioning context - '-mr-2 hidden group-hover:block', - 'group-hover:pointer-events-auto', - isOpen && 'pointer-events-auto block', - className - )}> - <Dropdown items={dropdownItems} side="top" align="end" onOpenChange={setIsOpen}> - {children} - </Dropdown> - </div> - ); - } -); + return ( + <div + onClick={(e) => { + e.stopPropagation(); + e.preventDefault(); + }} + className={cn( + // Use opacity and pointer-events instead of display:none to maintain positioning context + '-mr-2 hidden group-hover:block', + 'group-hover:pointer-events-auto', + isOpen && 'pointer-events-auto block', + className + )}> + <Dropdown items={dropdownItems} side="top" align="end" onOpenChange={setIsOpen}> + {children} + </Dropdown> + </div> + ); +}; MetricCardThreeMenuContainer.displayName = 'MetricCardThreeMenuContainer'; diff --git a/apps/web/src/components/ui/metric/MetricTitle.tsx b/apps/web/src/components/ui/metric/MetricTitle.tsx index 233b64f26..ff8bec638 100644 --- a/apps/web/src/components/ui/metric/MetricTitle.tsx +++ b/apps/web/src/components/ui/metric/MetricTitle.tsx @@ -20,57 +20,55 @@ export const MetricTitle: React.FC<{ isDragOverlay: boolean; readOnly?: boolean; threeDotMenuItems: DropdownItems; -}> = React.memo( - ({ - readOnly = true, - name, - description, - isDragOverlay, - metricLink, - timeFrame, - threeDotMenuItems - }) => { - const router = useRouter(); +}> = ({ + readOnly = true, + name, + description, + isDragOverlay, + metricLink, + timeFrame, + threeDotMenuItems +}) => { + const router = useRouter(); - useMount(() => { - if (metricLink) router.prefetch(metricLink); - }); + useMount(() => { + if (metricLink) router.prefetch(metricLink); + }); - return ( - <div className="group flex h-full min-h-0 w-full flex-1 flex-nowrap space-x-0.5"> - <div className={'flex h-full flex-1 cursor-pointer flex-col space-y-0.5 overflow-hidden'}> - <div className="flex w-full justify-between space-x-0.5 overflow-hidden"> - <Title - as="h4" - truncate - className="text-md! whitespace-nowrap" - style={{ fontSize: '14px' }}> - {`${name}`} - -
- -
- - {timeFrame || '_'} - - {description && timeFrame && ' • '} - - {description} - -
+ return ( +
+
+
+ + {`${name}`} +
- {isDragOverlay || readOnly ? null : ( - -
- ); - } -); + + {isDragOverlay || readOnly ? null : ( + +
+ ); +}; MetricTitle.displayName = 'MetricTitle'; diff --git a/apps/web/src/controllers/DashboardController/DashboardViewDashboardController/DashboardContentController/DashboardMetricItem/DashboardMetricItem.tsx b/apps/web/src/controllers/DashboardController/DashboardViewDashboardController/DashboardContentController/DashboardMetricItem/DashboardMetricItem.tsx index 4b6556ce4..6e9bf78cf 100644 --- a/apps/web/src/controllers/DashboardController/DashboardViewDashboardController/DashboardContentController/DashboardMetricItem/DashboardMetricItem.tsx +++ b/apps/web/src/controllers/DashboardController/DashboardViewDashboardController/DashboardContentController/DashboardMetricItem/DashboardMetricItem.tsx @@ -1,6 +1,6 @@ 'use client'; -import React, { useMemo,useContext } from 'react'; +import React, { useMemo, useContext } from 'react'; import { useMemoizedFn } from '@/hooks'; import { useDashboardMetric } from './useDashboardMetric'; import { assetParamsToRoute } from '@/lib/assets'; @@ -47,10 +47,8 @@ const DashboardMetricItemBase: React.FC<{ const animate = !initialAnimationEnded && !isDragOverlay && dataLength < 125 && numberOfMetrics <= 30; - const error: string | undefined = useMemo( - () => metric?.error || metricDataError?.message || metricError?.message || undefined, - [metric?.error, metricDataError, metricError] - ); + const error: string | undefined = + metric?.error || metricDataError?.message || metricError?.message || undefined; const metricLink = useMemo(() => { return assetParamsToRoute({ @@ -92,4 +90,4 @@ const DashboardMetricItemBase: React.FC<{ ); }; -export const DashboardMetricItem = React.memo(DashboardMetricItemBase); +export const DashboardMetricItem = DashboardMetricItemBase;