Skip to content

fix(debug): preserve language in plot links so R/ggplot2 deep-links work#7066

Merged
MarkusNeusinger merged 3 commits into
mainfrom
claude/fix-r-plot-links-aHhKX
May 17, 2026
Merged

fix(debug): preserve language in plot links so R/ggplot2 deep-links work#7066
MarkusNeusinger merged 3 commits into
mainfrom
claude/fix-r-plot-links-aHhKX

Conversation

@MarkusNeusinger
Copy link
Copy Markdown
Owner

Summary

Clicking an R/ggplot2 implementation from /debug landed on the cross-language hub filtered to ?language=python (without the plot), instead of opening the implementation detail page. Root cause: DebugPage.tsx hardcoded 'python' as the language when building plot deep links — for ggplot2 this produced /spec/python/ggplot2, which SpecPage then validates against the impl set, fails to match (the impl is in language r), and redirects to the Python-filtered hub.

Audited all other pages — only DebugPage had the hardcoded-'python' bug. Every other deep link (PlotOfTheDay, SpecOverview, StatsPage, PlotsPage, RelatedSpecs, SpecPage) reads language from the API response.

What changed

Bug fix (DebugPage):

  • Recent activity, desktop spec matrix, and mobile card list now use the real implementation language (via act.language_id from the API, and via a new LIB_TO_LANG constant for the matrix where only a library_id is in scope).

Companion fixes triggered by the R/ggplot2 rollout that the debug pipe never picked up:

  • RecentActivity payload (/debug/status) now includes language_id.
  • SpecStatusItem gains the ggplot2 column — the matrix column was always empty before.
  • library_names map and coverage formula (was specs * 9, now specs * len(SUPPORTED_LIBRARIES)).
  • Hardcoded 9s in DebugPage replaced with LIBRARIES.length (filter button, {implCount}/9 cell, repeat(9, 40px) grid template — both desktop and mobile).
  • /specs/{id}/images and /libraries/{id}/images now also expose language so external API consumers (MCP / docs) can build the same deep links. Docs updated.

Tests:

  • _make_impl helper accepts language_id (defaults to "python").
  • test_debug_status_recent_activity now exercises an R/ggplot2 impl and asserts language_id survives the round-trip — the regression that just shipped.
  • Coverage assertion updated to use len(SUPPORTED_LIBRARIES) rather than the magic 9.

Test plan

  • uv run --extra test --extra plotting pytest tests/unit/ — 1437 passed
  • yarn test --run — 459 passed
  • yarn tsc --noEmit — clean
  • Manual: open /debug, click a ggplot2 cell in the matrix → lands on /{spec}/r/ggplot2 with the plot visible
  • Manual: click a Python library cell → still goes to /{spec}/python/{lib} as before
  • Manual: click an entry in "recent activity" for an R impl → lands on the R detail page

https://claude.ai/code/session_01YKrNgGApdLy6LBfRQbL7qf


Generated by Claude Code

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.
Copilot AI review requested due to automatic review settings May 17, 2026 11:19
@codecov
Copy link
Copy Markdown

codecov Bot commented May 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 only library_id is available.
  • /debug/status recent-activity payload now includes language_id, and ggplot2 is added to the spec status matrix model/column set; coverage calculation is no longer hardcoded to 9 libraries.
  • /specs/{id}/images and /libraries/{id}/images now include language in 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 thread app/src/constants/index.ts Outdated
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).
Comment thread tests/unit/api/test_debug.py Outdated
"""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).
claude and others added 2 commits May 17, 2026 11:49
- 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/...).
Copilot AI review requested due to automatic review settings May 17, 2026 14:58
@MarkusNeusinger MarkusNeusinger enabled auto-merge (squash) May 17, 2026 14:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

@MarkusNeusinger MarkusNeusinger merged commit 3138048 into main May 17, 2026
13 checks passed
@MarkusNeusinger MarkusNeusinger deleted the claude/fix-r-plot-links-aHhKX branch May 17, 2026 15:03
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.

3 participants