Repository navigation
fix: Mosaic table references for memory-backed datasets - #774
Conversation
|
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 (6)
🚧 Files skipped from review as they are similar to previous changes (5)
📝 WalkthroughWalkthroughAdds catalog-aware table-reference helpers and threads canonical Mosaic table identities through chart SQL, dashboard selection, AI tool flows, and tests. The new behavior omits DuckDB ChangesMosaic table reference normalization
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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: 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/src/ai/block-document/createBlockDocumentChartTools.ts (1)
41-57: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick winNormalize the fallback table identity too.
If
findTable()misses, the rawtableNameis stored unchanged, so whitespace-only or padded names bypass the canonical identity path.Proposed fix
addChart: ({config, tableName, title}) => { - if (!tableName) { + const requestedTableIdentity = getMosaicTableIdentity(tableName ?? ''); + if (!requestedTableIdentity) { throw new Error( 'tableName is required for block document chart blocks but was empty or undefined', ); } - const resolvedTable = databaseAdapter.findTable(tableName); + const resolvedTable = databaseAdapter.findTable(requestedTableIdentity); const tableIdentity = resolvedTable?.table ? getMosaicTableIdentity(resolvedTable.table) - : tableName; + : requestedTableIdentity;🤖 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/ai/block-document/createBlockDocumentChartTools.ts` around lines 41 - 57, The fallback table identity in addChart is not normalized when databaseAdapter.findTable() returns nothing, so padded or whitespace-only names can be stored as-is. Update createBlockDocumentChartTools’s addChart logic so the tableName fallback goes through the same normalization/canonicalization path as resolvedTable.table, using getMosaicTableIdentity or equivalent normalization before passing tableName into blockDocumentAdapter.addBlock.packages/mosaic/src/ai/block-document/createBlockDocumentDataTableExplorerTool.ts (1)
49-76: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick winNormalize the fallback table identity before storing it.
When resolution fails, this persists the original
tableName, skipping the trimming/canonicalization thatgetMosaicTableIdentityprovides.Proposed fix
databaseAdapter, addDataTable: async ({title, tableName, intent}) => { - if (!tableName) { + const requestedTableIdentity = getMosaicTableIdentity(tableName ?? ''); + if (!requestedTableIdentity) { throw new Error( 'Table name is required to add a data table explorer block', ); } blockDocumentAdapter.ensureBlockDocument(blockDocumentId); - const resolvedTable = databaseAdapter.findTable(tableName); + const resolvedTable = databaseAdapter.findTable(requestedTableIdentity); const tableIdentity = resolvedTable?.table ? getMosaicTableIdentity(resolvedTable.table) - : tableName; + : requestedTableIdentity;🤖 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/ai/block-document/createBlockDocumentDataTableExplorerTool.ts` around lines 49 - 76, The fallback table identity in addDataTable should be normalized before it is stored, because the current resolvedTable?.table ? getMosaicTableIdentity(...) : tableName path skips canonicalization when lookup fails. Update createBlockDocumentDataTableExplorerTool so the tableName fallback also goes through getMosaicTableIdentity (or equivalent normalization logic) before passing it to addDataTableExplorerBlock, createDataTableExplorerBlock, and blockDocumentAdapter.addBlock.
🧹 Nitpick comments (1)
packages/mosaic/src/mosaicTableReference.ts (1)
10-11: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd TSDoc for the new exported types.
MosaicTableReferenceInputandMosaicTableReferenceCandidateare new public exports, but they ship undocumented while the surrounding helpers are documented. Please add brief TSDoc so consumers can distinguish persisted identities from runtime candidates. As per coding guidelines,packages/**/*.{ts,tsx}: Add tsdoc to exported types and functions in@sqlrooms/*packages.🤖 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/mosaicTableReference.ts` around lines 10 - 11, Add brief TSDoc comments to the new public exported types `MosaicTableReferenceInput` and `MosaicTableReferenceCandidate` in `mosaicTableReference.ts`. Document that `MosaicTableReferenceInput` accepts either a string or `QualifiedTableName`, and that `MosaicTableReferenceCandidate` represents a runtime object containing a `table: QualifiedTableName`, so consumers can distinguish persisted identities from runtime candidates.Source: Coding guidelines
🤖 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/ai/dashboard/createDashboardChartTools.ts`:
- Around line 48-57: The selectedTable value is being persisted with a raw
tableName fallback when databaseAdapter.findTable(tableName) misses, which
leaves dashboard state non-canonical. Update createDashboardChartTools so it
only writes a resolved table reference, using ensureTable(...) from tool-helpers
or otherwise skipping dashboardAdapter.setSelectedTable when no table is found.
Keep the change centered on the selectedTableIdentity resolution logic so the
dashboard toolbar, selector, and chart renderer can continue resolving through
resolveMosaicTableReference(...).table.
In `@packages/mosaic/src/ai/dashboard/createDashboardDataTableExplorerTool.ts`:
- Around line 34-44: The addDataTable flow in
createDashboardDataTableExplorerTool should not persist an unresolved raw
tableName into dashboardAdapter.setSelectedTable. Update the addDataTable
handler to fail fast with ensureTable(...) when
databaseAdapter.findTable(tableName) does not resolve, or otherwise preserve the
existing selection instead of overwriting it with the unresolved string. Keep
the fix localized to the addDataTable logic and use the existing
dashboardAdapter and databaseAdapter symbols to locate the change.
---
Outside diff comments:
In `@packages/mosaic/src/ai/block-document/createBlockDocumentChartTools.ts`:
- Around line 41-57: The fallback table identity in addChart is not normalized
when databaseAdapter.findTable() returns nothing, so padded or whitespace-only
names can be stored as-is. Update createBlockDocumentChartTools’s addChart logic
so the tableName fallback goes through the same normalization/canonicalization
path as resolvedTable.table, using getMosaicTableIdentity or equivalent
normalization before passing tableName into blockDocumentAdapter.addBlock.
In
`@packages/mosaic/src/ai/block-document/createBlockDocumentDataTableExplorerTool.ts`:
- Around line 49-76: The fallback table identity in addDataTable should be
normalized before it is stored, because the current resolvedTable?.table ?
getMosaicTableIdentity(...) : tableName path skips canonicalization when lookup
fails. Update createBlockDocumentDataTableExplorerTool so the tableName fallback
also goes through getMosaicTableIdentity (or equivalent normalization logic)
before passing it to addDataTableExplorerBlock, createDataTableExplorerBlock,
and blockDocumentAdapter.addBlock.
---
Nitpick comments:
In `@packages/mosaic/src/mosaicTableReference.ts`:
- Around line 10-11: Add brief TSDoc comments to the new public exported types
`MosaicTableReferenceInput` and `MosaicTableReferenceCandidate` in
`mosaicTableReference.ts`. Document that `MosaicTableReferenceInput` accepts
either a string or `QualifiedTableName`, and that
`MosaicTableReferenceCandidate` represents a runtime object containing a `table:
QualifiedTableName`, so consumers can distinguish persisted identities from
runtime candidates.
🪄 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: 921e4396-7714-4e63-a2cb-e50b667b8a56
📒 Files selected for processing (18)
packages/mosaic/__tests__/chart-types/line-chart-spec.test.tspackages/mosaic/__tests__/data-table-explorer.utils.test.tspackages/mosaic/__tests__/mosaicTableReference.test.tspackages/mosaic/src/ai/block-document/createBlockDocumentChartTools.tspackages/mosaic/src/ai/block-document/createBlockDocumentDataTableExplorerTool.tspackages/mosaic/src/ai/dashboard/createDashboardAgentTool.tspackages/mosaic/src/ai/dashboard/createDashboardChartTools.tspackages/mosaic/src/ai/dashboard/createDashboardDataTableExplorerTool.tspackages/mosaic/src/charts/chart-types/base-types.tspackages/mosaic/src/charts/chart-types/box-plot/renderer/BoxPlotClient.tspackages/mosaic/src/charts/dashboard/MosaicDashboardChartRenderer.tsxpackages/mosaic/src/dashboard/panel/MosaicDashboardPanels.tsxpackages/mosaic/src/dashboard/toolbar/MosaicDashboardDataTableSelector.tsxpackages/mosaic/src/dashboard/toolbar/MosaicDashboardToolbar.tsxpackages/mosaic/src/dashboard/useSelectedOrFirstTable.tspackages/mosaic/src/data-table-explorer/dashboard/MosaicDashboardDataTableExplorerPanelRenderer.tsxpackages/mosaic/src/data-table-explorer/useDataTableExplorer.tspackages/mosaic/src/mosaicTableReference.ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bfe301bdfb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (selectedTableIdentity) { | ||
| await dashboardAdapter.setSelectedTable(selectedTableIdentity); | ||
| } |
There was a problem hiding this comment.
Move table selection after panel validation
When a chart tool call includes a tableName and a stale or non-chart panelId, this mutates the dashboard's selected table before the panel existence/type checks below throw. The tool then reports failure without updating any panel, but existing dashboard panels have already switched datasets; keep this mutation after the panelId validation succeeds, or roll it back on validation failure.
Useful? React with 👍 / 👎.
Summary
memorycatalog.Testing
Summary by CodeRabbit