Warn before opening a very large JSON value in the data grid (#9868)#10075
Warn before opening a very large JSON value in the data grid (#9868)#10075dpage wants to merge 2 commits into
Conversation
…-org#9868) Opening a huge JSON/JSONB cell in the Query Tool's cell editor parses, pretty-prints and renders the entire document on the main thread. For pathologically large values (e.g. a jsonb object with 100k keys) this blocks the UI thread and pgAdmin becomes completely unresponsive, with no chance for the user to back out. Guard the JSON editor: when the raw cell value exceeds a size threshold, render nothing until the user confirms via a warning dialog. If they cancel, the editor is closed without doing the expensive work. Small values are unaffected and open immediately as before. The editor already uses commitOnOutsideClick: false, so the confirm dialog does not dismiss the editor. The size-threshold logic is a small, separately tested helper. Closes pgadmin-org#9868
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughThis PR adds a safeguard against UI freezing when opening very large JSON/JSONB cell values in the SQL editor data grid. A new detection module with a 1MB threshold, integrated into the JSON editor as a confirmation guard, prevents main-thread blocking when editing large JSON objects. Tests validate both the detection logic and confirmation behavior; release notes document the fix for issue ChangesLarge JSON Value Warning Guard
Sequence DiagramsequenceDiagram
participant User
participant JsonTextEditor
participant shouldWarnForLargeJSON
participant notifier
participant JsonTextEditorContent
User->>JsonTextEditor: Open cell editor
JsonTextEditor->>shouldWarnForLargeJSON: Check value size
alt Large value exceeds threshold
shouldWarnForLargeJSON-->>JsonTextEditor: true
JsonTextEditor->>notifier: Show confirm dialog
alt User confirms
notifier-->>JsonTextEditor: Callback triggered
JsonTextEditor->>JsonTextEditorContent: Render editor
JsonTextEditorContent-->>User: Display JSON editor
else User cancels
notifier-->>JsonTextEditor: Cancel callback
JsonTextEditor->>User: Call onClose(false)
end
else Small value within threshold
shouldWarnForLargeJSON-->>JsonTextEditor: false
JsonTextEditor->>JsonTextEditorContent: Render editor immediately
JsonTextEditorContent-->>User: Display JSON editor
end
🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 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 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.
Pull request overview
Adds a size-based guard to the Query Tool data grid JSON cell editor to avoid UI hangs when opening very large JSON/JSONB values (issue #9868), prompting the user before doing expensive parse/pretty-print/render work on the main thread.
Changes:
- Introduces
shouldWarnForLargeJSON+LARGE_JSON_WARNING_LENGTHhelper for determining when to warn. - Wraps
JsonTextEditorwith a confirmation gate for large raw JSON strings. - Adds Jest coverage for the helper and updates v9.16 release notes.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| web/regression/javascript/sqleditor/json_editor_warning.spec.js | Adds Jest tests for the size-threshold warning helper. |
| web/pgadmin/tools/sqleditor/static/js/components/QueryToolDataGrid/json_editor_warning.js | Implements threshold constant + helper predicate for large JSON warning. |
| web/pgadmin/tools/sqleditor/static/js/components/QueryToolDataGrid/Editors.jsx | Gates the JSON cell editor behind a confirm dialog for large values. |
| docs/en_US/release_notes_9_16.rst | Documents the fix for issue #9868 in release notes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
notifier.confirm() fires its cancel callback whenever the dialog closes, including when the user clicks OK. The large-JSON guard passed () => onClose(false) as the cancel callback, so confirming "continue" also closed the cell editor and the JSON editor never opened. Track the confirmation in the effect closure so the editor is only closed on an actual cancel, and add a regression test for the continue path. Closes pgadmin-org#9868
Summary
jsonbobject with 100,000 keys, ~3 MB) this blocks the UI thread and pgAdmin becomes completely unresponsive, with no opportunity for the user to back out.JsonTextEditor— when the raw cell value exceeds a size threshold (1 MB of characters), render nothing until the user confirms via a warning dialog. If they cancel, the editor closes without doing the expensive parse/render. Small values are unaffected and open immediately, exactly as before. The grid already setscommitOnOutsideClick: false, so the confirm dialog does not dismiss the editor.json_editor_warning.js).Test plan
regression/javascript/sqleditor/json_editor_warning.spec.js(5 tests) covering the threshold boundary, custom thresholds, and non-string values — all passing.eslint -c .eslintrc.jsclean on all changed files.wide_datacell — a confirmation dialog appears; Cancel leaves the UI responsive, Continue opens the editor as before. A small jsonb cell opens with no prompt.Closes #9868
Summary by CodeRabbit
Release Notes
Bug Fixes
Documentation
Tests