Skip to content

feat: enhanced dasboard creation - #651

Merged
dmitriy-kostianetskiy merged 10 commits into
mainfrom
feat/data-table-selector
May 21, 2026
Merged

dmitriy-kostianetskiy merged 10 commits into
mainfrom
feat/data-table-selector

Conversation

@dmitriy-kostianetskiy

@dmitriy-kostianetskiy dmitriy-kostianetskiy commented May 21, 2026 •

Copy link
Copy Markdown
Collaborator
image

Summary by CodeRabbit

  • New Features

    • AI-powered "Analyze with AI" dashboard flow and a "Start" action for dashboard analysis
    • Map settings UI with latitude/longitude selectors and improved Add-panel dropdown
    • New initial dashboard creation: create manually or generate with AI
    • Reset filters button in dashboard toolbar
  • Improvements

    • More reliable coordinate detection for map visualizations
    • Smarter panel add/availability logic and profiler de-duplication behavior

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 21, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 22194f95-dd1f-4f8a-970a-9938cd1e559b

📥 Commits

Reviewing files that changed from the base of the PR and between f453976 and 2c26a5a.

📒 Files selected for processing (22)
  • apps/sqlrooms-cli-ui/src/createArtifactContextAiTools.ts
  • packages/deck/__tests__/dashboard.test.ts
  • packages/mosaic/src/ai.ts
  • packages/mosaic/src/chart-types/base-types.ts
  • packages/mosaic/src/chart-types/profiler-tool.ts
  • packages/mosaic/src/chart-types/remove-panel-tool.ts
  • packages/mosaic/src/chart-types/text-panel-tool.ts
  • packages/mosaic/src/chart-types/tool-helpers.ts
  • packages/mosaic/src/chart/addChartPanelAction.ts
  • packages/mosaic/src/dashboard/MosaicDashboardContext.tsx
  • packages/mosaic/src/dashboard/MosaicDashboardPanelHeader.tsx
  • packages/mosaic/src/dashboard/MosaicDashboardSlice.ts
  • packages/mosaic/src/dashboard/action-types.ts
  • packages/mosaic/src/dashboard/core-types.ts
  • packages/mosaic/src/dashboard/dashboard-types.ts
  • packages/mosaic/src/dashboard/defaultPanelActions.ts
  • packages/mosaic/src/dashboard/initial-state/MosaicDashboardInitialState.tsx
  • packages/mosaic/src/dashboard/useAddPanelActions.ts
  • packages/mosaic/src/dashboard/useMosaicDashboardAddPanelActionContext.ts
  • packages/mosaic/src/index.ts
  • packages/mosaic/src/profiler/addProfilerPanelAction.ts
  • packages/mosaic/src/text/addTextPanelAction.ts
💤 Files with no reviewable changes (2)
  • apps/sqlrooms-cli-ui/src/createArtifactContextAiTools.ts
  • packages/mosaic/src/dashboard/MosaicDashboardPanelHeader.tsx
✅ Files skipped from review due to trivial changes (5)
  • packages/mosaic/src/dashboard/MosaicDashboardContext.tsx
  • packages/mosaic/src/chart-types/remove-panel-tool.ts
  • packages/mosaic/src/chart-types/text-panel-tool.ts
  • packages/mosaic/src/ai.ts
  • packages/mosaic/src/dashboard/dashboard-types.ts

📝 Walkthrough

Walkthrough

Adds a pluggable dashboard add-panel action system, deck map utilities and UI for configuring lon/lat columns, centralizes column metadata via ColumnsContext, provides initial-state AI/manual dashboard builders, decouples panel source wiring, and introduces AiSlice.startNewSession plus CLI/store wiring updates.

Changes

Dashboard Panel Refactor and AI Integration

