Add a JSONPath box to the workbench's JSON view - #3910
Conversation
/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>
|
|
andy-stark-redis
left a comment
There was a problem hiding this comment.
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 :-)
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>
|
Good advice @andy-stark-redis , I added an |
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>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ 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, |
There was a problem hiding this comment.
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)
Reviewed by Cursor Bugbot for commit ee8a885. Configure here.


/develop/data-types/json/path is a page of JSONPath syntax with nowhere to try it: a reader can read about
$..nameand$.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.GETcalls; 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.GETat 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.openKeyand 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 withjsonPath.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.