Skip to content

Add a JSONPath box to the workbench's JSON view - #3910

Open
paoloredis wants to merge 4 commits into
mainfrom
DOC-7028
Open

Add a JSONPath box to the workbench's JSON view#3910
paoloredis wants to merge 4 commits into
mainfrom
DOC-7028

Conversation

@paoloredis

@paoloredis paoloredis commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

/develop/data-types/json/path is a page of JSONPath syntax with nowhere to try it: a reader can read about $..name and $.list[*] and then has to go and build a JSON.GET by hand. Opening a JSON key in the workbench showed the whole document and nothing else.

So the path that produced what is on screen is now editable. Enter runs JSON.GET at that path and the value below is the answer, with the number of matches beside it — JSONPath replies with an array of everything it matched, which is the thing readers get wrong first.

Wrong paths are the point, not an accident: a path matching nothing answers [] and a path that does not parse answers with the server's error, shown in red rather than swallowed. That is how the syntax gets learned.

The box starts empty rather than prefilled with $. The root is already on screen, so a prefilled path is a control that does nothing, and a lone "$" in a box reads as an empty one; the placeholder carries the syntax instead.

quote() now prefers single quotes. redis-cli takes a single-quoted token literally, so a path keeps its $ and its brackets as written — with double quotes this escaped the $ like a shell and the command under the value read "\$[?(@.a==1)]": correct, and not what anyone would type. Double quotes stay as the fallback for a value containing a quote.

Verified against a live sandbox: the box appears only for ReJSON-RL keys, reads a field, counts matches, reports a bad path in red, and shows JSON.GET bike '$.colors[?(@=="black")]' unescaped for copying.


Note

Low Risk
Workbench-only UI and sandbox JSON.GET calls; no auth, persistence, or backend contract changes beyond clearer command quoting.

Overview
Readers can try JSONPath against ReJSON-RL keys in the workbench value pane instead of only seeing the full document from JSON.GET … $.

An editable Path strip (Run, optional clear) runs JSON.GET at the typed path and refreshes the preview below. Match counts appear as facts; parse/server errors render in red via .rwb-failed. The path box starts empty with placeholder examples; clearing or an empty submit reads the root. After user-initiated reads, focus and caret return to the path input so iterative tries stay in the box.

openKey and keyspace sweeps keep the active path in sync: reopening or re-rendering the same JSON key re-fetches that path instead of silently resetting to root. Dock state tracks this with jsonPath.

quote() now prefers single-quoted arguments when safe so “Read with” lines show paths like '$.colors[?(@=="black")]' without shell-style \$ escaping.

Reviewed by Cursor Bugbot for commit ee8a885. Bugbot is set up for automated code reviews on this repo. Configure here.

/develop/data-types/json/path is a page of JSONPath syntax with nowhere
to try it: a reader can read about `$..name` and `$.list[*]` and then has
to go and build a JSON.GET by hand. Opening a JSON key in the workbench
showed the whole document and nothing else.

So the path that produced what is on screen is now editable. Enter runs
JSON.GET at that path and the value below is the answer, with the number
of matches beside it — JSONPath replies with an array of everything it
matched, which is the thing readers get wrong first.

Wrong paths are the point, not an accident: a path matching nothing
answers `[]` and a path that does not parse answers with the server's
error, shown in red rather than swallowed. That is how the syntax gets
learned.

The box starts empty rather than prefilled with `$`. The root is already
on screen, so a prefilled path is a control that does nothing, and a lone
"$" in a box reads as an empty one; the placeholder carries the syntax
instead.

quote() now prefers single quotes. redis-cli takes a single-quoted token
literally, so a path keeps its `$` and its brackets as written — with
double quotes this escaped the `$` like a shell and the command under the
value read `"\$[?(@.a==1)]"`: correct, and not what anyone would type.
Double quotes stay as the fallback for a value containing a quote.

