fix(debug): preserve language in plot links so R/ggplot2 deep-links work#7066
Merged
Conversation
DebugPage hardcoded 'python' when building plot-detail URLs (recent
activity + spec matrix, desktop and mobile). For ggplot2 (R) this
produced /spec/python/ggplot2; SpecPage then validated that an impl
exists with language=python AND library=ggplot2, found none, and
redirected to the Python-filtered hub overview — exactly the symptom
reported (lands on overview, plot missing).
Fixes alongside, all triggered by the same R-language rollout:
- /debug/status RecentActivity now carries language_id so the frontend
doesn't have to guess
- SpecStatusItem gains a ggplot2 column (was silently missing — the
matrix column was always empty)
- coverage = total / (specs * len(SUPPORTED_LIBRARIES)) instead of *9
- library_names map includes ggplot2
- Hardcoded 9s in DebugPage replaced with LIBRARIES.length
(filter, count display, grid template)
- /specs/{id}/images and /libraries/{id}/images now expose language too,
so external API consumers can build the same deep links
Frontend constants gain LIB_TO_LANG (mirror of LIB_ABBREV) so the matrix
grid can resolve a column's language without waiting for /libraries to
load.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes broken deep-links for non-Python implementations (notably R/ggplot2) by preserving the correct implementation language when building links from the debug dashboard, and extends a couple of image-list API responses to include language so external consumers can build the same links.
Changes:
- Debug dashboard now uses the real implementation language (
language_id) for recent-activity links, and uses a library→language map for the spec matrix where onlylibrary_idis available. /debug/statusrecent-activity payload now includeslanguage_id, and ggplot2 is added to the spec status matrix model/column set; coverage calculation is no longer hardcoded to 9 libraries./specs/{id}/imagesand/libraries/{id}/imagesnow includelanguagein each image entry; API docs updated accordingly; unit tests updated for the new debug payload and dynamic library count.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/api/test_debug.py | Updates debug endpoint unit tests for language_id in recent activity and for dynamic coverage computation. |
| docs/reference/api.md | Documents the new language field in images responses. |
| app/src/pages/DebugPage.tsx | Fixes debug-page deep-links to preserve language; replaces hardcoded 9 with LIBRARIES.length; adds ggplot2 support in the matrix type. |
| app/src/pages/DebugPage.test.tsx | Adjusts mock debug payload shape to include the new ggplot2 column. |
| app/src/constants/index.ts | Adds LIB_TO_LANG mapping to build correct links from library-only contexts. |
| api/routers/specs.py | Adds language to /specs/{id}/images response entries. |
| api/routers/libraries.py | Adds language to /libraries/{id}/images response entries. |
| api/routers/debug.py | Adds language_id to recent activity items, adds ggplot2 column, and replaces hardcoded library-count coverage math. |
Comment on lines
+31
to
+32
| // only know a library id (e.g. the debug-page spec matrix and recent-activity | ||
| // list, which would otherwise have to wait for /libraries to load). |
| """recent_activity should return impls sorted by updated DESC, capped at 15.""" | ||
| """recent_activity should return impls sorted by updated DESC, capped at 15, | ||
| and surface each impl's language so the frontend can build correct deep links | ||
| (regression: Python + R impls were both linked as /spec/python/... before). |
- ruff format collapsed two over-wrapped literals (api/routers/specs.py
spec-images dict and the recent-activity test impl_r construction).
- Narrow the LIB_TO_LANG comment to the spec-matrix use case — once
recent activity started carrying language_id from /debug/status it
no longer relies on the static map.
- Update the recent-activity regression docstring so the URL shape
matches the real specPath output ({specId}/{language}/{library},
not /spec/python/...).
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.
Summary
Clicking an R/ggplot2 implementation from
/debuglanded on the cross-language hub filtered to?language=python(without the plot), instead of opening the implementation detail page. Root cause:DebugPage.tsxhardcoded'python'as the language when building plot deep links — for ggplot2 this produced/spec/python/ggplot2, whichSpecPagethen validates against the impl set, fails to match (the impl is in languager), and redirects to the Python-filtered hub.Audited all other pages — only
DebugPagehad the hardcoded-'python'bug. Every other deep link (PlotOfTheDay,SpecOverview,StatsPage,PlotsPage,RelatedSpecs,SpecPage) readslanguagefrom the API response.What changed
Bug fix (DebugPage):
act.language_idfrom the API, and via a newLIB_TO_LANGconstant for the matrix where only alibrary_idis in scope).Companion fixes triggered by the R/ggplot2 rollout that the debug pipe never picked up:
RecentActivitypayload (/debug/status) now includeslanguage_id.SpecStatusItemgains theggplot2column — the matrix column was always empty before.library_namesmap and coverage formula (wasspecs * 9, nowspecs * len(SUPPORTED_LIBRARIES)).9s inDebugPagereplaced withLIBRARIES.length(filter button,{implCount}/9cell,repeat(9, 40px)grid template — both desktop and mobile)./specs/{id}/imagesand/libraries/{id}/imagesnow also exposelanguageso external API consumers (MCP / docs) can build the same deep links. Docs updated.Tests:
_make_implhelper acceptslanguage_id(defaults to"python").test_debug_status_recent_activitynow exercises an R/ggplot2 impl and assertslanguage_idsurvives the round-trip — the regression that just shipped.len(SUPPORTED_LIBRARIES)rather than the magic9.Test plan
uv run --extra test --extra plotting pytest tests/unit/— 1437 passedyarn test --run— 459 passedyarn tsc --noEmit— clean/debug, click a ggplot2 cell in the matrix → lands on/{spec}/r/ggplot2with the plot visible/{spec}/python/{lib}as beforehttps://claude.ai/code/session_01YKrNgGApdLy6LBfRQbL7qf
Generated by Claude Code