Layer / File(s) Summary
Deck map utilities and interactive settings
packages/deck/src/mapConfigUtils.ts, packages/deck/src/LatitudeSelector.tsx, packages/deck/src/LongitudeSelector.tsx, packages/deck/src/MapSettings.tsx, packages/deck/src/dashboard.tsx, packages/deck/src/index.ts
Adds map config utilities (findLongitudeLatitudeColumns, regenerateMapConfigForTable), latitude/longitude selectors, Map settings UI, integrates settingsOpen into panel config, and updates Deck renderer to compose map + settings.
ColumnsContext and chart builder refactor
packages/mosaic/src/chart-builders/ColumnsContext.tsx, packages/mosaic/src/chart-builders/ColumnSelector.tsx, packages/mosaic/src/chart-builders/MultiFieldSelector.tsx, packages/mosaic/src/chart/chart-settings/ChartSettingsContext.tsx, packages/mosaic/src/chart/chart-settings/ChartSettings.tsx, packages/mosaic/src/chart/chart-settings/ChartTypeSelector.tsx, packages/mosaic/src/chart-types/line-chart/LineChartSettings.tsx
Introduces ColumnsProvider/useColumnsContext and refactors chart builders/settings to source columns from context instead of prop drilling; simplifies some selector UIs.
Add-panel action types and hooks
packages/mosaic/src/dashboard/action-types.ts, packages/mosaic/src/dashboard/useAddPanelActions.ts, packages/mosaic/src/dashboard/useMosaicDashboardAddPanelActionContext.ts
Defines MosaicDashboardAddPanelAction and MosaicDashboardAddPanelActionContext types, and implements hooks to evaluate action enablement and create/add panels for a given dashboard.
Default panel actions and creators
packages/mosaic/src/dashboard/defaultPanelActions.ts, packages/mosaic/src/chart/addChartPanelAction.ts, packages/mosaic/src/profiler/addProfilerPanelAction.ts, packages/mosaic/src/text/addTextPanelAction.ts
Adds action creator modules for Chart/Profiler/Text and exports defaultAddPanelActions array.
Dashboard initial state with AI and manual flows
packages/mosaic/src/dashboard/initial-state/MosaicDashboardInitialState.tsx, packages/mosaic/src/dashboard/initial-state/BuildDashboardWithAIPanel.tsx, packages/mosaic/src/dashboard/initial-state/BuildDashboardManuallyPanel.tsx
Adds initial-state UI with two builders: AI prompt-based onStart flow and manual table-based profiler creation; shares isStarting state.
Toolbar decomposition and empty-state wiring
packages/mosaic/src/dashboard/toolbar/MosaicDashboardToolbar.tsx, packages/mosaic/src/dashboard/toolbar/MosaicDashboardAddPanelDropdown.tsx, packages/mosaic/src/dashboard/toolbar/MosaicDashboardResetFiltersButton.tsx, packages/mosaic/src/dashboard/MosaicDashboardEmptyState.tsx
Splits toolbar into modular components; empty state derives add-panel buttons from useAddPanelActions.
Table selection hooks and selector
packages/mosaic/src/dashboard/useTablesWithColumns.ts, packages/mosaic/src/dashboard/useSelectedOrFirstTable.ts, packages/mosaic/src/chart-builders/TableSelector.tsx
Adds hooks to list tables with columns and pick last-selected-or-first-table; adds TableSelector UI.
Remove per-panel source; renderer updates
packages/mosaic/src/dashboard/MosaicDashboardPanel.tsx, packages/mosaic/src/dashboard/MosaicDashboardPanelHeader.tsx, packages/mosaic/src/chart/MosaicDashboardChartRenderer.tsx, packages/mosaic/src/profiler/MosaicDashboardProfilerPanelRenderer.tsx, packages/mosaic/src/chart-types/tool-helpers.ts
Removes panel.source usage and related helpers; chart/profiler renderers now use dashboard.selectedTable; panel header uses selectionName.
Mosaic dashboard slice types and factories
packages/mosaic/src/dashboard/MosaicDashboardSlice.ts
Reworks slice to declare panel-type constants and Zod schemas, replaces generic factory with typed create*PanelConfig functions (no source param), and adds lastSelectedTable + setLastSelectedTable.
Dashboard root and panels integration
packages/mosaic/src/dashboard/MosaicDashboard.tsx, packages/mosaic/src/dashboard/MosaicDashboardContext.tsx, packages/mosaic/src/dashboard/MosaicDashboardPanels.tsx
Threads optional onStart through dashboard context, switches to useSelectedOrFirstTable, and renders MosaicDashboardInitialState when empty.
Deck map dashboard rendering and config typing
packages/deck/src/dashboardConfig.ts, packages/deck/src/dashboard.tsx
Updates dashboardConfig to inline source type and settingsOpen; Deck renderer composes map + settings, computes datasets inline, and overlays dataset load errors.
CLI UI store: deck map and panel actions
apps/sqlrooms-cli-ui/src/store.ts
Imports deck helper and mosaic default actions; uses findLongitudeLatitudeColumns, returns empty deck map config when coords missing, removes deckMap enable predicate, adjusts profiler dedupe logic, and appends ...defaultAddPanelActions.
AI slice session API and DashboardArtifact
packages/ai-core/src/AiSlice.ts, apps/sqlrooms-cli-ui/src/workspace/dashboard/DashboardArtifact.tsx, apps/sqlrooms-cli-ui/src/createArtifactContextAiTools.ts
Adds startNewSession(name, prompt) that creates session, sets prompt, polls for chat readiness, and starts analysis; DashboardArtifact uses it to start dashboard analysis sessions and artifact read logic omits legacy panel.source.
Tests: deck map serialization & source resolution
packages/deck/__tests__/dashboard.test.ts
Adjusts tests to expect inline dataset source in serialized configs and adds assertions covering dataset-vs-dashboard source resolution priority.
Package entrypoint updates
packages/deck/src/index.ts, packages/mosaic/src/index.ts
Re-exports deck map utilities; expands mosaic exports to include default add actions, initial-state, hooks, chart-builder components, and core-types while removing deprecated source helpers.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • sqlrooms/sqlrooms#649: Both PRs modify packages/ai-core/src/AiSlice.ts to change AI session creation/start behavior.
  • sqlrooms/sqlrooms#622: Adds text panel support surfaced via the new panel action system and default add actions.
  • sqlrooms/sqlrooms#634: Registers/extends the dashboard_agent tool referenced by the dashboard AI start flow.

