Skip to content

fix(sql): scroll long scripts inside the SQL editor (#1480)#1481

Open
shaishab316 wants to merge 3 commits into
prisma:mainfrom
shaishab316:main
Open

fix(sql): scroll long scripts inside the SQL editor (#1480)#1481
shaishab316 wants to merge 3 commits into
prisma:mainfrom
shaishab316:main

Conversation

@shaishab316

Copy link
Copy Markdown

Summary

Fixes prisma/studio#1480: the SQL console editor could grow with very long queries, stretching the layout so Run SQL (and the rest of the header) was hard to reach without zooming or resizing.

What changed

  • Constrain the SQL view layout with flex (min-h-0 / flex-1) so the editor panel has a bounded height.
  • Give CodeMirror a filled height (height="100%") so content scrolls inside the editor instead of expanding the whole view.
  • When there is no result grid, the empty result area no longer steals flex space (flex-none), so the editor can use the full pane.

How to test

  1. pnpm test -- ui/studio/views/sql/SqlView.test.tsx
  2. Run the demo (pnpm demo:ppg), open SQL Console, paste a large script, and confirm the editor scrolls internally while Run SQL stays visible in the header.

Before

image

After

image

Constrain the SQL panel with flex + overflow so CodeMirror scrolls
internally instead of growing the view. Fixes prisma#1480.
Copilot AI review requested due to automatic review settings April 4, 2026 10:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR fixes the SQL Console layout issue where very long queries caused the CodeMirror editor to expand vertically, pushing the header (including Run SQL) out of easy reach.

Changes:

  • Constrained the SQL view layout using flex + min-h-0/flex-1/overflow-hidden so the editor pane height is bounded.
  • Configured CodeMirror to fill available height (height="100%") so long content scrolls inside the editor.
  • Adjusted result grid container flex behavior so the empty result area doesn’t consume space when there’s no result.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
ui/studio/views/sql/SqlView.tsx Introduces bounded flex layout and makes CodeMirror scroll internally; adjusts result container flexing based on presence of results.
ui/studio/views/sql/SqlView.test.tsx Adds a regression test asserting the presence of the new bounded/overflow-hidden editor container.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ui/studio/views/sql/SqlView.test.tsx
Comment thread ui/studio/views/sql/SqlView.tsx

@sorenbs sorenbs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @shaishab316, thanks a lot for taking this on — the before/after screenshots and the clear breakdown in the description made this easy to review, and the fix direction (bounding the pane and letting CodeMirror scroll internally) is exactly right.

A few things before we can merge:

  1. Layout proportions when results are shown. With this change the editor pane and the result grid are both flex-1, so they always split the view 50/50. Today the editor auto-sizes to its content, so for a short query the result grid gets most of the screen — after this PR it would only get half, with a mostly empty editor above it. Could we keep the auto-sizing and instead cap the editor, e.g. via CodeMirror's maxHeight prop (or a max-h-* on the container), so it grows with content up to a limit and then scrolls? That fixes #1480 without changing the layout for the common case. Keeping your flex-1 behavior for the no-result state (editor fills the pane) is a nice touch and worth preserving.

  2. Changeset. Per our release process, bugfix PRs need a changeset — could you run pnpm changeset and add a patch entry for this fix?

  3. Formatting. The JSX siblings inside the new wrapper didn't get re-indented, and the new cn import is slightly out of sort order — a quick lint/format pass should clean both up.

Small note for next time: opening the PR from a feature branch (rather than your fork's main) makes it easier for us to push tweaks and keeps the PR stable if you keep working on your fork. No need to change it for this one.

Thanks again — happy to re-review quickly once the height cap question is settled!

Address review feedback: instead of evenly splitting the SQL panel
between editor and result grid, keep the editor auto-sized to
content (capped at 40vh) so short queries don't leave a mostly
empty editor pane above the results.
@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 11505c20-0a7a-4b4d-8da3-14d9e447a7c3

📥 Commits

Reviewing files that changed from the base of the PR and between a28e5f5 and 416b7da.

📒 Files selected for processing (4)
  • Architecture/sql-view.md
  • FEATURES.md
  • ui/studio/views/sql/SqlView.test.tsx
  • ui/studio/views/sql/SqlView.tsx

Summary by CodeRabbit

  • Bug Fixes
    • Improved SQL editor sizing so it stays content-sized until results appear.
    • When results are visible, the editor height is capped and long scripts scroll internally.
    • The results grid uses the remaining space rather than splitting the viewport evenly.
  • Tests
    • Added automated coverage for the bounded editor height and the layout transition when results show.
  • Documentation
    • Updated SQL view and feature documentation to reflect the new editor sizing behavior.

Walkthrough

The SQL view now keeps the editor content-sized until results appear, then applies a 40vh maximum height with internal scrolling and lets the results grid use the remaining space. Tests capture CodeMirror sizing props and verify both long-script scrolling and the post-result transition. Architecture guidance, feature documentation, and a patch changeset describe the updated behavior.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: making long SQL scripts scroll inside the editor.
Description check ✅ Passed The description matches the PR and explains the SQL editor scrolling fix and how it was tested.
Linked Issues check ✅ Passed The changes implement the linked issue’s goal by keeping the SQL editor scrollable and the Run SQL button accessible.
Out of Scope Changes check ✅ Passed The diff appears focused on the SQL view behavior, tests, and related docs with no unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

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.

🔧 Biome (2.5.3)
ui/studio/views/sql/SqlView.tsx

File contains syntax errors that prevent linting: Line 1205: expected ) but instead found {; Line 1205: expected , but instead found ?; Line 1206: expected , but instead found <; Line 1206: expected , but instead found className; Line 1207: Expected a parenthesis '(' but instead found '<'.; Line 1207: Expected a parenthesis '(' but instead found 'AI'.; Line 1207: expected , but instead found SQL; Line 1207: expected , but instead found generation; Line 1207: expected , but instead found error; Line 1207: Expected an expression, or an assignment but instead found '<'.; Line 1207: Expected a type parameter but instead found '/'.; Line 1207: expected , but instead found strong; Line 1207: Expected a parenthesis '(' but instead found '{'.; Line 1208: expected , but instead found <; Line 1208: Expected a type parameter but instead found '/'.; Line 1208: expected , but instead found div; Line 1209: Expected a parenthesis '(' but instead found ')'.; Line 1210: expected } but instead found {; Line 1288: expected ) but instead found <

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ui/studio/views/sql/SqlView.tsx

Parsing error: ')' expected.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

CodeRabbit couldn't request changes on this pull request because it doesn't have sufficient GitHub permissions.

Please grant CodeRabbit Pull requests: Read and write permission and re-run the review.

👉 Steps to fix this

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 `@ui/studio/views/sql/SqlView.tsx`:
- Around line 931-935: Run the project formatter on all affected sites: in
ui/studio/views/sql/SqlView.tsx:931-935, add the Prettier-required spacing
between the closing strong element and aiGenerationErrorMessage; in
ui/studio/views/sql/SqlView.test.tsx:1299-1301 and 1327-1329, reformat the
sql-editor-scroll-container querySelector calls; and in
ui/studio/views/sql/SqlView.test.tsx:1332-1334, reformat the
sql-result-grid-container querySelector call. Use Prettier or eslint --fix
without changing behavior.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5fa7561f-fdc8-44ee-9974-308a8c4ed301

📥 Commits

Reviewing files that changed from the base of the PR and between b10686a and a28e5f5.

📒 Files selected for processing (5)
  • .changeset/bright-bears-run.md
  • Architecture/sql-view.md
  • FEATURES.md
  • ui/studio/views/sql/SqlView.test.tsx
  • ui/studio/views/sql/SqlView.tsx

Comment thread ui/studio/views/sql/SqlView.tsx
@shaishab316

Copy link
Copy Markdown
Author

@coderabbitai resolve merge conflict

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown

CodeRabbit chat interactions are restricted to organization members for this repository. Ask an organization member to interact with CodeRabbit, or set chat.allow_non_org_members: true in your configuration.

@shaishab316 shaishab316 left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done — all three addressed:

  1. Layout — swapped flex-1 for auto-sizing + a maxHeight cap on the CodeMirror editor, so short queries still leave most of the space to the result grid, with internal scroll once it hits the cap. Kept flex-1 for the no-result state.
  2. Changeset — added via pnpm changeset.
  3. Formatting — re-indented JSX, fixed cn import order.

@shaishab316
shaishab316 requested a review from sorenbs July 19, 2026 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Raw SQL editor textarea is not scrollable — "Run SQL" button becomes inaccessible

3 participants