feat(extensions): Enhances SQL Lab API#37642
Conversation
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Code Review Agent Run #07fa32
Actionable Suggestions - 5
-
superset-frontend/packages/superset-core/src/api/sqlLab.ts - 2
- Outdated API example in comment · Line 268-269
- Outdated API example in comment · Line 334-334
-
superset-frontend/src/core/sqlLab/index.ts - 2
- Incorrect state inheritance · Line 526-531
- Incorrect API return value · Line 607-607
-
superset-frontend/packages/superset-core/src/api/editors.ts - 1
- Incorrect zero-based indexing in JSDoc example · Line 94-101
Additional Suggestions - 1
-
superset-frontend/src/SqlLab/components/EditorWrapper/index.tsx - 1
-
Missing handle re-registration · Line 257-279If queryEditorId changes after the editor is ready, the handle isn't re-registered under the new ID, potentially breaking SQL Lab API access. The added useEffect ensures re-registration.
Code suggestion
@@ -278,1 +278,6 @@ - + // Re-register editor handle when queryEditorId changes + useEffect(() => { + if (editorHandleRef.current) { + registerEditorHandle(queryEditorId, editorHandleRef.current); + } + }, [queryEditorId]); +
-
Review Details
-
Files reviewed - 6 · Commit Range:
bbc5ccd..bbc5ccd- superset-frontend/packages/superset-core/src/api/editors.ts
- superset-frontend/packages/superset-core/src/api/sqlLab.ts
- superset-frontend/src/SqlLab/components/EditorWrapper/index.tsx
- superset-frontend/src/core/sqlLab/index.ts
- superset-frontend/src/core/sqlLab/models.ts
- superset-frontend/src/core/utils.ts
-
Files skipped - 0
-
Tools
- Eslint (Linter) - ✔︎ Successful
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
Bito Usage Guide
Commands
Type the following command in the pull request comment and save the comment.
-
/review- Manually triggers a full AI review. -
/pause- Pauses automatic reviews on this pull request. -
/resume- Resumes automatic reviews. -
/resolve- Marks all Bito-posted review comments as resolved. -
/abort- Cancels all in-progress reviews.
Refer to the documentation for additional commands.
Configuration
This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].
Documentation & Help
Code Review Agent Run #a6163fActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
msyavuz
left a comment
There was a problem hiding this comment.
Looks good with a small nit! Curious to see how this changes your example editor implementations?
@msyavuz It does not change the editor implementations as the editor API didn't change. What changed was that the editor handle API is now available for extensions and built-in features. |
|
@michael-s-molina Yeah, i am using your extensions repo as a documentation so i was curious to see how you would use the handle api |
Oh, got it! We'll need an extension idea that manipulates the editor 😉 The only one I have is the SQL Snippets which uses |
Code Review Agent Run #dcffdaActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
|
@msyavuz I updated my extensions to reflect the latest changes. |
Summary
This PR extends the SQL Lab API with new capabilities for tab management, query execution, and editor manipulation.
New APIs
Editor Access (now available via
Tab.getEditor())Tab.getEditor()- Async method to get the editor handleEditor.getValue()- Get the current SQL contentEditor.setValue(sql)- Replace the editor contentEditor.insertText(text)- Insert text at cursor positionEditor.focus()- Focus the editorEditor.getCursorPosition()- Get current cursor positionEditor.getSelections()- Get current selectionsEditor.setAnnotations(annotations)- Set error/warning markersEditor.registerCompletionProvider(provider)- Register custom autocompleteTab Management
createTab(options?)- Create a new query editor tab with optional SQL, title, database, catalog, and schemacloseTab(tabId)- Close a specific tabsetActiveTab(tabId)- Switch to a specific tabonDidCreateTab- Event fired when a new tab is createdQuery Execution
executeQuery(options?)- Execute the SQL query in the current tabcancelQuery(queryId)- Cancel a running queryTab Context
setDatabase(databaseId)- Set the database for the current tabsetCatalog(catalog)- Set the catalog for the current tabsetSchema(schema)- Set the schema for the current tabTab.databaseId,Tab.catalog,Tab.schema- Direct access to tab contextAPI Changes
Tab Interface
Editor Interface
Migration Example
Documentation
Improved JSDoc documentation for the Editor API in
packages/superset-core/src/api/editors.ts:Test Plan
createTab()with various optionsgetEditor()and manipulate contentADDITIONAL INFORMATION