feat: pretty-print JSON and add copy button in cell popup#3801
Open
Arunkoo wants to merge 2 commits intoydb-platform:mainfrom
Open
feat: pretty-print JSON and add copy button in cell popup#3801Arunkoo wants to merge 2 commits intoydb-platform:mainfrom
Arunkoo wants to merge 2 commits intoydb-platform:mainfrom
Conversation
| <div className={b('cell-popup')}>{value}</div> | ||
| <div className={b('cell-popup')}> | ||
| {isJson ? <pre className={b('cell-popup-json')}>{formatted}</pre> : formatted} | ||
| <ClipboardButton text={formatted} size="s" className={b('cell-popup-copy')} /> |
Contributor
There was a problem hiding this comment.
Copy button copies pretty-printed form, not original value
The PR description says "copy the cell value," but text={formatted} copies the indented multi-line JSON (with extra whitespace) rather than the original compact string from the query result. Users pasting into code or a query editor will get the reformatted version instead of the raw value. Use text={value} to copy the original.
Suggested change
| <ClipboardButton text={formatted} size="s" className={b('cell-popup-copy')} /> | |
| <ClipboardButton text={value} size="s" className={b('cell-popup-copy')} /> |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/components/QueryResultTable/Cell/Cell.tsx
Line: 48
Comment:
**Copy button copies pretty-printed form, not original value**
The PR description says "copy the cell value," but `text={formatted}` copies the indented multi-line JSON (with extra whitespace) rather than the original compact string from the query result. Users pasting into code or a query editor will get the reformatted version instead of the raw value. Use `text={value}` to copy the original.
```suggestion
<ClipboardButton text={value} size="s" className={b('cell-popup-copy')} />
```
How can I resolve this? If you propose a fix, please make it concise.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a query result cell contains a JSON value, it is displayed as a minified string in both the cell and the popup tooltip, making it hard to read — especially for large JSON payloads.
Closes #3594
Changes
Cell.tsx(primitives like42,true,nullare intentionally excluded)JSON.stringify(parsed, null, 2)inside a<pre>block in the popupClipboardButtonin the popup to copy the formatted JSON valueQueryResultTable.scssBefore
Popup shows:

After
Popup shows:

Greptile Summary
Adds JSON pretty-printing (with a correct primitive guard) and a
ClipboardButtonto the cell popup. The logic inCell.tsxlooks correct; the main concern is in the stylesheet whereword-break: break-wordfrom the parent.cell-popupis inherited by.cell-popup-json, causing long JSON tokens to wrap rather than trigger the horizontal scrollbar, defeatingoverflow-x: auto.Confidence Score: 4/5
Safe to merge with one minor CSS fix recommended to ensure horizontal scrolling works as intended.
The only remaining finding is a P2 CSS inheritance issue (
word-break) that affects the horizontal-scroll UX for wide JSON but doesn't break functionality. Prior P1 concerns (primitive guard, copy text) have been resolved in the current code.QueryResultTable.scss— addword-break: normalto&__cell-popup-jsonImportant Files Changed
tryFormatJsonand aClipboardButton; primitive guard (null/number/boolean) is correctly handled; copy button copies the formatted string.word-break: break-wordis inherited from.cell-popupand should be reset tonormalto letoverflow-x: autowork correctly.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Cell renders with value] --> B[tryFormatJson] B --> C{JSON.parse succeeds?} C -- No --> D[formatted = value, isJson = false] C -- Yes --> E{typeof parsed === 'object' && parsed !== null?} E -- No primitive --> D E -- Yes --> F[formatted = JSON.stringify pretty, isJson = true] D --> G[Popup: plain text + ClipboardButton copies formatted] F --> H[Popup: pre block + ClipboardButton copies formatted]Prompt To Fix All With AI
Reviews (2): Last reviewed commit: "fix: guard primitive JSON values and cop..." | Re-trigger Greptile