Ctrl+Click a URI in the Response plugin to DESCRIBE and append the result - #176
Conversation
…shes (#175) * Initial plan * fix: persist horizontal/vertical orientation across page refreshes * fix: add JSDoc comments to getOrientation/setOrientation * Improve getOrientation method implementation Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Mathias Vanden Auweele <mathias@matdata.eu> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
There are correctness issues in the new helper/query behavior (DESCRIBE vs CONSTRUCT mismatch) and an async race where DESCRIBE results can append to a new response after the editor is recreated.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds “Ctrl/Cmd+Click a URI to DESCRIBE and append triples” ergonomics to the YASR Response plugin, enabling inline exploration of resources directly from the raw response view (similar to the Graph plugin’s node expansion behavior).
Changes:
- Introduces DOM-free URI parsing/query helpers for the Response plugin (
uriUtils.ts) plus unit tests. - Adds a Ctrl/Cmd+Click (mousedown) handler in the Response plugin to detect a URI under the cursor, execute the background query via
yasr.executeQuery, and append results inline. - Updates user documentation to describe the new shortcut.
File summaries
| File | Description |
|---|---|
| test/unit/response-uri-utils-test.ts | Adds unit tests for URI extraction and query building helpers. |
| packages/yasr/src/plugins/response/uriUtils.ts | Adds URI-at-offset extraction and “describe query” builder utilities for the Response plugin. |
| packages/yasr/src/plugins/response/index.ts | Implements Ctrl/Cmd+Click handling and async DESCRIBE execution + append behavior in the Response plugin. |
| docs/user-guide.md | Documents the new Ctrl/Cmd+Click DESCRIBE-and-append shortcut for the Response plugin. |
Review details
Suppressed comments (2)
packages/yasr/src/plugins/response/uriUtils.ts:52
- The match range check uses
offset <= end, butendis exclusive (start + match length). Using inclusive end can incorrectly treat clicks immediately after the URI as being inside it.
const start = match.index;
const end = start + match[0].length;
if (offset >= start && offset <= end) {
const uri = sanitizeUri(match[0]);
return uri.length > 0 ? uri : undefined;
packages/yasr/src/plugins/response/uriUtils.ts:41
- The match range check uses
offset <= end, butendis exclusive (start + match length). Using inclusive end can incorrectly treat clicks immediately after the closing>as being inside the IRI.
const start = match.index;
const end = start + match[0].length;
if (offset >= start && offset <= end) {
const uri = sanitizeUri(match[1]);
- Files reviewed: 10/10 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…end the result (fixes #176) * Initial plan * feat: Ctrl+Click URI in response plugin runs DESCRIBE and appends result * refactor: surface DESCRIBE failures in response view and tighten typing * refactor: reuse showMore for revealing appended DESCRIBE content * feat: don't describe but retrieve all triples where uri is subject of * docs: also the docker image has been renamed * chore: update prefixes * fix: persist horizontal/vertical layout orientation across page refreshes (#175) * Initial plan * fix: persist horizontal/vertical orientation across page refreshes * fix: add JSDoc comments to getOrientation/setOrientation * Improve getOrientation method implementation Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Mathias Vanden Auweele <mathias@matdata.eu> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Fix offset condition in extractUriAtOffset function Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Modify loading behavior in describeUri method Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Mathias Vanden Auweele <mathias@matdata.eu> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
The raw Response view lets you read URIs but not explore them. This adds the Graph plugin's node-expansion ergonomics to the Response plugin: Ctrl/Cmd+Click a URI to run
DESCRIBE <uri>and append the returned triples inline.Changes
response/uriUtils.ts, new) —extractUriAtOffset(text, offset)resolves the URI under a click across serializations (angle-bracket IRIs in Turtle/N-Triples and bare/quoted URIs in JSON/XML, with trailing-punctuation trimming);buildDescribeQuery(uri)builds the query. Kept DOM-free so they're unit-testable in isolation.response/index.ts) —mousedownhandler resolves the URI viaposAtCoords→extractUriAtOffset, then executes the DESCRIBE through the existingyasr.executeQueryhook (same path the Graph plugin uses). Results are appended to the view viashowMore; appended content survives "Show all", resets on a new query, and failures/empty responses are surfaced as inline#comment notes. The requestAcceptheader reuses the current RDF content type when applicable, elsetext/turtle.Notes for reviewers
config.executeQuery; otherwise the click is a no-op (nopreventDefault)."triple"/"quad"content-type matching ingetDescribeAcceptHeaderintentionally mirrors the existing detection inparsers/index.tsrather than switching to"n-triples".