Suggested labels

codex

Suggested reviewers

  • ilyabo

Poem

🐰 A Rabbit's Ode to Dashboard Action
Panels sprout like clover, tidy and bright,
Columns find their places, morning to night.
AI wakes a session with a curious cheer,
Maps redraw their settings when selectors appear.
Hooray — the dashboard hops forward, brave and light!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/data-table-selector

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

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/MosaicDashboardContext.tsx (1)

2-12: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Break the context ↔ initial-state import cycle.

Line 2 introduces a dependency that is already failing CI with a circular import chain. Move the onStart callback type into a neutral shared type module (e.g., under dashboard/types) and import that type from both sides instead of importing from MosaicDashboardInitialState.

As per coding guidelines, "Keep the compound context layer thin and stable. Avoid turning a compound provider into a second state system; it should usually wrap an existing hook/store API rather than replace it".

🤖 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/MosaicDashboardContext.tsx` around lines 2 -
12, MosaicDashboardContextValue currently imports
MosaicDashboardInitialStateProps to reference onStart, creating a circular
import; extract the onStart callback type into a neutral shared type (e.g.,
create a new export like DashboardTypes or dashboard/types that declares OnStart
type) and update both MosaicDashboardContextValue and
MosaicDashboardInitialState to import that shared OnStart type instead of
importing MosaicDashboardInitialStateProps; ensure the exported type name is
used in the existing context type (onStart?: OnStart) and in the initial-state
file to break the cycle and keep the context layer thin.
🧹 Nitpick comments (3)
packages/mosaic/src/chart-builders/TableSelector.tsx (1)

17-22: ⚡ Quick win

Remove or implement the required prop contract.

required is exposed in the public props but has no effect in rendering or behavior, which makes the API misleading.

Proposed cleanup
 export interface TableSelectorProps {
   value: string | undefined;
   onChange?: (tableName: string) => void;
   placeholder?: string;
-  required?: boolean;
 }
🤖 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-builders/TableSelector.tsx` around lines 17 - 22,
The TableSelectorProps exposes a required?: boolean that is never used; remove
the misleading prop from the public contract by deleting required from the
TableSelectorProps interface and any related defaultProps/prop spreads, and
update the TableSelector component signature (and any places that pass required)
to stop accepting it; run and fix any consumer call sites or tests that
referenced it. If you prefer to keep behavior instead, implement it by passing
the prop into the underlying form control (e.g., the <select> or input inside
TableSelector) as the HTML required attribute and optionally render a visual
required marker, but do one consistent change across TableSelector, its props
interface, and all consumers.
packages/mosaic/src/chart/chart-settings/ChartTypeSelector.tsx (1)