Verified against a live sandbox: the box appears only for ReJSON-RL keys,
reads a field, counts matches, reports a bad path in red, and shows
`JSON.GET bike '$.colors[?(@=="black")]'` unescaped for copying.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

DOC-7028

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🧠 Redis Memory

Found 10 related items from repository history (1 new this commit):

Memory updated at ee8a885

Comment thread static/css/redis-workbench.css Outdated
Comment thread static/js/redis-workbench.js
@paoloredis
paoloredis requested a review from a team September 2, 2026 13:41

@andy-stark-redis andy-stark-redis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Really good feature! Minor suggestion, maybe, is an "X" button to clear the JSONPath filter (currently, you have to clear the text manually, then press Enter or click Run to remove the filter). Approved anyway - very neat :-)

@andy-stark-redis
andy-stark-redis requested a review from a team September 2, 2026 14:52
The Path box desynced from the value. jsonPath is restored whenever that
key is drawn, but openKey re-read the document at the root, so after a
sweep — any command re-renders whatever is open — the box said `$.model`
while the value and the "Read with" line were the whole document.

openKey now re-reads at the reader's path when there is one for that key,
which is what the vector-set element view already does: a sweep keeps
showing what the reader had open rather than throwing it away. A
different key still starts with an empty box.

The error colour never applied. A failed read is `.rwb-text .rwb-json
.rwb-failed` on one <pre>, and .rwb-json sets cyan 120 lines further
down the file — same specificity, later wins — so "(error) …" rendered as
a JSON value. Compounded the selector as .rwb-text.rwb-failed, which wins
on specificity rather than on order.

Verified: the error is rgb(252, 165, 165), and a command run while a path
is open leaves the box, the value and the command line all naming that
path.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@paoloredis

Copy link
Copy Markdown
Collaborator Author

Good advice @andy-stark-redis , I added an X button to clear the text box, it shows up when the box is not empty.

paoloredis and others added 2 commits September 3, 2026 17:06
Review: clearing the filter took three steps — select the text, delete
it, then Enter or Run. Now one click on an × beside the field empties the
box and reads the whole document back.

Shown only while a path is in force. An × over an empty box would be a
control that does nothing, which is the same reason the box starts empty
rather than prefilled with `$`.

As tall as Run next to it: .rwb-btn's vertical padding and a 17px line
box are what make that 25px, so the glyph is set larger inside the same
box rather than being allowed to grow it.

Verified: the × appears with a path and goes away without one, one click
restores the root document and the `JSON.GET bike $` line under it, and a
sweep re-reads the path with its × intact.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Reading a path redraws the value pane, so the box the reader pressed
Enter in no longer exists by the time the answer is on screen and focus
falls back to the document. Trying a path is usually trying several —
`$.a`, then `$.a[0]`, then `$..a` — and each one meant clicking back into
the box first.

Focus returns to the box that replaced it, caret where they left it, so
editing continues straight away. The × does the same, into an empty box.

Only after a read the reader asked for. The same redraw runs on every
sweep, and taking the keyboard because a command finished in the terminal
would be worse than the problem.

Verified: Enter leaves focus in the box with the caret at 7 of `$.brand`,
a second path can be typed and run without touching the mouse, the ×
leaves an empty focused box, and a command run in the terminal leaves
focus in the terminal.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ee8a885. Configure here.

indexDocs: null,
/* Page setups already run in this sandbox session, by name. */
setupRan: {},
jsonPath: null,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale jsonPath survives flush and key deletion

Medium Severity

The new jsonPath state is never reset when the sandbox is flushed, a key is deleted, or a key expires, unlike the analogous openElement state which is explicitly cleared at all those points. If a user queries $.model on key "bike", then runs FLUSHDB (or the key expires), and the page setup recreates a "bike" JSON key, the sweep calls openKey → finds the stale jsonPath.name === "bike" with a truthy path → calls readJsonPath with the old path the user never asked for on this new key.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ee8a885. Configure here.

@mich-elle-luna mich-elle-luna left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

thank you!

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.

4 participants