Repository navigation
feat: Add reusable SQL query blocks and artifact tabs - #669
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 (4)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughAdds id-addressable SQL query support, a reusable SqlQuery compound UI plus a SqlQueryBlock factory, registers ChangesSQL Query Blocks and Artifacts
Estimated code review effort 🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 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)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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: 4
🤖 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 `@apps/sqlrooms-cli-ui/src/context/createArtifactContextAiTools.ts`:
- Around line 104-125: The sql-query branch reads state.sqlEditor.config.queries
and queryResultsById without guaranteeing the artifact-backed query is loaded,
so add a guard to ensure the backing query is initialized before reading
context: if query is undefined, call a new or existing initializer (e.g.,
ensureQueryLoadedForArtifact(artifactId) or dispatch/selectQuery for artifactId)
to load/create the query into state.sqlEditor.config.queries and
queryResultsById, then re-read query and result; finally return the payload
using the now-guaranteed query and result. Ensure you reference artifactId,
state.sqlEditor.config.queries, and state.sqlEditor.queryResultsById in the
change.
In `@packages/data-table/src/DataTablePaginated.tsx`:
- Around line 173-175: The Tailwind v3 important modifier syntax is used in
DataTablePaginated.tsx; update the className usages on TableHeader and TableRow
to use Tailwind v4 placement of the "!" at the end of the utility (e.g., replace
"[&_tr]:!border-b-0" with "[&_tr]:border-b-0!" and any "!border-b-0" occurrences
with "border-b-0!") so the TableHeader and TableRow className strings conform to
Tailwind v4.
In `@packages/sql-editor/src/components/QueryEditorPanelEditor.tsx`:
- Around line 51-58: The current editorOptions memo unconditionally spreads
CODEMIRROR_OPTIONS then sets lineNumbers, foldGutter, and highlightActiveLine to
false or undefined, which overwrites defaults when compact is false; change it
so overrides are only applied when compact is true (e.g., conditionally include
properties) so CODEMIRROR_OPTIONS values remain intact when compact is false;
update the useMemo that defines editorOptions (referencing editorOptions,
CODEMIRROR_OPTIONS, and compact) to only inject the false overrides in compact
mode.
In `@packages/sql-editor/src/SqlEditorSlice.tsx`:
- Around line 327-336: The current removeQuery() implementation recreates a
synthetic 'default' query when the last query is deleted; change removeQuery()
to perform a pure deletion (remove the id-addressable state from config.queries,
config.openTabs, config.selectedQueryId without injecting a 'default' entry) so
it can be used by artifact/block deletion paths without leaving phantom tabs,
and move the "always keep one workbench tab" fallback into the UI/tab-specific
delete flow (the function that handles user tab deletions—e.g., the
deleteTab/removeActiveTab handler) so the editor UI ensures at least one visible
tab while library-level removeQuery() remains generic and composable.
🪄 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: de4d2d9c-a2f1-463a-9c8a-c7f4707033a9
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (24)
apps/sqlrooms-cli-ui/README.mdapps/sqlrooms-cli-ui/src/artifactTypes.tsxapps/sqlrooms-cli-ui/src/context/createArtifactContextAiTools.tsapps/sqlrooms-cli-ui/src/createDashboardCommands.tsapps/sqlrooms-cli-ui/src/statefulBlockArtifactConfigs.tsapps/sqlrooms-cli-ui/src/workspace/WorksheetArtifact.tsxapps/sqlrooms-cli-ui/src/workspace/WorksheetSqlQueryBlockRenderer.tsxdev-docs/tasks/sql-query-block-artifacts.mdpackages/data-table/src/DataTablePaginated.tsxpackages/data-table/src/DataTablePaginatedFooter.tsxpackages/documents/README.mdpackages/documents/src/BlockDocumentEditor/node-views/BlockDocumentStatefulBlockNodeView.tsxpackages/sql-editor/README.mdpackages/sql-editor/package.jsonpackages/sql-editor/src/SqlCodeMirrorEditor.tsxpackages/sql-editor/src/SqlEditorSlice.tsxpackages/sql-editor/src/SqlQuery.tsxpackages/sql-editor/src/SqlQueryBlock.tsxpackages/sql-editor/src/components/QueryEditorPanel.tsxpackages/sql-editor/src/components/QueryEditorPanelActions.tsxpackages/sql-editor/src/components/QueryEditorPanelEditor.tsxpackages/sql-editor/src/components/QueryResultLimitSelect.tsxpackages/sql-editor/src/components/QueryResultPanel.tsxpackages/sql-editor/src/index.ts
Summary
@sqlrooms/sql-editoraround id-addressable queries and a newSqlQuerycompound surface.SqlQueryBlockpluscreateSqlQueryBlockDefinition()so SQL queries can be embedded in BlockDocuments or opened as top-level artifact tabs.sql-querytype into the CLI app’s stateful block registry, artifact types, renderer, and AI context tooling.SqlQuery.*while keeping legacy workbench components compatible.Testing
@sqlrooms/sql-editorand the CLI app.@sqlrooms/sql-editorand the CLI app.@sqlrooms/sql-editorretained one pre-existing warning inCreateTableModal.tsx.Summary by CodeRabbit
New Features
Improvements
Documentation