33-35: ⚡ Quick win

Add an explicit accessible name to the trigger.

After removing the wrapper label, provide a guaranteed control name on the trigger (aria-label or aria-labelledby) to avoid unlabeled-select scenarios.

Suggested diff
-        <SelectTrigger className="h-8 text-xs">
+        <SelectTrigger className="h-8 text-xs" aria-label="Chart 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 `@packages/mosaic/src/chart/chart-settings/ChartTypeSelector.tsx` around lines
33 - 35, ChartTypeSelector's SelectTrigger is missing an accessible name after
the wrapper label was removed, causing an unlabeled select; add a guaranteed
accessible name by adding an aria-label or aria-labelledby to the SelectTrigger
element (e.g., in the SelectTrigger JSX inside ChartTypeSelector) so the
dropdown control is always announced by screen readers—use a clear string like
"Chart type" or point aria-labelledby to an existing visible label element if
present.
packages/mosaic/src/chart-builders/ColumnsContext.tsx (1)

30-38: ⚡ Quick win

Memoize the context value to keep provider updates stable.

value={{columns, tableName}} creates a new object every render and can force unnecessary rerenders in all consumers.

Suggested diff
 import {
   createContext,
   useContext,
+  useMemo,
   type FC,
   type PropsWithChildren,
 } from 'react';
@@
 export const ColumnsProvider: FC<ColumnsProviderProps> = ({
   columns,
   tableName,
   children,
 }) => {
+  const value = useMemo(() => ({columns, tableName}), [columns, tableName]);
   return (
-    <ColumnsContext.Provider value={{columns, tableName}}>
+    <ColumnsContext.Provider value={value}>
       {children}
     </ColumnsContext.Provider>
   );
 };

As per coding guidelines, "Keep the compound context layer thin and stable. Avoid turning a compound provider into a second state system; it should usually wrap an existing hook/store API rather than replace it".

🤖 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-builders/ColumnsContext.tsx` around lines 30 - 38,
ColumnsProvider is passing value={{columns, tableName}} directly which recreates
the object each render and can trigger unnecessary consumer rerenders; wrap the
context value in useMemo (e.g., memoize {columns, tableName} with deps [columns,
tableName]) and pass that memoized value to ColumnsContext.Provider in the
ColumnsProvider component to keep provider updates stable.
🤖 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/ai-core/src/AiSlice.ts`:
- Around line 1116-1140: The hardcoded setTimeout in startNewSession causes race
conditions; replace it with a readiness-based wait that proceeds only when the
session's chat provider has registered its sendMessage handler (or an equivalent
"chat ready" flag). Locate startNewSession and remove the
setTimeout/tryStartAnalysis pattern; instead implement a short-polling loop or
awaitable event that checks the newly created session (via
get().ai.getCurrentSession() or get().ai.getSession(session.id)) until the
chat/sendMessage registration is present (or until a reasonable timeout), then
call get().ai.startAnalysis(session.id); ensure you reference the session.id and
the chat registration check (e.g., session.chatProvider?.sendMessage or a new
get().ai.isChatReady(session.id)) so startup is deterministic.

In `@packages/deck/src/LatitudeSelector.tsx`:
- Around line 27-36: The handler in LatitudeSelector (handleChange) currently
returns early if currentLongitudeColumn is falsy, preventing initializing
latitude first; remove that early return and let the function call
regenerateMapConfigForTable(panel, currentTable, currentLongitudeColumn,
latitudeColumn) even when currentLongitudeColumn is undefined so users can set
the first coordinate, matching the mirrored behavior in LongitudeSelector;
ensure state update flow that follows this call remains the same so the new
config is applied when either coordinate is set first.

