Skip to content

refactor(app): central routes/ module with paths registry#8546

Merged
MarkusNeusinger merged 3 commits into
mainfrom
refactor/frontend-routes
Jun 10, 2026
Merged

refactor(app): central routes/ module with paths registry#8546
MarkusNeusinger merged 3 commits into
mainfrom
refactor/frontend-routes

Conversation

@MarkusNeusinger

Copy link
Copy Markdown
Owner

Summary

Part 6 of the frontend modernization roadmap.

  • router.tsx moves to src/routes/index.tsx (git mv, route config unchanged — lazy pattern and error boundaries untouched)
  • utils/paths.ts moves to src/routes/paths.ts and gains a paths registry — the single source of truth for app URLs: static routes, paths.plotsFiltered(param, value), spec detail via the existing specPath (also exposed as paths.spec)
  • ~25 hardcoded route literals across 16 files replaced with paths.* (Links, navigate(), trackPageview/trackEvent targets)
  • New routes/paths.test.ts (11 tests: builders, reserved slugs, registry); routes/ added to coverage
  • Path references updated in spec-create.yml (comment) and docs/reference/seo.md

Verification

yarn lint ✓ · yarn fm:check ✓ · yarn type-check ✓ · yarn test 547+ ✓ · yarn build

🤖 Generated with Claude Code

- router.tsx moves to src/routes/index.tsx (git mv, route config unchanged)
- utils/paths.ts moves to src/routes/paths.ts and gains a paths registry —
  the single source of truth for app URLs (static routes, plotsFiltered
  builder, spec detail via specPath)
- ~25 hardcoded route literals across 16 files replaced with paths.*
- routes/paths.test.ts covers builders, reserved slugs, and the registry;
  routes/ added to coverage
- Updated path references in spec-create.yml and docs/reference/seo.md

Part 6 of the frontend modernization roadmap.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 9, 2026 23:56
@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.81818% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
app/src/components/NavBar.tsx 75.00% 1 Missing ⚠️
app/src/pages/AboutPage.tsx 0.00% 1 Missing ⚠️
app/src/pages/LibrariesPage.tsx 50.00% 1 Missing ⚠️
app/src/pages/PalettePage.tsx 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR continues the frontend modernization roadmap by consolidating routing into a dedicated src/routes/ module and introducing a centralized paths registry as the single source of truth for app URLs. It updates navigation/analytics call sites to reference the shared helpers, and adds focused unit tests for route building.

Changes:

  • Moved router setup to app/src/routes/index.tsx and updated app entrypoint import.
  • Expanded app/src/routes/paths.ts with a paths registry (static routes + builders) and updated call sites to use it.
  • Added unit tests for path builders and included src/routes/**/*.ts in Vitest coverage; updated docs and workflow comments referencing the moved paths file.

Reviewed changes

Copilot reviewed 32 out of 33 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
docs/reference/seo.md Updates documentation references from utils/paths.ts to routes/paths.ts.
app/vitest.config.ts Adds src/routes/**/*.ts to coverage include patterns.
app/src/routes/paths.ts Adds paths registry alongside specPath, RESERVED_TOP_LEVEL, and langFromPath.
app/src/routes/paths.test.ts Adds unit tests for specPath, langFromPath, reserved slugs, and the paths registry.
app/src/routes/index.tsx Centralizes router creation under src/routes/ (moved router module).
app/src/pages/StatsPage.tsx Replaces hardcoded routes with paths.* / paths.plotsFiltered for navigation and pageview tracking.
app/src/pages/SpecsListPage.tsx Replaces hardcoded /specs pageview tracking with paths.specs.
app/src/pages/SpecPage.tsx Uses paths.home (and imports from new routes/paths) for navigation.
app/src/pages/PlotsPage.tsx Updates specPath import to new location.
app/src/pages/PalettePage.tsx Replaces hardcoded /palette pageview tracking with paths.palette.
app/src/pages/NotFoundPage.tsx Replaces hardcoded home link with paths.home.
app/src/pages/MapPage.tsx Updates specPath import to new location.
app/src/pages/LibrariesPage.tsx Replaces hardcoded routes with paths.* / paths.plotsFiltered for navigation and pageview tracking.
app/src/pages/LandingPage.tsx Switches navigation to paths.* / paths.plotsFiltered and updates some route usages.
app/src/pages/DebugPage.tsx Updates specPath import to new location.
app/src/pages/AboutPage.tsx Replaces hardcoded internal links/pageview targets with paths.*.
app/src/hooks/useAnalytics.ts Updates RESERVED_TOP_LEVEL import to new location.
app/src/components/ToolbarActions.tsx Replaces hardcoded /plots link with paths.plots.
app/src/components/SpecTabs.tsx Uses paths.plotsFiltered for tag navigation to plots.
app/src/components/SpecOverview.tsx Updates specPath import to new location.
app/src/components/ScienceNote.tsx Replaces hardcoded /palette link with paths.palette.
app/src/components/RouteErrorBoundary.tsx Replaces hardcoded home link with paths.home.
app/src/components/RootLayout.tsx Uses paths.plots when computing mastheadSticks.
app/src/components/RelatedSpecs.tsx Updates specPath import to new location.
app/src/components/PlotOfTheDayTerminal.tsx Updates specPath import to new location.
app/src/components/PlotOfTheDay.tsx Updates specPath import to new location.
app/src/components/NavBar.tsx Uses paths.plotsSearch, paths.debug, and paths.home for navigation.
app/src/components/MastheadRule.tsx Updates RESERVED_TOP_LEVEL import to new location and uses paths.home.
app/src/components/HeroSection.tsx Replaces CTA destinations and analytics targets with paths.*.
app/src/components/Footer.tsx Replaces hardcoded internal links with paths.*.
app/src/components/FeedbackWidget.tsx Updates RESERVED_TOP_LEVEL import to new location.
app/src/app.tsx Updates router import to src/routes.
.github/workflows/spec-create.yml Updates comment to reference app/src/routes/paths.ts as the source for RESERVED_TOP_LEVEL.
Comments suppressed due to low confidence (1)

