Repository navigation
feat: reset filters in worksheets and block captions - #690
Conversation
…panels Co-authored-by: Copilot <[email protected]>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds panel- and dashboard-scoped filter-reset hooks and UI, refactors chart spec creators to take a CreateSpecOptions object (including selectionName), threads dashboard/panel context and client registration into chart rendering, decomposes the data-table-explorer into focused hooks and lifecycle wiring, introduces a Popover-based Combobox and migrates selectors, and applies UI/typing polish. ChangesMain cohort
Estimated code review effort:
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
packages/deck/src/dashboard.tsx (1)
129-130: ⚡ Quick winStabilize clients array to avoid unnecessary effect re-runs.
The inline array creation (
client ? [client] : []) produces a new reference on every render, causingusePanelClientRegistration's effect to re-run and unregister/re-register the client repeatedly. While the registration operations are idempotent, this is wasteful.⚡ Proposed fix to memoize the clients array
+ const panelClients = useMemo(() => client ? [client] : [], [client]); // Register client for panel reset button - usePanelClientRegistration(dashboard.id, panel.id, client ? [client] : []); + usePanelClientRegistration(dashboard.id, panel.id, panelClients);🤖 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/deck/src/dashboard.tsx` around lines 129 - 130, The clients array passed to usePanelClientRegistration is recreated each render causing its effect to re-run; fix by memoizing the array before calling usePanelClientRegistration (e.g. create a stable "clients" value derived from "client" using useMemo or a ref) and pass that memoized "clients" into usePanelClientRegistration(dashboard.id, panel.id, clients) so the reference only changes when "client" actually changes.packages/mosaic/src/dashboard/MosaicDashboardSlice.ts (1)
983-1007: 💤 Low valueConsider consolidating state updates for efficiency.
The
removePanelmethod performs three separate state updates: deleting the panel clients entry, evicting panel runtime, and removing the panel from config. While this is functionally correct, combining these into a single state update would reduce intermediate renders and improve performance.🤖 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 983 - 1007, The code does three separate state updates in removePanel—deleting mosaicDashboard.runtime.panelClients[key], calling get().mosaicDashboard.evictPanelRuntime(dashboardId, panelId), and updating the dashboards config (dashboard.panels, dashboard.layout, dashboard.updatedAt); consolidate the two direct state mutations into a single set(produce(...)) call to avoid intermediate renders by: build one produce block that deletes state.mosaicDashboard.runtime.panelClients[getMosaicDashboardPanelId(dashboardId, panelId)] and updates the corresponding dashboard (filter panels, call removePanelFromLayout, set updatedAt) in the same draft, and keep get().mosaicDashboard.evictPanelRuntime(dashboardId, panelId) as an external side-effect call (before or after the combined set) so runtime eviction still runs but state mutations happen atomically.
🤖 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/dashboard/toolbar/MosaicDashboardAddPanelDropdown.tsx`:
- Around line 30-36: The icon-only add-panel Button in
MosaicDashboardAddPanelDropdown.tsx lacks an accessible name; update the Button
(the one rendering <Plus /> inside) to provide an explicit accessible label
(e.g., add aria-label="Add panel" or aria-label based on localized text) or hook
it to a visually hidden text/aria-labelledby so assistive tech can announce it;
ensure the label string is descriptive and, if applicable, uses existing
i18n/localization utilities in the component.
In
`@packages/mosaic/src/data-table-explorer/dashboard/MosaicDashboardDataTableExplorerPanelRenderer.tsx`:
- Around line 31-35: The code calls useDataTableExplorer with a non-null
asserted selectedTable (selectedTable!) which can be undefined; change the call
to pass selectedTable (no !) so tableName can be undefined, and update the hook
useDataTableExplorer (and downstream helpers it uses) to accept tableName?:
string and return a safe no-op explorer state when tableName is undefined (e.g.,
empty data, loading=false, no-op selection handlers) so the component can render
safely; alternatively, if you prefer not to change the hook, move rendering of
MosaicDashboardDataTableExplorerPanelRenderer up so it is not mounted when
selectedTable is falsy, but do not use a non-null assertion inside this
component.
In
`@packages/mosaic/src/data-table-explorer/hooks/useDataTableExplorerSelection.ts`:
- Around line 53-61: The hook creates fallbackSelection eagerly causing
selection identity to change once existingSelection is registered; update
useDataTableExplorerSelection to either (A) stop creating an immediate
fallbackSelection and let selection be providedSelection ?? existingSelection ??
MosaicSelection.crossfilter() inline so the effect's getSelection call supplies
the same instance, or (B) if the store API allows, synchronously obtain/register
the selection by calling getSelection(selectionKey, 'crossfilter') during
initialization and use that returned instance as fallbackSelection—adjust
references to fallbackSelection, getSelection, existingSelection,
providedSelection, and selectionKey accordingly to ensure a stable selection
object identity across renders.
---
Nitpick comments:
In `@packages/deck/src/dashboard.tsx`:
- Around line 129-130: The clients array passed to usePanelClientRegistration is
recreated each render causing its effect to re-run; fix by memoizing the array
before calling usePanelClientRegistration (e.g. create a stable "clients" value
derived from "client" using useMemo or a ref) and pass that memoized "clients"
into usePanelClientRegistration(dashboard.id, panel.id, clients) so the
reference only changes when "client" actually changes.
In `@packages/mosaic/src/dashboard/MosaicDashboardSlice.ts`:
- Around line 983-1007: The code does three separate state updates in
removePanel—deleting mosaicDashboard.runtime.panelClients[key], calling
get().mosaicDashboard.evictPanelRuntime(dashboardId, panelId), and updating the
dashboards config (dashboard.panels, dashboard.layout, dashboard.updatedAt);
consolidate the two direct state mutations into a single set(produce(...)) call
to avoid intermediate renders by: build one produce block that deletes
state.mosaicDashboard.runtime.panelClients[getMosaicDashboardPanelId(dashboardId,
panelId)] and updates the corresponding dashboard (filter panels, call
removePanelFromLayout, set updatedAt) in the same draft, and keep
get().mosaicDashboard.evictPanelRuntime(dashboardId, panelId) as an external
side-effect call (before or after the combined set) so runtime eviction still
runs but state mutations happen atomically.
🪄 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: 7a2c4745-e8d0-43f7-89e2-607d86f27778
📒 Files selected for processing (47)
apps/sqlrooms-cli-ui/src/workspace/dashboard/DashboardArtifact.tsxpackages/deck/src/dashboard.tsxpackages/mosaic/src/MosaicSlice.tspackages/mosaic/src/charts/MosaicChart.tsxpackages/mosaic/src/charts/MosaicChartView.tsxpackages/mosaic/src/charts/chart-types/base-types.tspackages/mosaic/src/charts/chart-types/bubble-chart/spec.tspackages/mosaic/src/charts/chart-types/count-plot/spec.tspackages/mosaic/src/charts/chart-types/custom-spec/spec.tspackages/mosaic/src/charts/chart-types/heatmap/spec.tspackages/mosaic/src/charts/chart-types/histogram/spec.tspackages/mosaic/src/charts/chart-types/line-chart/spec.tspackages/mosaic/src/charts/dashboard/MosaicDashboardChartHeaderActions.tsxpackages/mosaic/src/charts/dashboard/MosaicDashboardChartRenderer.tsxpackages/mosaic/src/charts/useChartPanelClients.tspackages/mosaic/src/charts/useMosaicChartRenderContext.tspackages/mosaic/src/charts/worksheet/ChartBlockHeader.tsxpackages/mosaic/src/charts/worksheet/ChartBlockRenderer.tsxpackages/mosaic/src/dashboard/DefaultMosaicDashboardBlock.tsxpackages/mosaic/src/dashboard/MosaicDashboardSlice.tspackages/mosaic/src/dashboard/components/ResetFiltersButton.tsxpackages/mosaic/src/dashboard/hooks/useDashboardResetFilters.tspackages/mosaic/src/dashboard/hooks/usePanelResetFilters.tspackages/mosaic/src/dashboard/toolbar/MosaicDashboardAddPanelDropdown.tsxpackages/mosaic/src/dashboard/toolbar/MosaicDashboardResetFiltersButton.tsxpackages/mosaic/src/dashboard/toolbar/MosaicDashboardToolbar.tsxpackages/mosaic/src/dashboard/usePanelClientRegistration.tspackages/mosaic/src/dashboard/usePanelClients.tspackages/mosaic/src/data-table-explorer/DataTableExplorer.tsxpackages/mosaic/src/data-table-explorer/DataTableExplorerCategoryClient.tspackages/mosaic/src/data-table-explorer/createDataTableExplorerStore.tspackages/mosaic/src/data-table-explorer/dashboard/MosaicDashboardDataTableExplorerHeaderActions.tsxpackages/mosaic/src/data-table-explorer/dashboard/MosaicDashboardDataTableExplorerPanelRenderer.tsxpackages/mosaic/src/data-table-explorer/dashboard/useDataTableExplorerPanelClients.tspackages/mosaic/src/data-table-explorer/dataTableExplorerController.tspackages/mosaic/src/data-table-explorer/hooks/useDataTableExplorerColumns.tspackages/mosaic/src/data-table-explorer/hooks/useDataTableExplorerLifecycles.tspackages/mosaic/src/data-table-explorer/hooks/useDataTableExplorerQueryState.tspackages/mosaic/src/data-table-explorer/hooks/useDataTableExplorerSelection.tspackages/mosaic/src/data-table-explorer/hooks/useDataTableExplorerStatus.tspackages/mosaic/src/data-table-explorer/hooks/useDataTableExplorerStoreState.tspackages/mosaic/src/data-table-explorer/hooks/useDataTableExplorerVisiblePage.tspackages/mosaic/src/data-table-explorer/types.tspackages/mosaic/src/data-table-explorer/useDataTableExplorer.tspackages/mosaic/src/data-table-explorer/worksheet/DataTableBlockHeader.tsxpackages/mosaic/src/data-table-explorer/worksheet/DataTableBlockRenderer.tsxpackages/mosaic/src/index.ts
💤 Files with no reviewable changes (1)
- packages/mosaic/src/charts/worksheet/ChartBlockRenderer.tsx
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/charts/chart-settings/MosaicChartTypeSelector.tsx`:
- Around line 46-47: Selected chart type labels are optional and can render
empty spans; update the render in MosaicChartTypeSelector (the trigger span
using selectedChartType.label and the list row span using chartType.label) to
fall back to the chart id by using the nullish fallback (e.g., "?? chartType.id"
/ "?? selectedChartType.id") so the UI always shows a non-empty identifier.
In `@packages/mosaic/src/components/useCombobox.ts`:
- Around line 3-6: The generic T for UseComboboxOptions/useCombobox should be
constrained to string because selection flow (handleSelect) and
Combobox/Combobox.Item use string values; change the signature to use T extends
string (e.g. UseComboboxOptions<T extends string>) and update useCombobox's
generic accordingly so value: T and onChange: (value: T) => void are truly
string-based, then remove any unsafe casts like value as T in handleSelect and
let TypeScript enforce string types end-to-end.
🪄 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: 2468f9df-0b7a-4959-8e82-00ed14c9dc83
📒 Files selected for processing (6)
packages/mosaic/src/charts/chart-settings/MosaicChartTypeSelector.tsxpackages/mosaic/src/components/AggregationSelector.tsxpackages/mosaic/src/components/Combobox.tsxpackages/mosaic/src/components/FieldSelectorInput.tsxpackages/mosaic/src/components/TemporalGranularitySelector.tsxpackages/mosaic/src/components/useCombobox.ts
| <span>{selectedChartType.label}</span> | ||
| </div> |
There was a problem hiding this comment.
Use an ID fallback when chart labels are missing.
label is optional for chart types, so these spans can render empty text. Add ?? chartType.id fallback in both trigger and list rows.
Suggested fix
- <span>{selectedChartType.label}</span>
+ <span>{selectedChartType.label ?? selectedChartType.id}</span>
@@
- <span className="truncate text-xs">{chartType.label}</span>
+ <span className="truncate text-xs">
+ {chartType.label ?? chartType.id}
+ </span>Also applies to: 66-66
🤖 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/charts/chart-settings/MosaicChartTypeSelector.tsx` around
lines 46 - 47, Selected chart type labels are optional and can render empty
spans; update the render in MosaicChartTypeSelector (the trigger span using
selectedChartType.label and the list row span using chartType.label) to fall
back to the chart id by using the nullish fallback (e.g., "?? chartType.id" /
"?? selectedChartType.id") so the UI always shows a non-empty identifier.
Summary by CodeRabbit
New Features
UI Improvements
Documentation