diff --git a/.changeset/chart-explorer-auto-run.md b/.changeset/chart-explorer-auto-run.md new file mode 100644 index 0000000000..f4258994de --- /dev/null +++ b/.changeset/chart-explorer-auto-run.md @@ -0,0 +1,5 @@ +--- +"@hyperdx/app": patch +--- + +feat: Chart Explorer now auto-executes the chart on load when a valid source is configured. Deeplinks render results without requiring a manual click. diff --git a/packages/app/src/DBChartPage.tsx b/packages/app/src/DBChartPage.tsx index 045ed41104..82f2e5e26d 100644 --- a/packages/app/src/DBChartPage.tsx +++ b/packages/app/src/DBChartPage.tsx @@ -253,6 +253,7 @@ function DBChartExplorerPage() { onTimeRangeSearch={onSearch} onTimeRangeSelect={onTimeRangeSelect} submitRef={submitRef} + autoRun /> ); diff --git a/packages/app/src/components/DBEditTimeChartForm.tsx b/packages/app/src/components/DBEditTimeChartForm.tsx index 347eeccf4c..fe930f2f22 100644 --- a/packages/app/src/components/DBEditTimeChartForm.tsx +++ b/packages/app/src/components/DBEditTimeChartForm.tsx @@ -546,6 +546,7 @@ export default function EditTimeChartForm({ 'data-testid': dataTestId, submitRef, isDashboardForm = false, + autoRun = false, }: { dashboardId?: string; chartConfig: SavedChartConfig; @@ -562,6 +563,7 @@ export default function EditTimeChartForm({ 'data-testid'?: string; submitRef?: React.MutableRefObject<(() => void) | undefined>; isDashboardForm?: boolean; + autoRun?: boolean; }) { const formValue: ChartEditorFormState = useMemo( () => convertSavedChartConfigToFormState(chartConfig), @@ -827,6 +829,14 @@ export default function EditTimeChartForm({ } }, [onSubmit, submitRef]); + const autoRunFired = useRef(false); + useEffect(() => { + if (autoRun && !autoRunFired.current && tableSource) { + autoRunFired.current = true; + onSubmit(true); + } + }, [autoRun, tableSource, onSubmit]); + const handleSave = useCallback( (form: ChartEditorFormState) => { const errors = validateChartForm(form, tableSource, setError);