In `@packages/deck/src/mapConfigUtils.ts`:
- Around line 55-92: The function currently returns a brand-new config that
replaces panel.config and discards existing map-level settings; instead
merge/retain existing panel.config and its nested spec fields when regenerating
coordinates: obtain the current config (panel.config), spread it into the
returned object and merge/override only the specific keys you must change
(spec.initialViewState and spec.layers, datasets[datasetId], fitToData) while
preserving properties like mapStyle, mapProps, showLegends, interaction; update
the logic around the returned object (the block creating spec, datasets and
fitToData) to shallow-merge with existing config and spec rather than replacing
them wholesale.

In `@packages/mosaic/src/chart/addChartPanelAction.ts`:
- Around line 12-16: The createPanel implementation currently hard-codes
'histogram' as the initial chartType, which can be invalid; change createPanel
to read the available chartTypes from the action context (the same context used
by isEnabled) and pick a valid initial value (e.g., chartTypes[0] or a
configured default) before calling createMosaicDashboardChartPanelConfig so the
new panel's chartType is always one of the provided chartTypes; update
references to isEnabled, createPanel, and createMosaicDashboardChartPanelConfig
accordingly to use the derived chartType.

In `@packages/mosaic/src/dashboard/initial-state/BuildDashboardManuallyPanel.tsx`:
- Around line 30-34: Add an early-return guard that checks the current
isStarting flag at the top of handleStart (and the analogous handler around
lines 52-59) so the function exits immediately if a manual start is already in
progress; specifically, in BuildDashboardManuallyPanel update handleStart to
return if isStarting is true before calling onStartingChange(true) or running
the try block, and do the same guard for the other manual-creation handler,
referencing the isStarting prop/state and onStartingChange callback to prevent
duplicate submissions.

In `@packages/mosaic/src/dashboard/initial-state/BuildDashboardWithAIPanel.tsx`:
- Around line 16-27: handleStart can be invoked re-entrantly (e.g., via
keyboard) before the UI blocks input; add a guard that prevents multiple
concurrent starts by tracking an "in-progress" flag. Modify handleStart to
return immediately if a local isStarting boolean/ref is true, set it true before
awaiting onStart(prompt) and only clear it in the finally block (alongside
calling onStartingChange(false)); reference the existing symbols handleStart,
prompt, onStart, onStartingChange and use a local ref or state (e.g.,
isStartingRef) so rapid repeated calls are ignored.

In `@packages/mosaic/src/dashboard/initial-state/MosaicDashboardInitialState.tsx`:
- Around line 19-21: Update the user-facing subtitle copy in the
MosaicDashboardInitialState component: replace the <p> text content "Choose how
would you like to start" with the corrected phrasing "Choose how you'd like to
start" (the <p> element using className "text-muted-foreground text-sm"). Ensure
the change is made in MosaicDashboardInitialState.tsx so the displayed string is
updated in the rendered JSX.

In `@packages/mosaic/src/dashboard/MosaicDashboard.tsx`:
- Around line 89-93: The guard for enabling chart creation incorrectly treats
chartTypes undefined as truthy because `chartTypes?.length !== 0` is true when
chartTypes is undefined; update the condition in the `canCreateChart`
calculation(s) so undefined yields false (for example replace
`chartTypes?.length !== 0` with `(chartTypes?.length ?? 0) !== 0` or
`Array.isArray(chartTypes) && chartTypes.length > 0`). Apply the same change to
the other occurrence referenced (the second `canCreateChart` occurrence) and
keep references to `selectedTableInfo`, `panelRenderers`, and
`MOSAIC_DASHBOARD_CHART_PANEL_TYPE` intact.

In `@packages/mosaic/src/dashboard/MosaicDashboardSlice.ts`:
- Around line 35-36: MosaicDashboardSlice.ts currently imports
MosaicDashboardAddPanelAction types creating a circular dependency; extract the
shared action/context types used by both MosaicDashboardSlice and
MosaicDashboardAddPanelAction into a new leaf module (e.g.,
MosaicDashboard.types.ts), update both files to import those types from that new
module, and remove any direct imports from MosaicDashboardAddPanelAction in
MosaicDashboardSlice (and vice versa) so the slice and add-panel files no longer
reference each other directly.

---

