Repository navigation
Joshen/fe 4077 explorer query cells - #48989
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
5 Skipped Deployments
|
|
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: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughExplorer notebooks now support configurable Markdown and database cells. Database cells execute SQL, persist edits, and render query results and errors. Toolbar titles support inline editing, and toolbar actions support tooltips. ChangesExplorer notebook queries
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant ExplorerHome
participant NotebookEditor
participant QueryCell
participant SQLExecution
participant QueryResultTable
ExplorerHome->>NotebookEditor: open configured notebook
NotebookEditor->>QueryCell: render database cell
QueryCell->>SQLExecution: execute SQL for selected project
SQLExecution-->>QueryCell: return rows or error
QueryCell->>QueryResultTable: render QueryResult
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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: 7
🧹 Nitpick comments (2)
apps/studio/components/interfaces/Explorer/QueryCell.tsx (2)
51-52: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse an
isprefix for query visibility.Rename
showQuerytoisQueryVisibleand rename its setter consistently. As per coding guidelines, “Use boolean names beginning withis,has,can, orshould.”🤖 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 `@apps/studio/components/interfaces/Explorer/QueryCell.tsx` around lines 51 - 52, Rename the showQuery state variable in QueryCell to isQueryVisible and rename its setter consistently, updating all references in the component while preserving the existing visibility behavior.Source: Coding guidelines
64-69: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove the double type cast.
error as unknown as ResponseErrorhides an incompatible error contract. MakeQueryResult.erroraccept the mutation error type, or map the error fields at this boundary. As per coding guidelines, “Avoid TypeScriptascasts.”🤖 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 `@apps/studio/components/interfaces/Explorer/QueryCell.tsx` around lines 64 - 69, Update the onError handler in QueryCell to remove the double type cast when assigning QueryResult.error. Align QueryResult.error with the mutation’s actual error type, or explicitly map the mutation error fields to the expected ResponseError shape at this boundary, without using TypeScript as-casts.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 `@apps/studio/components/interfaces/Explorer/ExplorerToolbar/index.tsx`:
- Around line 62-107: Update the title editing flow around the toolbar’s value
state and Input/Button rendering: remove the local synchronization useEffect,
initialize the draft from title when editing starts, and keep the draft only
while editing. Render title—not value—when static, and when onSaveTitle is
absent render a non-interactive title instead of enabling editing; preserve
Escape cancellation and save behavior for editable titles.
In `@apps/studio/components/interfaces/Explorer/hooks.ts`:
- Around line 11-37: Replace the module-level DEFAULT_CELLS value with a cell
factory function that creates fresh cell objects and generates new UUIDs on each
invocation. Update the notebook initialization at line 65 to call this factory
so every notebook receives unique cell IDs and an independent cells array.
In `@apps/studio/components/interfaces/Explorer/QueryCell.tsx`:
- Around line 72-79: Update onRunQuery in QueryCell so it persists the current
editor value to the database cell before calling executeQuery. Reuse the
existing persistence logic from the Line 145 path, ensuring Ctrl/Cmd+Enter saves
the latest SQL while preserving the current query execution behavior.
- Around line 72-79: Update onRunQuery to avoid discarding the query mutation
Promise: replace executeQuery’s mutateAsync-style invocation with mutate,
preserving the existing project validation, SQL transformation, and
callback-driven result updates.
In `@apps/studio/components/interfaces/Explorer/QueryResultTable/index.tsx`:
- Around line 145-173: The recovery actions in QueryResultTable currently do
nothing: implement the “Switch to primary database” Button handler and the
AiAssistantDropdown’s buildPrompt and onOpenAssistant behavior, or conditionally
remove both controls until functional implementations are available. Ensure no
visible recovery action has an empty callback or prompt.
- Around line 95-100: Replace the clickable span elements in QueryResultTable
with an accessible Button or equivalent interactive control, preserving the
existing styling and setShowConnect(true) behavior. Apply the change to both
connection prompts, including the additional occurrence around the second
referenced section, so keyboard users can open the connection flow.
In `@apps/studio/state/notebooks/notebooks-state.ts`:
- Around line 114-119: Update useCurrentNotebook to read the route project
reference from useParams and only return the notebook when its stored projectRef
matches that route ref; otherwise return undefined, preventing cached notebooks
from another project from being used.
---
Nitpick comments:
In `@apps/studio/components/interfaces/Explorer/QueryCell.tsx`:
- Around line 51-52: Rename the showQuery state variable in QueryCell to
isQueryVisible and rename its setter consistently, updating all references in
the component while preserving the existing visibility behavior.
- Around line 64-69: Update the onError handler in QueryCell to remove the
double type cast when assigning QueryResult.error. Align QueryResult.error with
the mutation’s actual error type, or explicitly map the mutation error fields to
the expected ResponseError shape at this boundary, without using TypeScript
as-casts.
🪄 Autofix
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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 74ee577d-a692-48c2-be0b-312ec234ad57
📒 Files selected for processing (11)
apps/studio/components/interfaces/Explorer/ExplorerHome.tsxapps/studio/components/interfaces/Explorer/ExplorerQuery/ExplorerQuery.types.tsapps/studio/components/interfaces/Explorer/ExplorerToolbar/index.tsxapps/studio/components/interfaces/Explorer/MarkdownCell.tsxapps/studio/components/interfaces/Explorer/NotebookEditor.tsxapps/studio/components/interfaces/Explorer/QueryCell.tsxapps/studio/components/interfaces/Explorer/QueryResultTable/index.tsxapps/studio/components/interfaces/Explorer/hooks.tsapps/studio/components/interfaces/SQLEditor/UtilityPanel/Results.tsxapps/studio/components/ui/SortableSection.tsxapps/studio/state/notebooks/notebooks-state.ts
There was a problem hiding this comment.
♻️ Duplicate comments (2)
apps/studio/components/interfaces/Explorer/QueryCell.tsx (2)
72-79:⚠️ Potential issue | 🟠 MajorHandle the
mutateAsyncrejection.
executeQueryismutateAsync, butonRunQuerydoes not await or catch it. A failed SQL request runsonErrorand still rejects, which can create an unhandled Promise rejection. Usemutate, or handle the rejected Promise explicitly.🤖 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 `@apps/studio/components/interfaces/Explorer/QueryCell.tsx` around lines 72 - 79, Update onRunQuery to avoid an unhandled rejection from executeQuery, which is mutateAsync: either switch to the mutation’s mutate API or await executeQuery and explicitly catch its rejection while preserving the existing onError behavior.
72-79:⚠️ Potential issue | 🟠 MajorPersist the current SQL before execution.
Ctrl/Cmd+Enter invokes
onRunQuerywhile the editor remains focused. The blur handler may not run, so the notebook can retain older SQL while the current text executes. SavevaluethroughhandleUpdateCellbefore callingexecuteQuery.🤖 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 `@apps/studio/components/interfaces/Explorer/QueryCell.tsx` around lines 72 - 79, Update onRunQuery to persist the editor’s current value through handleUpdateCell before invoking executeQuery, ensuring Ctrl/Cmd+Enter saves the latest SQL even while the editor remains focused. Keep the existing SQL transformation and execution flow unchanged.
🧹 Nitpick comments (3)
apps/studio/components/interfaces/Explorer/QueryCell.tsx (3)
51-52: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse an
is-prefixed name for the visibility state.Rename
showQuerytoisQueryVisibleand renamesetShowQueryto the matching setter. Update all render and toggle sites.As per coding guidelines, boolean names must begin with
is,has,can, orshould.Also applies to: 121-123, 134-134
🤖 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 `@apps/studio/components/interfaces/Explorer/QueryCell.tsx` around lines 51 - 52, Rename the QueryCell visibility state from showQuery to isQueryVisible and its setter to the matching isQueryVisible setter, then update every render and toggle reference in QueryCell to use the new names.Source: Coding guidelines
72-80: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse
handleRunQueryfor the internal handler.
onRunQueryis an internal event handler, not a prop callback. Rename it tohandleRunQueryand update both call sites.As per coding guidelines, prop callbacks use
onX, and internal event handlers usehandleX.Also applies to: 129-129, 141-141
🤖 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 `@apps/studio/components/interfaces/Explorer/QueryCell.tsx` around lines 72 - 80, Rename the internal event handler onRunQuery to handleRunQuery and update both of its call sites, including the references around the affected UI handlers. Keep the existing query execution logic unchanged.Source: Coding guidelines
64-68: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAvoid the double type assertion for execution errors.
error as unknown as ResponseErrorbypasses type checking. If the mutation returns another error shape,QueryResultcan store an invalid value. Type the mutation error asResponseError, or narrow and normalize the error before storing it.As per coding guidelines, avoid TypeScript
ascasts and parse external data at the boundary.🤖 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 `@apps/studio/components/interfaces/Explorer/QueryCell.tsx` around lines 64 - 68, Update the mutation error handling around the onError callback in QueryCell to avoid the double type assertion. Type the mutation’s error as ResponseError when defining the mutation, or narrow and normalize the received error at the boundary before assigning it to QueryResult.error, preserving the existing error result behavior.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.
Duplicate comments:
In `@apps/studio/components/interfaces/Explorer/QueryCell.tsx`:
- Around line 72-79: Update onRunQuery to avoid an unhandled rejection from
executeQuery, which is mutateAsync: either switch to the mutation’s mutate API
or await executeQuery and explicitly catch its rejection while preserving the
existing onError behavior.
- Around line 72-79: Update onRunQuery to persist the editor’s current value
through handleUpdateCell before invoking executeQuery, ensuring Ctrl/Cmd+Enter
saves the latest SQL even while the editor remains focused. Keep the existing
SQL transformation and execution flow unchanged.
---
Nitpick comments:
In `@apps/studio/components/interfaces/Explorer/QueryCell.tsx`:
- Around line 51-52: Rename the QueryCell visibility state from showQuery to
isQueryVisible and its setter to the matching isQueryVisible setter, then update
every render and toggle reference in QueryCell to use the new names.
- Around line 72-80: Rename the internal event handler onRunQuery to
handleRunQuery and update both of its call sites, including the references
around the affected UI handlers. Keep the existing query execution logic
unchanged.
- Around line 64-68: Update the mutation error handling around the onError
callback in QueryCell to avoid the double type assertion. Type the mutation’s
error as ResponseError when defining the mutation, or narrow and normalize the
received error at the boundary before assigning it to QueryResult.error,
preserving the existing error result behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 456cc041-f03a-4f95-9bdd-08e689ef97ff
📒 Files selected for processing (2)
apps/studio/components/interfaces/Explorer/ExplorerToolbar/index.tsxapps/studio/components/interfaces/Explorer/QueryCell.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/studio/components/interfaces/Explorer/ExplorerToolbar/index.tsx
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/studio/components/interfaces/Explorer/NotebookEditor.tsx`:
- Around line 87-91: Update the toolbar actions in NotebookEditor so Analyze,
Run notebook, and Save changes either invoke their appropriate handlers or are
explicitly disabled when unavailable. For disabled actions, provide tooltips
explaining the reason; do not leave any rendered control enabled without
functional behavior.
🪄 Autofix
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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 9004be28-0b19-4a0b-b436-02d0f2d90c63
📒 Files selected for processing (8)
apps/studio/components/interfaces/Explorer/ExplorerToolbar/index.tsxapps/studio/components/interfaces/Explorer/NotebookEditor.tsxapps/studio/components/interfaces/Explorer/QueryCell.tsxapps/studio/components/interfaces/Explorer/QueryResultTable/index.tsxapps/studio/components/interfaces/Explorer/hooks.tsapps/studio/components/interfaces/ProjectHome/Home.tsxapps/studio/components/ui/SortableSection.tsxapps/studio/state/notebooks/notebooks-state.ts
🚧 Files skipped from review as they are similar to previous changes (4)
- apps/studio/state/notebooks/notebooks-state.ts
- apps/studio/components/interfaces/Explorer/QueryResultTable/index.tsx
- apps/studio/components/interfaces/Explorer/hooks.ts
- apps/studio/components/interfaces/Explorer/ExplorerToolbar/index.tsx
🎭 Playwright Test Results (next)Details
Flaky testsFeatures › table-editor.spec.ts › table editor › should show rls accordingly Skipped testsFeatures › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled |
| onMouseDown={(e) => e.preventDefault()} | ||
| onClick={() => handleUpdateMarkdown(cell.id, value)} | ||
| > | ||
| Save |
There was a problem hiding this comment.
Does this just save local state or does it also persist?
There was a problem hiding this comment.
just have local state - the persistence of data will come from saving the whole notebook
although i understand the confusion though, so was thinking of coming back to this
Saxon's UI prototype used the copy "Done" instead of "Save" so perhaps that might be clearer
Braintrust eval report
|
Context
Related to Explorer / Notebooks - adds a barebones query cell that minimally can run SQL queries + render results
The intention is to migrate the components used in the SQL Editor into this new Query cell since all the functionality is very similar, but the SQL Editor component is tightly coupled to the SQL Editor valtio store. So we'll be duplicating a bit of UI for now - which will also make deprecating the SQL Editor eventually a bit easier by just deleting them
Have deliberately omitted a lot of details for now just to keep the PRs small, so will be continuing to build out the QueryCell's functionality in subsequent PRs. This includes
Other changes also includes
Summary by CodeRabbit
New Features
Improvements