Repository navigation
feat: aggregations, multiple lines in line chart and dashboard tools refactoring - #591
Conversation
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
- Added `addDefaultChart` method to `MosaicDashboardContext` for default chart creation. - Wrapped `RendererComponent` in `DashboardPanelErrorBoundary` in `MosaicDashboardPanel` for error handling. - Updated `MosaicDashboardProfilerPanelRenderer` to use `ProfilerPanelRendererProps`. - Refactored `createMosaicDashboardVgPlotPanelConfig` to accept `VgPlotChartConfig` directly. - Modified `MosaicDashboardToolbar` to trigger `addDefaultChart` instead of `openBuilder`. - Improved `ChartSettings` component structure with a new context for better state management. - Removed deprecated chart settings components (e.g., `BoxPlotSettings`, `BubbleSettings`, etc.) and replaced them with a dynamic settings approach. - Introduced `DynamicChartSettings` for handling chart-specific settings dynamically based on selected chart type. - Updated `generateMosaicChartSpec` to include error handling and improved logging. - Cleaned up imports and exports across various files for better organization and clarity. Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
- Add multiple flag to yFields field definition - Generate multiple lineY marks and text labels - Add getLineColor helper for auto color assignment Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
- Display list of selected fields with remove buttons - Add Y-axis button to add more fields - Enforce minimum 1 field when required - Filter out already-selected columns Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
- Check field.multiple flag to render MultiFieldSelector - Handle array values for multi-field selectors - Keep single field rendering unchanged Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
…change
Add type assertions to fix TypeScript discriminated union type errors that occurred after changing line chart schema from {y: string} to {yFields: Array<{field: string, color?: string}>}. The assertions are necessary because TypeScript cannot infer the exact discriminated union member when settings are dynamically constructed.
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Mosaic/vgplot does not resolve CSS variables at runtime. This change replaces `var(--color-chart-X)` with actual hex colors converted from the theme's HSL values, ensuring each line in a multi-line chart gets a distinct color. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
- Add xInterval for temporal granularity - Add aggregate option per Y-field (sum/avg) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
- Auto-detects temporal X-axis fields - Dropdown with temporal interval options - None option to disable aggregation Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
- Add showAggregation prop to control visibility - Aggregation dropdown (SUM/AVG) per field - Update field value type to include aggregate Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
…th aggregation support Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/mosaic/src/dashboard/MosaicDashboardSlice.ts (1)
742-758:⚠️ Potential issue | 🟠 Major | 🏗️ Heavy liftStale
vgplotproperty check will permanently suppress chart eviction on config changesThe eviction guard at line 753 (
Object.prototype.hasOwnProperty.call(patch.config, 'vgplot')) checks for a property that does not exist onVgPlotChartConfig. The actual schema for each chart type (histogram, line-chart, etc.) only defineschartType,settings, and optionalsettingsOpen—there is novgplotfield in the discriminated union.Consequence: after any chart-settings update (
updatePanelwith config patches containingchartType,settings,settingsOpen, etc.),evictPanelRuntimeis never called. Retained chart instances remain stale, and the chart UI will not re-render with new settings.Update the condition to check for fields that actually exist on the new
VgPlotChartConfig, or remove this eviction path entirely if retained charts no longer require spec-driven re-rendering.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/mosaic/src/dashboard/MosaicDashboardSlice.ts` around lines 742 - 758, The eviction check in shouldEvictPanelRuntimeForPatch is using a nonexistent patch.config.vgplot property so chart config updates never trigger eviction; update the MOSAIC_DASHBOARD_VGPLOT_PANEL_TYPE branch to inspect actual VgPlotChartConfig fields (e.g., check whether patch.config has ownProperty 'chartType' or 'settings' or 'settingsOpen') and return true when any of those are present, or if you prefer, remove the specialized vgplot branch and always return true for any config patch on VGPLOT panels to ensure evictPanelRuntime is called on chart-settings updates.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/mosaic/src/chart-types/line-chart/schema.ts`:
- Around line 24-26: The schema currently uses
AggregateFunction.optional().default('sum') so Zod 4 treats undefined as
optional and the default never runs; update the line in the line-chart schema to
remove .optional() (i.e., use AggregateFunction.default('sum') and keep
.describe(...)) so the default is applied by Zod at runtime, and then remove or
reconsider the defensive fallback (const aggregate = fieldConfig.aggregate ||
'sum') in definition.ts since the schema will now guarantee a value.
---
Outside diff comments:
In `@packages/mosaic/src/dashboard/MosaicDashboardSlice.ts`:
- Around line 742-758: The eviction check in shouldEvictPanelRuntimeForPatch is
using a nonexistent patch.config.vgplot property so chart config updates never
trigger eviction; update the MOSAIC_DASHBOARD_VGPLOT_PANEL_TYPE branch to
inspect actual VgPlotChartConfig fields (e.g., check whether patch.config has
ownProperty 'chartType' or 'settings' or 'settingsOpen') and return true when
any of those are present, or if you prefer, remove the specialized vgplot branch
and always return true for any config patch on VGPLOT panels to ensure
evictPanelRuntime is called on chart-settings updates.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 26582505-4659-44e9-83a5-295f49c9bf0d
📒 Files selected for processing (19)
apps/sqlrooms-cli-ui/src/createDashboardCommands.tsapps/sqlrooms-cli-ui/src/utils.tsapps/sqlrooms-cli-ui/src/vgplot.tspackages/mosaic/src/chart-builders/constants.tspackages/mosaic/src/chart-types/box-plot/tool.tspackages/mosaic/src/chart-types/bubble-chart/tool.tspackages/mosaic/src/chart-types/count-plot/tool.tspackages/mosaic/src/chart-types/ecdf/tool.tspackages/mosaic/src/chart-types/heatmap/tool.tspackages/mosaic/src/chart-types/histogram/schema.tspackages/mosaic/src/chart-types/histogram/tool.tspackages/mosaic/src/chart-types/line-chart/schema.tspackages/mosaic/src/chart-types/line-chart/tool.tspackages/mosaic/src/chart-types/tool-helpers.tspackages/mosaic/src/dashboard/MosaicDashboard.tsxpackages/mosaic/src/dashboard/MosaicDashboardSlice.tspackages/mosaic/src/dashboard/MosaicDashboardVgPlotPanelRenderer.tsxpackages/mosaic/src/dashboard/chart-settings/ChartSettings.tsxpackages/mosaic/src/dashboard/useGenerateSpec.ts
💤 Files with no reviewable changes (3)
- apps/sqlrooms-cli-ui/src/utils.ts
- apps/sqlrooms-cli-ui/src/vgplot.ts
- apps/sqlrooms-cli-ui/src/createDashboardCommands.ts
🚧 Files skipped from review as they are similar to previous changes (10)
- packages/mosaic/src/chart-types/histogram/tool.ts
- packages/mosaic/src/dashboard/MosaicDashboard.tsx
- packages/mosaic/src/chart-types/count-plot/tool.ts
- packages/mosaic/src/chart-types/histogram/schema.ts
- packages/mosaic/src/chart-types/bubble-chart/tool.ts
- packages/mosaic/src/chart-types/ecdf/tool.ts
- packages/mosaic/src/chart-types/line-chart/tool.ts
- packages/mosaic/src/chart-types/tool-helpers.ts
- packages/mosaic/src/chart-types/heatmap/tool.ts
- packages/mosaic/src/dashboard/chart-settings/ChartSettings.tsx
| aggregate: AggregateFunction.optional() | ||
| .default('sum') | ||
| .describe('Aggregation function: sum, avg, min, or max'), |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
Zod 4 optional().default() chaining behavior TypeScript inferred type
💡 Result:
In Zod 4, chaining behavior and TypeScript inferred types for default + optional depend on whether you look at output vs input types, and on the order of chaining. 1) What Zod 4 changes: default short-circuits on undefined Zod 4’s.default short-circuits parsing when the input is undefined and returns the default immediately, so the default must be assignable to the output type. [1] 2) Why.optional.default often surprises people - Zod’s.optional wraps the inner schema so that if the input is undefined, the optional wrapper returns undefined immediately. That means if you put.optional after/around the default, you can prevent the default from being applied at runtime (and it also affects the inferred types). [2] - A concrete explanation from a Zod issue: calling.optional wraps the schema in a ZodOptional; if you pass undefined into ZodOptional, it immediately returns undefined—so a default wrapped in.optional won’t get applied. [2] 3) TypeScript inference: output vs input Zod provides two relevant type views: - Output type: z.output (and z.infer) - Input type: z.input When you combine optional and default, the output type is generally “value will exist” (because default provides it when input is undefined), while the input type may still allow omission/undefined. A Zod issue shows this explicitly for Zod 4: - Example interpretation: type SchemaOutput is { limit: number; offset?: number | undefined } and type SchemaInput is { limit?: number | undefined; offset?: number | undefined }. [2] So if you write: - type T = z.infer (i.e., output), the property with a default is typically required in that output type. - type T = z.input, the property may be optional in the input type. This is the common root cause of “.optional.default doesn’t make my property optional” reports: the user is using z.infer (output type) where they should be using z.input (input type) if they want to type the object they pass into parse. [3] 4) Practical rules for “optional property with default” A) If your goal is: “My parsed result always has the property” Use z.infer / z.output for typing the parsed value. Zod 4’s default ensures the output value exists when input is undefined. [1][2] B) If your goal is: “My input object may omit the property” Type your input with z.input (or Zod’s input helper). Zod 4’s default may still make the output property required, but the input can still omit it. [2][4] 5) Chaining-order nuance (runtime + inference) Because.optional short-circuits undefined inputs at the wrapper level, putting.optional in the wrong position can stop the default from applying. The Zod issue discussion notes that calling.optional wraps the original schema in ZodOptional, so undefined is returned before the default can run when it’s wrapped by optional. [2] 6) Recommended pattern For most use-cases in Zod 4: - Define the schema with.default(...) where you want a fallback. - Use z.input to type what you pass to parse. - Use z.output / z.infer to type what you get back from parse. This matches Zod’s own discussion of input vs output types in this scenario. [3][2] If you share your exact schema snippet (including whether you chain as.optional.default(...) or.default(...).optional) and the type you’re trying to assign, I can tell you what z.input vs z.infer will resolve to in that specific case.
Citations:
- 1: https://www.zod.dev/v4/changelog?id=defaults-applied-within-optional-fields
- 2: v4(bug): Default values not working as expected with optional fields colinhacks/zod#4179
- 3:
.optional().default()doesn't make property optional in typeScript type inference colinhacks/zod#2491 - 4: https://www.ryanmr.com/posts/zod-optional-default
🏁 Script executed:
# Search for usages of aggregate field from YFieldConfig
rg "aggregate" packages/mosaic/src/chart-types/line-chart/ -A 2 -B 2Repository: sqlrooms/sqlrooms
Length of output: 2697
Remove .optional() from the aggregate chain or restructure the default.
In Zod 4, .optional() wraps the schema and intercepts undefined inputs before .default() runs, so .optional().default('sum') does not apply the default at runtime—it returns undefined instead. The schema is therefore incorrect.
Downstream code in definition.ts works around this with const aggregate = fieldConfig.aggregate || 'sum', but the schema should not be misleading. Either remove .optional() to make aggregate required with a guaranteed default, or restructure as needed based on your actual requirements. Relying on defensive fallbacks in consumer code instead of fixing the schema is technical debt.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/mosaic/src/chart-types/line-chart/schema.ts` around lines 24 - 26,
The schema currently uses AggregateFunction.optional().default('sum') so Zod 4
treats undefined as optional and the default never runs; update the line in the
line-chart schema to remove .optional() (i.e., use
AggregateFunction.default('sum') and keep .describe(...)) so the default is
applied by Zod at runtime, and then remove or reconsider the defensive fallback
(const aggregate = fieldConfig.aggregate || 'sum') in definition.ts since the
schema will now guarantee a value.
…d validation in chart tools
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
packages/mosaic/__tests__/ChartSettings.test.tsx (2)
119-119:⚠️ Potential issue | 🟠 Major | ⚡ Quick winUpdate
line-chartfixture to use the newyFieldsschema after the multiple-Y-fields refactor.The fixture at line 119 uses
{x: 'id', y: 'amount'}, but the schema changed to expectyFieldsas an array ofYFieldConfigobjects (seepackages/mosaic/src/chart-types/line-chart/schema.tslines 38–41). The test should be:{type: 'line-chart', settings: {x: 'id', yFields: [{field: 'amount'}]}}Because
settingsis typedany, this mismatch isn't caught at compile time. The fixture must match the actual schema to ensure the test exercises the intended code path with multiple Y fields support.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/mosaic/__tests__/ChartSettings.test.tsx` at line 119, Update the test fixture for the 'line-chart' entry so its settings follow the new multiple-Y-fields schema: replace the single y property with yFields being an array of YFieldConfig objects (e.g., change settings from {x: 'id', y: 'amount'} to {x: 'id', yFields: [{field: 'amount'}]}), ensuring the 'line-chart' fixture in ChartSettings.test.tsx matches the schema defined for the line-chart type and exercises multiple Y fields support.
16-22:⚠️ Potential issue | 🟠 Major | ⚡ Quick winUpdate line-chart test fixture to match the new schema.
The
line-chartsettings at line 119 use the old schema format{x: 'id', y: 'amount'}, but the schema now definesyFieldsas an array ofYFieldConfigobjects:yFields: z.array(YFieldConfig).optional() .describe('Array of Y fields to plot, supports multiple lines')The test fixture should be updated to:
🔧 Proposed fix
- {type: 'line-chart', settings: {x: 'id', y: 'amount'}}, + {type: 'line-chart', settings: {x: 'id', yFields: [{field: 'amount'}]}},The use of
settings: anyat line 115 masks this type mismatch. Consider using a properly-typed fixture or a type assertion that matches the actual schema.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/mosaic/__tests__/ChartSettings.test.tsx` around lines 16 - 22, The test fixture for "line-chart" uses the old shape {x: 'id', y: 'amount'}; update it to the new schema by replacing the old y property with the new yFields array of YFieldConfig objects (e.g., yFields: [{ field: 'amount' }] while keeping the x/xField as appropriate) and ensure the fixture matches the actual ChartSettings schema; also remove or narrow the settings: any usage in the test and either import/apply the proper type for settings or use a type assertion to the chart settings type so the mismatch is caught at compile time (update references to settings and the "line-chart" fixture and ensure YFieldConfig is used).
🧹 Nitpick comments (3)
packages/mosaic/__tests__/ChartSettings.test.tsx (1)
113-116: ⚡ Quick win
settings: anybypasses schema validation for the "all chart types" test.Typing
settingsasanymeans TypeScript won't catch mismatches when the per-chart settings schemas evolve (as happened withline-chartin this very PR). Consider typing it asVgPlotChartConfig['settings']or using a discriminated union so that fixture drift is caught at compile time rather than silently at runtime.♻️ Suggested improvement
- const chartTypes: Array<{ - type: VgPlotChartConfig['chartType']; - settings: any; - }> = [ + const chartTypes: Array<VgPlotChartConfig> = [ + {chartType: 'histogram', settings: {field: 'amount'}}, + {chartType: 'count-plot', settings: {field: 'name'}}, + {chartType: 'line-chart', settings: {x: 'id', y: ['amount']}}, + // ... etc + ];Then iterate as:
- chartTypes.forEach(({type, settings}) => { - const config: VgPlotChartConfig = { - chartType: type, - settings, - }; + chartTypes.forEach((config) => {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/mosaic/__tests__/ChartSettings.test.tsx` around lines 113 - 116, The chartTypes test fixture declares each item with settings: any which bypasses compile-time schema checks; update the chartTypes definition so settings is typed as VgPlotChartConfig['settings'] (or replace the array with a discriminated-union type keyed by chartType to match per-chart schemas), e.g. change the array element type to { type: VgPlotChartConfig['chartType']; settings: VgPlotChartConfig['settings'] } (or the appropriate union) so TypeScript will error when a fixture's settings no longer match the chart's schema; update any iteration or assertions that consume chartTypes accordingly to preserve behavior.apps/sqlrooms-cli-ui/src/createChartToolDeps.ts (1)
23-26: 💤 Low valueDead defensive check –
getTablesWithColumnsalready guarantees non-empty columns.
getTablesWithColumnsat line 14 filters ontable.columns && table.columns.length > 0, sotable.columnscan never be falsy here. Theif (!table?.columns) return nullguard at line 26 is unreachable.♻️ Suggested cleanup
- if (!table?.columns) return null; - return table.columns.map((column) => ({ + return table.columns!.map((column) => ({ name: column.name, type: column.type, }));🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/sqlrooms-cli-ui/src/createChartToolDeps.ts` around lines 23 - 26, The guard `if (!table?.columns) return null` is redundant because getTablesWithColumns() already filters out empty columns; update the check to only return when the table itself is not found (e.g., replace or remove the columns null-check so you only handle `!table`) in the code around the `getTablesWithColumns(state).find(...)` call in createChartToolDeps.ts; ensure subsequent code uses `table.columns` without additional null guards.packages/mosaic/src/chart-types/box-plot/tool.ts (1)
9-33: ⚡ Quick win
xis required by the schema but neither validated nor handled as optional in title logic.
BoxPlotChartSettings.required()at line 10 strips.optional()from bothxandy, making both requiredstrings. However,xis never passed tovalidateColumnExists, so an invalid column name goes undetected. Additionally, the ternary at line 31 (params.settings.x ?) impliesxis optional, which contradicts the required schema — a non-emptyxstring is always truthy, making theelsebranch unreachable.If
xis intended to be optional for box plots (e.g., single-column distribution with no grouping), omit it from.required()and add a conditional validation:♻️ Suggested fix
export const BoxPlotToolParameters = BaseChartToolParameters.extend({ - settings: BoxPlotChartSettings.required(), + settings: BoxPlotChartSettings.required({y: true}), });And add conditional x-validation after the y check:
validateColumnExists(params.settings.y, NUMERIC_COLUMN_TYPES, columns, 'y'); + if (params.settings.x) { + validateColumnExists(params.settings.x, undefined, columns, 'x'); + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/mosaic/src/chart-types/box-plot/tool.ts` around lines 9 - 33, The schema and title logic disagree: BoxPlotChartSettings was made required (via BoxPlotToolParameters) so params.settings.x is always present, yet createBoxPlotAiTool treats x as optional and never validates it; either make x optional in the schema or validate x when present. Fix by updating BoxPlotToolParameters to not force x (use a settings schema where x is optional) if grouping should be optional, or keep the schema required and call validateColumnExists(params.settings.x, NUMERIC_OR_CATEGORICAL_COLUMN_TYPES, columns, 'x') before building the title; also adjust the title construction in createBoxPlotAiTool to reflect the chosen optional/required semantics (use conditional title only when x is truly optional).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/mosaic/src/chart-types/bubble-chart/schema.ts`:
- Around line 4-9: The optional string fields x, y and size in the Zod schema
currently allow empty strings; update their schema definitions to normalize
empty-string values to undefined so consumers never see '' (e.g., use a
preprocess/transform that maps '' to undefined before validating). Locate the
symbols x, y, and size in the schema.ts Zod object and replace the current
z.string().optional() chains with a z.preprocess or
z.string().optional().transform that returns undefined for '' and preserves
other strings/undefined.
In `@packages/mosaic/src/chart-types/count-plot/schema.ts`:
- Around line 4-7: The count-plot schema declares field as a categorical column
but tool.ts currently validates against QUANTITATIVE_COLUMN_TYPES
(numeric/temporal), which is backwards; fix by changing the validation in
tool.ts for the count-plot to accept categorical columns instead of quantitative
ones—either add a new CATEGORICAL_COLUMN_TYPES constant (e.g., include
nominal/ordinal/string/category types used elsewhere) and validate field against
that, or invert the existing check to ensure the chosen field's type is NOT in
QUANTITATIVE_COLUMN_TYPES; update the validation logic that references
QUANTITATIVE_COLUMN_TYPES so the count-plot only allows categorical columns,
keeping the schema.field (z.string()) unchanged.
---
Outside diff comments:
In `@packages/mosaic/__tests__/ChartSettings.test.tsx`:
- Line 119: Update the test fixture for the 'line-chart' entry so its settings
follow the new multiple-Y-fields schema: replace the single y property with
yFields being an array of YFieldConfig objects (e.g., change settings from {x:
'id', y: 'amount'} to {x: 'id', yFields: [{field: 'amount'}]}), ensuring the
'line-chart' fixture in ChartSettings.test.tsx matches the schema defined for
the line-chart type and exercises multiple Y fields support.
- Around line 16-22: The test fixture for "line-chart" uses the old shape {x:
'id', y: 'amount'}; update it to the new schema by replacing the old y property
with the new yFields array of YFieldConfig objects (e.g., yFields: [{ field:
'amount' }] while keeping the x/xField as appropriate) and ensure the fixture
matches the actual ChartSettings schema; also remove or narrow the settings: any
usage in the test and either import/apply the proper type for settings or use a
type assertion to the chart settings type so the mismatch is caught at compile
time (update references to settings and the "line-chart" fixture and ensure
YFieldConfig is used).
---
Nitpick comments:
In `@apps/sqlrooms-cli-ui/src/createChartToolDeps.ts`:
- Around line 23-26: The guard `if (!table?.columns) return null` is redundant
because getTablesWithColumns() already filters out empty columns; update the
check to only return when the table itself is not found (e.g., replace or remove
the columns null-check so you only handle `!table`) in the code around the
`getTablesWithColumns(state).find(...)` call in createChartToolDeps.ts; ensure
subsequent code uses `table.columns` without additional null guards.
In `@packages/mosaic/__tests__/ChartSettings.test.tsx`:
- Around line 113-116: The chartTypes test fixture declares each item with
settings: any which bypasses compile-time schema checks; update the chartTypes
definition so settings is typed as VgPlotChartConfig['settings'] (or replace the
array with a discriminated-union type keyed by chartType to match per-chart
schemas), e.g. change the array element type to { type:
VgPlotChartConfig['chartType']; settings: VgPlotChartConfig['settings'] } (or
the appropriate union) so TypeScript will error when a fixture's settings no
longer match the chart's schema; update any iteration or assertions that consume
chartTypes accordingly to preserve behavior.
In `@packages/mosaic/src/chart-types/box-plot/tool.ts`:
- Around line 9-33: The schema and title logic disagree: BoxPlotChartSettings
was made required (via BoxPlotToolParameters) so params.settings.x is always
present, yet createBoxPlotAiTool treats x as optional and never validates it;
either make x optional in the schema or validate x when present. Fix by updating
BoxPlotToolParameters to not force x (use a settings schema where x is optional)
if grouping should be optional, or keep the schema required and call
validateColumnExists(params.settings.x, NUMERIC_OR_CATEGORICAL_COLUMN_TYPES,
columns, 'x') before building the title; also adjust the title construction in
createBoxPlotAiTool to reflect the chosen optional/required semantics (use
conditional title only when x is truly optional).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2ccab7dd-4d3c-46b1-bc4a-7dab68669d17
📒 Files selected for processing (31)
apps/sqlrooms-cli-ui/src/createChartToolDeps.tspackages/mosaic/__tests__/ChartSettings.test.tsxpackages/mosaic/__tests__/MosaicDashboardSlice.test.tspackages/mosaic/package.jsonpackages/mosaic/src/chart-builders/ChartBuilderFields.tsxpackages/mosaic/src/chart-builders/ColumnSelector.tsxpackages/mosaic/src/chart-types/box-plot/schema.tspackages/mosaic/src/chart-types/box-plot/tool.tspackages/mosaic/src/chart-types/bubble-chart/schema.tspackages/mosaic/src/chart-types/bubble-chart/tool.tspackages/mosaic/src/chart-types/chart-config.tspackages/mosaic/src/chart-types/count-plot/definition.tspackages/mosaic/src/chart-types/count-plot/schema.tspackages/mosaic/src/chart-types/count-plot/tool.tspackages/mosaic/src/chart-types/ecdf/schema.tspackages/mosaic/src/chart-types/ecdf/tool.tspackages/mosaic/src/chart-types/heatmap/schema.tspackages/mosaic/src/chart-types/heatmap/tool.tspackages/mosaic/src/chart-types/histogram/definition.tspackages/mosaic/src/chart-types/histogram/schema.tspackages/mosaic/src/chart-types/histogram/tool.tspackages/mosaic/src/chart-types/index.tspackages/mosaic/src/chart-types/line-chart/schema.tspackages/mosaic/src/chart-types/line-chart/tool.tspackages/mosaic/src/chart-types/tool-schemas.tspackages/mosaic/src/chart-types/tool-types.tspackages/mosaic/src/chart-types/tool-validation.tspackages/mosaic/src/dashboard/MosaicDashboard.tsxpackages/mosaic/src/dashboard/chart-settings/ChartSettings.tsxpackages/mosaic/src/dashboard/generateMosaicChartSpec.tspackages/mosaic/src/index.ts
✅ Files skipped from review due to trivial changes (2)
- packages/mosaic/package.json
- packages/mosaic/src/chart-types/tool-types.ts
🚧 Files skipped from review as they are similar to previous changes (17)
- packages/mosaic/src/chart-types/histogram/schema.ts
- packages/mosaic/src/chart-types/histogram/definition.ts
- packages/mosaic/src/chart-types/ecdf/tool.ts
- packages/mosaic/src/chart-types/chart-config.ts
- packages/mosaic/src/dashboard/chart-settings/ChartSettings.tsx
- packages/mosaic/src/chart-builders/ColumnSelector.tsx
- packages/mosaic/src/chart-types/histogram/tool.ts
- packages/mosaic/src/chart-types/heatmap/tool.ts
- packages/mosaic/src/chart-builders/ChartBuilderFields.tsx
- packages/mosaic/src/dashboard/generateMosaicChartSpec.ts
- packages/mosaic/src/chart-types/count-plot/tool.ts
- packages/mosaic/src/dashboard/MosaicDashboard.tsx
- packages/mosaic/src/chart-types/bubble-chart/tool.ts
- packages/mosaic/src/index.ts
- packages/mosaic/src/chart-types/count-plot/definition.ts
- packages/mosaic/src/chart-types/index.ts
- packages/mosaic/src/chart-types/line-chart/tool.ts
…initions and specifications
…ization and remove deprecated type in tool-types
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
…initions - Removed centralized icon mapping from `chart-builders/builders.ts`. - Updated `ChartTypeDefinition` to include an optional `icon` property. - Modified individual chart definitions to specify their icons directly. - Simplified chart builder creation by utilizing the new icon property. - Ensured backward compatibility by maintaining existing APIs and behaviors. - Removed deprecated types and functions related to previous chart builder structure. - Updated all relevant components to use the new chart type definitions and icon handling.
… for consistency Co-authored-by: Copilot <[email protected]>
…aicDashboardSlice
Summary by CodeRabbit
New Features
Bug Fixes
UI/UX Improvements