Outside diff comments:
In `@packages/mosaic/src/dashboard/MosaicDashboardContext.tsx`:
- Around line 2-12: MosaicDashboardContextValue currently imports
MosaicDashboardInitialStateProps to reference onStart, creating a circular
import; extract the onStart callback type into a neutral shared type (e.g.,
create a new export like DashboardTypes or dashboard/types that declares OnStart
type) and update both MosaicDashboardContextValue and
MosaicDashboardInitialState to import that shared OnStart type instead of
importing MosaicDashboardInitialStateProps; ensure the exported type name is
used in the existing context type (onStart?: OnStart) and in the initial-state
file to break the cycle and keep the context layer thin.

---

Nitpick comments:
In `@packages/mosaic/src/chart-builders/ColumnsContext.tsx`:
- Around line 30-38: ColumnsProvider is passing value={{columns, tableName}}
directly which recreates the object each render and can trigger unnecessary
consumer rerenders; wrap the context value in useMemo (e.g., memoize {columns,
tableName} with deps [columns, tableName]) and pass that memoized value to
ColumnsContext.Provider in the ColumnsProvider component to keep provider
updates stable.

In `@packages/mosaic/src/chart-builders/TableSelector.tsx`:
- Around line 17-22: The TableSelectorProps exposes a required?: boolean that is
never used; remove the misleading prop from the public contract by deleting
required from the TableSelectorProps interface and any related defaultProps/prop
spreads, and update the TableSelector component signature (and any places that
pass required) to stop accepting it; run and fix any consumer call sites or
tests that referenced it. If you prefer to keep behavior instead, implement it
by passing the prop into the underlying form control (e.g., the <select> or
input inside TableSelector) as the HTML required attribute and optionally render
a visual required marker, but do one consistent change across TableSelector, its
props interface, and all consumers.

In `@packages/mosaic/src/chart/chart-settings/ChartTypeSelector.tsx`:
- Around line 33-35: ChartTypeSelector's SelectTrigger is missing an accessible
name after the wrapper label was removed, causing an unlabeled select; add a
guaranteed accessible name by adding an aria-label or aria-labelledby to the
SelectTrigger element (e.g., in the SelectTrigger JSX inside ChartTypeSelector)
so the dropdown control is always announced by screen readers—use a clear string
like "Chart type" or point aria-labelledby to an existing visible label element
if present.
🪄 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: 6e994cb5-b287-45c6-8a0e-fc90a5bdefc0

📥 Commits

Reviewing files that changed from the base of the PR and between 6f16ee5 and 95ad2df.

