Skip to content

Commit b204742

Browse files
authored
fix(frontend): wait for columns before an auto view loads the hog vm
With the Auto visualization and no columns yet, the effective type resolves to a table, so a query with formatting rules started the Hog VM download before its data showed it was a chart. needsHogVm now treats Auto as undecided until columns arrive. An explicit table view still starts the load at once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Generated-By: PostHog Desktop Task-Id: acec8cb2-f000-4747-a659-05b72b42513e
1 parent 3c572b5 commit b204742

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

‎frontend/src/queries/nodes/DataVisualization/dataVisualizationLogic.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,12 @@ describe('dataVisualizationLogic', () => {
682682
rules: [],
683683
hogVm: null,
684684
},
685+
{
686+
name: 'does not load the Hog VM for an auto visualization before its data arrives',
687+
display: ChartDisplayType.Auto,
688+
rules: [equalsRule],
689+
hogVm: null,
690+
},
685691
{
686692
name: 'does not load the Hog VM for a chart that kept table formatting rules',
687693
display: ChartDisplayType.ActionsLineGraph,

‎frontend/src/queries/nodes/DataVisualization/dataVisualizationLogic.ts‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,9 @@ export interface dataVisualizationLogicMeta {
988988
| null
989989
) => ChartDisplayType
990990
needsHogVm: (
991+
visualizationType: ChartDisplayType,
991992
effectiveVisualizationType: ChartDisplayType,
993+
columns: Column[],
992994
conditionalFormattingRules: ConditionalFormattingRule[]
993995
) => boolean
994996
hogVmLoadFailed: (needsHogVm: boolean, hogVmLoadError: unknown) => boolean
@@ -1914,10 +1916,18 @@ export const dataVisualizationLogic = kea<dataVisualizationLogicType>([
19141916
): ChartDisplayType => getAutoVisualizationType(columns, rowCountFromResponse(response)),
19151917
],
19161918
// The Hog VM and its crypto polyfills are large, so only a table that shows formatting rules loads them.
1919+
// Auto resolves to a table until columns arrive, so it waits for them before it decides.
19171920
needsHogVm: [
1918-
(s) => [s.effectiveVisualizationType, s.conditionalFormattingRules],
1919-
(visualizationType: ChartDisplayType, rules: ConditionalFormattingRule[]): boolean =>
1920-
visualizationType === ChartDisplayType.ActionsTable && rules.length > 0,
1921+
(s) => [s.visualizationType, s.effectiveVisualizationType, s.columns, s.conditionalFormattingRules],
1922+
(
1923+
visualizationType: ChartDisplayType,
1924+
effectiveVisualizationType: ChartDisplayType,
1925+
columns: Column[],
1926+
rules: ConditionalFormattingRule[]
1927+
): boolean =>
1928+
(visualizationType !== ChartDisplayType.Auto || columns.length > 0) &&
1929+
effectiveVisualizationType === ChartDisplayType.ActionsTable &&
1930+
rules.length > 0,
19211931
],
19221932
hogVmLoadFailed: [
19231933
(s) => [s.needsHogVm, s.hogVmLoadError],

0 commit comments

Comments
 (0)