Skip to content

Fix: resolve relative concept links in the graph viewer detail panel#181

Open
ryanb93 wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
ryanb93:fix/viz-relative-concept-links
Open

Fix: resolve relative concept links in the graph viewer detail panel#181
ryanb93 wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
ryanb93:fix/viz-relative-concept-links

Conversation

@ryanb93

@ryanb93 ryanb93 commented Jul 10, 2026

Copy link
Copy Markdown

Problem

In the bundled OKF graph viewer (viz.html), clicking a concept link inside the detail panel opened the raw .md file instead of selecting that concept in the graph — but only for relative links.

rewriteInternalLinks only recognised absolute links (/tables/users.md). Relative links — users.md, ../references/metrics/dau.md — fell through to the external-link branch. This is an asymmetry with the rest of the toolchain:

  • the Python edge extractor _extract_links (generator.py) already resolves relative links, so the graph edges render correctly;
  • the OKF spec's own examples and the reference agent's output use relative links.

So a bundle authored with relative links draws the right graph, but its in-panel links don't navigate.

Fix

Resolve each markdown-link href to a concept id relative to the current concept's directory — handling ., .., and #anchor — then select the node if it exists (falling back to external-link behaviour otherwise). This brings the click handler to parity with the already-supported/edge-extracted relative links. Absolute links keep working unchanged.

Testing

viz.js is a browser-only static asset and the repo has no JS test harness, so no automated JS test is added (introducing one for a ~30-line fix seemed disproportionate — happy to add one if maintainers prefer). The relative-link contract is already covered on the Python side by test_viewer.py::test_cross_links_become_edges, which uses relative links. Manually verified that absolute, sibling, ..-traversing, and #anchor links all resolve to the correct concept id, and that unresolved links still render as external.

🤖 Generated with Claude Code

The bundled graph viewer's detail panel only converted absolute markdown
links (e.g. `/tables/users.md`) into in-app node selections. Relative links
(`users.md`, `../references/metrics/dau.md`) — which the Python edge
extractor `_extract_links` already resolves, and which the format's own
examples use — fell through to the "external link" branch and opened the raw
`.md` file instead of selecting the concept.

Resolve link hrefs to concept ids relative to the current concept's
directory (handling `.`, `..`, and `#anchor`), so clicking any intra-bundle
link selects that node, matching the behaviour of the graph edges.

viz.js is a browser-only static asset with no JS test harness in the repo;
the relative-link contract is already covered on the Python side by
test_viewer.py::test_cross_links_become_edges. Verified manually that
absolute and relative links (including `..` traversal and `#anchors`)
resolve to the correct concept id.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@google-cla

google-cla Bot commented Jul 10, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

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.

1 participant