📒 Files selected for processing (46)
  • apps/sqlrooms-cli-ui/src/store.ts
  • apps/sqlrooms-cli-ui/src/workspace/dashboard/DashboardArtifact.tsx
  • packages/ai-core/src/AiSlice.ts
  • packages/deck/src/LatitudeSelector.tsx
  • packages/deck/src/LongitudeSelector.tsx
  • packages/deck/src/MapSettings.tsx
  • packages/deck/src/dashboard.tsx
  • packages/deck/src/dashboardConfig.ts
  • packages/deck/src/index.ts
  • packages/deck/src/mapConfigUtils.ts
  • packages/mosaic/src/chart-builders/ColumnSelector.tsx
  • packages/mosaic/src/chart-builders/ColumnsContext.tsx
  • packages/mosaic/src/chart-builders/MultiFieldSelector.tsx
  • packages/mosaic/src/chart-builders/TableSelector.tsx
  • packages/mosaic/src/chart-types/line-chart/LineChartSettings.tsx
  • packages/mosaic/src/chart-types/tool-helpers.ts
  • packages/mosaic/src/chart/MosaicDashboardChartRenderer.tsx
  • packages/mosaic/src/chart/addChartPanelAction.ts
  • packages/mosaic/src/chart/chart-settings/ChartSettings.tsx
  • packages/mosaic/src/chart/chart-settings/ChartSettingsContext.tsx
  • packages/mosaic/src/chart/chart-settings/ChartTypeSelector.tsx
  • packages/mosaic/src/dashboard/MosaicDashboard.tsx
  • packages/mosaic/src/dashboard/MosaicDashboardAddPanelAction.ts
  • packages/mosaic/src/dashboard/MosaicDashboardContext.tsx
  • packages/mosaic/src/dashboard/MosaicDashboardEmptyState.tsx
  • packages/mosaic/src/dashboard/MosaicDashboardPanel.tsx
  • packages/mosaic/src/dashboard/MosaicDashboardPanelHeader.tsx
  • packages/mosaic/src/dashboard/MosaicDashboardPanels.tsx
  • packages/mosaic/src/dashboard/MosaicDashboardSlice.ts
  • packages/mosaic/src/dashboard/MosaicDashboardToolbar.tsx
  • packages/mosaic/src/dashboard/defaultPanelActions.ts
  • packages/mosaic/src/dashboard/initial-state/BuildDashboardManuallyPanel.tsx
  • packages/mosaic/src/dashboard/initial-state/BuildDashboardWithAIPanel.tsx
  • packages/mosaic/src/dashboard/initial-state/MosaicDashboardInitialState.tsx
  • packages/mosaic/src/dashboard/toolbar/MosaicDashboardAddPanelDropdown.tsx
  • packages/mosaic/src/dashboard/toolbar/MosaicDashboardResetFiltersButton.tsx
  • packages/mosaic/src/dashboard/toolbar/MosaicDashboardToolbar.tsx
  • packages/mosaic/src/dashboard/useAddPanelActions.ts
  • packages/mosaic/src/dashboard/useMosaicDashboardAddPanelActionContext.ts
  • packages/mosaic/src/dashboard/useSelectedOrFirstTable.ts
  • packages/mosaic/src/dashboard/useTablesWithColumns.ts
  • packages/mosaic/src/index.ts
  • packages/mosaic/src/profiler/MosaicDashboardProfilerPanelRenderer.tsx
  • packages/mosaic/src/profiler/addProfilerPanelAction.ts
  • packages/mosaic/src/text/addTextPanelAction.ts
  • packages/ui/src/components/tree.tsx
💤 Files with no reviewable changes (3)
  • packages/mosaic/src/dashboard/MosaicDashboardToolbar.tsx
  • packages/mosaic/src/dashboard/MosaicDashboardPanel.tsx
  • packages/mosaic/src/chart-types/tool-helpers.ts

Comment thread packages/ai-core/src/AiSlice.ts
Comment thread packages/deck/src/LatitudeSelector.tsx
Comment thread packages/deck/src/mapConfigUtils.ts
Comment thread packages/mosaic/src/chart/addChartPanelAction.ts
Comment thread packages/mosaic/src/dashboard/initial-state/BuildDashboardWithAIPanel.tsx Outdated
Comment thread packages/mosaic/src/dashboard/MosaicDashboard.tsx
Comment thread packages/mosaic/src/dashboard/MosaicDashboardSlice.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
packages/ai-core/src/AiSlice.ts (1)

1149-1177: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

startNewSession resolves before startup actually completes.

This code fire-and-forgets readiness polling (void ...) and uses timer recursion, so awaiting startNewSession does not wait for analysis start/timeout. That can desync UI isStarting flows and error handling.