app/src/routes/paths.ts:65

  • paths.plotsFiltered encodes the value but not the query parameter name. If param ever contains &, =, or whitespace (even accidentally), it will generate an incorrect URL and can inject extra query params. Encode the key as well so both parts are safely serialized.

Comment on lines 33 to 36
const handleLibraryClick = (lib: string) => {
trackEvent('nav_click', { source: 'library_card', target: '/plots', value: lib });
navigate(`/plots?lib=${encodeURIComponent(lib)}`);
navigate(paths.plotsFiltered('lib', lib));
};

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Applied — all six hardcoded trackEvent targets (incl. two 'target: /' cases beyond the four flagged) now use the paths registry. See latest commit.

Comment thread app/src/pages/LandingPage.tsx Outdated
component={RouterLink}
to="/map"
to={paths.map}
onClick={() => trackEvent('nav_click', { source: 'map_teaser_preview', target: '/map' })}

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Applied — all six hardcoded trackEvent targets (incl. two 'target: /' cases beyond the four flagged) now use the paths registry. See latest commit.

Comment thread app/src/pages/LandingPage.tsx Outdated
component={RouterLink}
to="/specs"
to={paths.specs}
onClick={() => trackEvent('nav_click', { source: 'specs_more_link', target: '/specs' })}

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Applied — all six hardcoded trackEvent targets (incl. two 'target: /' cases beyond the four flagged) now use the paths registry. See latest commit.

Comment thread app/src/components/NavBar.tsx Outdated
MarkusNeusinger and others added 2 commits June 10, 2026 02:05
Copilot review findings on the routes PR: trackEvent target strings stayed
hardcoded where navigation already used paths.* — aligned all six
(LandingPage x3, NavBar x2, MastheadRule x1) so analytics can't drift from
the routing source of truth.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@MarkusNeusinger MarkusNeusinger enabled auto-merge (squash) June 10, 2026 00:21
Copilot AI review requested due to automatic review settings June 10, 2026 00:21
@MarkusNeusinger MarkusNeusinger merged commit 9c53f61 into main Jun 10, 2026
8 checks passed
@MarkusNeusinger MarkusNeusinger deleted the refactor/frontend-routes branch June 10, 2026 00:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 32 out of 33 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

app/src/routes/paths.ts:65

  • paths.plotsFiltered interpolates the query parameter key without encoding. If param ever contains characters like & or = (e.g. from refactors or caller mistakes), this produces a malformed URL and can inject additional query params. Encode the key the same way as the value.

Comment thread app/vitest.config.ts
'src/components/**/*.tsx',
'src/pages/**/*.tsx',
'src/constants/**/*.ts',
'src/routes/**/*.ts',
MarkusNeusinger added a commit that referenced this pull request Jun 10, 2026
…tion (#8596)

## Summary

Part 11 (final) of the frontend modernization roadmap.

- **`app/ARCHITECTURE.md`**: directory layout
(routes/layouts/pages/sections/components/hooks/lib/theme), conventions
(`src/` alias imports, `paths.*` URL registry, `lib/api` client, theme
tokens, feature folders), data flow, testing pattern, quality gates, and
how-to-add recipes for pages/sections/hooks/endpoints
- **`agentic/docs/project-guide.md`**: frontend section now lists the
full gate (`lint`, `fm:check`, `type-check` incl. tests, `test`),
mentions the dev-time checker overlay, and links the new architecture
doc

With this, the roadmap is complete: tooling baseline (#8519), src/
aliases (#8520), theme split (#8525), global-config (#8529), API client
(#8531), routes registry (#8546), structure split (#8547), FilterBar
(#8559), SpecTabs (#8564), MapPage hook (#8581).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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