Skip to content

Fix embedding-plot click-through (404 on every point)#148

Merged
realmarcin merged 1 commit into
mainfrom
fix/embedding-clickthrough-404
Jul 5, 2026
Merged

Fix embedding-plot click-through (404 on every point)#148
realmarcin merged 1 commit into
mainfrom
fix/embedding-clickthrough-404

Conversation

@realmarcin

Copy link
Copy Markdown
Contributor

Problem

Both embedding pages (umap.html, graph.html) recomputed each trait's page URL in the browser as CATEGORY_DIR[d.category]/slugify(d.label).html. Two defects:

  1. Category case-mismatch (100% breakage): CATEGORY_DIR is keyed UPPERCASE, but the data's category is lowercase and already equals the directory slug — so CATEGORY_DIR[d.category] was always undefined, and every one of the 477 points fell through to a non-existent traits/other/… page. 0/477 resolved.
  2. Label ≠ filename (4 traits): trait page filenames are the YAML file stems, which spell digits as words (dicarboxylate_four_hydroxybutyrate_cycle) and use abbreviations (reductive_tca_cycle). No client-side label-slugifier can reproduce those.

Surfaced by a front-end design review against the dataviz/artifact-design skills.

Fix

Stop recomputing slugs client-side. The renderer already builds the authoritative id→page map (page_path), so inject it into the two templates as HREF_BY_ID and have the click handler use HREF_BY_ID[d.id] directly.

Verification

Recomputed every point's click target against files on disk:

  • Before: 0/477 resolve (all 404).
  • After: 477/477 resolve — including the 4 digit/abbreviation metabolism traits.

Immune to future label/filename drift since the href is now data, not a re-derivation.

Files: scripts/render_trait_pages.py (inject map), src/traitmech/templates/{umap,graph}.html, regenerated pages/{umap,graph}.html.

🤖 Generated with Claude Code

…href map

The UMAP and sfdp-graph pages recomputed each trait's page URL client-side
as `CATEGORY_DIR[d.category]/slugify(d.label).html`. Two bugs made this wrong:

1. `CATEGORY_DIR` is keyed UPPERCASE but `d.category` is lowercase (and already
   equals the directory slug), so the lookup always missed and every one of the
   477 points navigated to a non-existent `traits/other/...` page (0/477 resolved).
2. Trait page filenames are the YAML file stems, which spell digits as words
   (`dicarboxylate_four_hydroxybutyrate_cycle`) and use abbreviations
   (`reductive_tca_cycle`); no label-slugifier can reproduce those.

Fix: stop recomputing slugs in the browser. The renderer already knows the
authoritative id→page map (`page_path`), so inject it as `HREF_BY_ID` and have
the click handler look up `HREF_BY_ID[d.id]` directly. Now 477/477 points link
to a real page, and the link is immune to future label/filename drift.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 4, 2026 21:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@realmarcin

Copy link
Copy Markdown
Contributor Author

Reviewed the PR's own diff (source templates + renderer; regenerated pages are consistent).

Clean — no issues. The fix is correct:

  • render_trait_pages.py injects href_by_id for both plots from the authoritative page_path map ({p["id"]: page_path.get(p["id"], "") for p in ...}), so the href is data, not a client-side re-derivation.
  • umap.html/graph.html click handlers now use HREF_BY_ID[d.id] with an if (href) guard (empty-string fallback is falsy → no bad nav). No slug/category recompute reintroduced.
  • Data keys and page filenames unchanged; rendered pages/{umap,graph}.html carry the injected map. Verified id→page targets resolve.

(Minor, non-blocking: the now-unused traits_root="traits/" kwarg is still passed to both render calls — harmless leftover.)

@realmarcin realmarcin merged commit 4db924b into main Jul 5, 2026
2 checks passed
@realmarcin realmarcin deleted the fix/embedding-clickthrough-404 branch July 5, 2026 07:26
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.

2 participants