Proposed fix
-          const waitForChatReadyAndStart = async (): Promise<void> => {
-            const maxAttempts = 50; // 50 * 20ms = 1 second max
-            let attempts = 0;
-
-            const checkAndStart = async () => {
-              const sendMessage = get().ai.getChatSendMessage(session.id);
-              if (sendMessage) {
-                // Chat provider is ready, start analysis
-                await get().ai.startAnalysis(session.id);
-                return;
-              }
-
-              attempts++;
-              if (attempts >= maxAttempts) {
-                console.error(
-                  'Timeout waiting for chat provider to register for session:',
-                  session.id,
-                );
-                return;
-              }
-
-              // Poll again after a short delay
-              setTimeout(checkAndStart, 20);
-            };
-
-            await checkAndStart();
-          };
-
-          void waitForChatReadyAndStart();
+          const waitForChatReadyAndStart = async (): Promise<void> => {
+            const maxAttempts = 50; // 50 * 20ms = 1 second max
+            for (let attempts = 0; attempts < maxAttempts; attempts++) {
+              if (get().ai.getChatSendMessage(session.id)) {
+                await get().ai.startAnalysis(session.id);
+                return;
+              }
+              await new Promise((resolve) => setTimeout(resolve, 20));
+            }
+
+            console.error(
+              'Timeout waiting for chat provider to register for session:',
+              session.id,
+            );
+          };
+
+          await waitForChatReadyAndStart();
🤖 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/ai-core/src/AiSlice.ts` around lines 1149 - 1177, The readiness poll
in waitForChatReadyAndStart currently fire-and-forgets (void ...) and uses timer
recursion so startNewSession returns before analysis starts; change
waitForChatReadyAndStart into an awaitable Promise<void> and convert the
recursive setTimeout into an async polling loop (e.g., while loop with await
delay) that checks get().ai.getChatSendMessage(session.id) up to maxAttempts and
then either awaits get().ai.startAnalysis(session.id) or resolves/rejects on
timeout; then replace the void call with await waitForChatReadyAndStart() in
startNewSession so callers only proceed when startAnalysis has completed or
timed out.
🤖 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.

Duplicate comments:
In `@packages/ai-core/src/AiSlice.ts`:
- Around line 1149-1177: The readiness poll in waitForChatReadyAndStart
currently fire-and-forgets (void ...) and uses timer recursion so
startNewSession returns before analysis starts; change waitForChatReadyAndStart
into an awaitable Promise<void> and convert the recursive setTimeout into an
async polling loop (e.g., while loop with await delay) that checks
get().ai.getChatSendMessage(session.id) up to maxAttempts and then either awaits
get().ai.startAnalysis(session.id) or resolves/rejects on timeout; then replace
the void call with await waitForChatReadyAndStart() in startNewSession so
callers only proceed when startAnalysis has completed or timed out.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e10ce121-f9d7-44ae-8fc1-e0b072601ad9

📥 Commits

Reviewing files that changed from the base of the PR and between 95ad2df and f453976.

📒 Files selected for processing (23)
  • apps/sqlrooms-cli-ui/src/store.ts
  • packages/ai-core/src/AiSlice.ts
  • packages/deck/src/LatitudeSelector.tsx
  • packages/deck/src/mapConfigUtils.ts
  • packages/mosaic/src/chart-builders/ColumnsContext.tsx
  • packages/mosaic/src/chart-builders/TableSelector.tsx
  • packages/mosaic/src/chart/addChartPanelAction.ts
  • packages/mosaic/src/chart/chart-settings/ChartTypeSelector.tsx
  • packages/mosaic/src/dashboard/MosaicDashboard.tsx
  • packages/mosaic/src/dashboard/MosaicDashboardContext.tsx
  • packages/mosaic/src/dashboard/MosaicDashboardSlice.ts
  • packages/mosaic/src/dashboard/dashboard-types.ts
  • packages/mosaic/src/dashboard/defaultPanelActions.ts
  • packages/mosaic/src/dashboard/initial-state/BuildDashboardManuallyPanel.tsx
  • packages/mosaic/src/dashboard/initial-state/BuildDashboardWithAIPanel.tsx
  • packages/mosaic/src/dashboard/initial-state/MosaicDashboardInitialState.tsx
  • packages/mosaic/src/dashboard/toolbar/MosaicDashboardResetFiltersButton.tsx
  • packages/mosaic/src/dashboard/toolbar/MosaicDashboardToolbar.tsx
  • packages/mosaic/src/dashboard/useAddPanelActions.ts
  • packages/mosaic/src/dashboard/useMosaicDashboardAddPanelActionContext.ts
  • packages/mosaic/src/index.ts
  • packages/mosaic/src/profiler/addProfilerPanelAction.ts
  • packages/mosaic/src/text/addTextPanelAction.ts
💤 Files with no reviewable changes (2)
  • packages/mosaic/src/chart-builders/TableSelector.tsx
  • packages/deck/src/LatitudeSelector.tsx

@dmitriy-kostianetskiy
dmitriy-kostianetskiy merged commit f3f0b9e into main May 21, 2026
4 checks passed
@dmitriy-kostianetskiy
dmitriy-kostianetskiy deleted the feat/data-table-selector branch May 21, 2026 10:32
@coderabbitai coderabbitai Bot mentioned this pull request May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants