Skip to content

feat(site): serve course lessons at /learn/<phase>/<lesson> - #780

Merged
rohitg00 merged 5 commits into
mainfrom
feat/clean-lesson-urls
Nov 12, 2026
Merged

rohitg00 merged 5 commits into
mainfrom
feat/clean-lesson-urls

Conversation

@rohitg00

@rohitg00 rohitg00 commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

What changes

URL form

  • Course lessons are served at /learn/<phase>/<lesson>. Each segment is the directory name without its number prefix: phases/07-transformers-deep-dive/02-self-attention-from-scratch becomes /learn/transformers-deep-dive/self-attention-from-scratch.
  • The 542 published course lessons map to 542 distinct clean paths.
  • Language and navigation context stay as query parameters: ?lang=hi, ?learningPath=..., ?fromTrack=....
  • Certification lessons keep /lesson?path=certifications/....

Redirects

  • /lesson?path=phases/... and /lesson.html?path=phases/... answer 308 to the clean URL and keep valid context parameters.
  • Unknown parameters on a clean URL answer 308 to the normalized clean URL, as the query form did before.

Server

  • vercel.json rewrites /learn/:phase/:lesson to the lesson function.
  • api/lesson.js resolves the clean path through the lesson manifest. It reads the path from req.url, and from the rewrite parameters when the host passes the destination URL.
  • Canonical, og:url, hreflang alternates, sitemaps, llms.txt, lesson-seo.json, and social card paths use the clean URL.
  • Practice, interview, cheat sheet, and phase hub pages link to the clean URL. The cheat sheet link checker validates clean lesson links against the lessons on disk.
  • site/developer.md, site/developer.html, and site/openapi.json document the new route.

Client

  • On a clean URL the page gets <base href="/"> and <meta name="aifs-lesson-path">. The lesson reader, the language picker, and the highlight export read the lesson path from the meta tag when the query has none.
  • header.js rewrites lesson?path=phases/... links to the clean form outside static previews. Static previews keep the query form.
  • The table of contents writes the hash against the current path. In-page links get the lesson path and query in front of their fragment, so the base href does not send them to the home page, including for copy link and open in new tab.
  • Narration treats clean lesson links as continuation and uses one route key for the query form and the clean form.

Not changed

  • Search records keep the query URL. The command palette parses the lesson path from it, and navigation follows the redirect.
  • Static HTML that uses relative lesson?path= links (catalog fallback table, skills page) keeps them for static previews. The header rewrites them in the browser, and a request without JavaScript follows one redirect.
  • Progress, highlights, and narration state are keyed by lesson path, so stored reader data needs no migration.

Tests

  • scripts/test_seo_routes.js, scripts/test_api_state.js, scripts/test_agent_api.js, scripts/test_agent_wire.js, and six site test files updated to the new contract. Legacy route tests now assert the 308 and its exact Location.
  • node --test scripts/test_*.js site/test_*.js: 737 pass, 2 fail.
  • The cheat sheet topic coverage test also fails on main at a509402c0. fix(cheatsheets): add tool-contract-migration-checker to a cheat sheet topic #781 fixes it.
  • scripts/test_function_bundles.js passes with @vercel/nft installed. An earlier commit on this branch failed it in CI: the smoke test asked for a course lesson by the query form. It now requests the canonical URL.
  • The cache key test fails only with local build output present.

Checked locally

  • Status codes and Location headers for clean, legacy, translated, learning path, unknown parameter, unknown lesson, and certification requests.
  • In a browser: page load, table of contents click and URL hash, next lesson link, deep link to a heading, progress recording.

To check on the preview

The first three were checked on the preview of 715c91259 with authenticated requests. The first preview answered 308 from the clean URL to itself, because the host adds rewrite path parameters to the query under their route names. The route parameters are now cleanPhase and cleanLesson, and a test covers each request shape. The browser items below are not checked on the preview yet.

  • /learn/transformers-deep-dive/self-attention-from-scratch answers 200 with the clean canonical
  • /lesson?path=phases/07-transformers-deep-dive/02-self-attention-from-scratch answers 308 to it
  • /learn/transformers-deep-dive/self-attention-from-scratch?lang=hi renders the translation
  • Narration continues across the next lesson link (checked locally in silent mode, not on the preview)
  • Highlight share link opens the same lesson
  • Language picker switches language and keeps the clean path

Risk

Course lessons get a path URL built from the phase and lesson
directory names without their number prefixes, for example
/learn/transformers-deep-dive/self-attention-from-scratch.

The lesson handler resolves the clean path through the lesson
manifest, keeps language and navigation context as query parameters,
and answers 308 from /lesson?path=phases/... to the clean URL.
Certification lessons keep the query form.

Canonical tags, hreflang alternates, sitemaps, llms.txt, social card
paths, and the practice, interview, cheat sheet, and phase hub links
use the clean URL. The API docs and OpenAPI description list the new
route.

On a clean URL the page sets a base href and a lesson path meta tag.
The reader, the language picker, and the highlight export read the
lesson path from that tag, and the shared header rewrites lesson
links to the clean form outside static previews.
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Explain Change →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 37 seconds.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between ce21cf7 and a9d4340.

Files selected for processing: 2

  • scripts/build_book.py
  • scripts/test_agent_readiness.py

No actionable comments were generated in the recent review.

Walkthrough

Course lessons gain clean /learn/{phase}/{lesson} routes. The handler resolves these routes and redirects eligible legacy URLs. Lesson links, rendered pages, translation URLs, sitemaps, and API documentation use clean paths where applicable.

Changes: Course lesson routes

Layer / File(s) Summary
Resolve and normalize clean lesson requests
lib/hub-routes.js, api/lesson.js, vercel.json, site/openapi.json, scripts/test_agent_wire.js, scripts/test_api_state.js, scripts/test_seo_routes.js, site/test_asset_cache.js
The route helper creates clean paths, and the lesson handler resolves them against the manifest. Eligible legacy course lesson URLs redirect to clean paths. Vercel rewrites clean routes to the handler, and the OpenAPI description documents the route and its responses.
Generate clean lesson links
lib/lesson-translations.js, lib/og-cards.js, site/build-cheatsheets.js, site/build-interviews.js, site/build-practice.js, site/build.js, site/header.js, site/tts.js, scripts/test_agent_api.js, scripts/test_function_bundles.js, site/test_interviews.js, site/test_practice.js, site/test_build_artifacts.js
Lesson URL builders use clean paths when available and keep query-based fallbacks. Generated links preserve applicable language parameters, navigation context, and anchors. TTS route keys and continuation-link checks recognize clean course lesson URLs.
Render and navigate clean lesson pages
api/lesson.js, site/lesson.html, site/lang-picker.js, site/content-source.js, site/highlights.js, site/test_lesson_code.js, scripts/test_api_state.js
Clean-route HTML includes a base URL and lesson-path metadata. Lesson scripts use the metadata when no path query is present. Fragment and table-of-contents navigation retain the current route and query. Markdown export uses a clean-route-aware base.
Update SEO outputs and route coverage
site/build.js, site/developer.html, site/developer.md, site/test_build_artifacts.js, scripts/test_seo_routes.js
Canonical URLs, sitemap entries, translated URLs, social metadata, generated documentation, and route tests use clean paths for course lessons. Certification lesson URLs remain query-based.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Browser
  participant Vercel
  participant LessonAPI
  participant Manifest
  Browser->>Vercel: Request clean lesson path
  Vercel->>LessonAPI: Forward clean route parameters
  LessonAPI->>Manifest: Resolve clean path
  Manifest-->>LessonAPI: Return matching lesson entry
  LessonAPI-->>Browser: Return page or normalized redirect
Loading

Possibly related PRs

Merge Risk: Minimal · previous review ce21c

Course lessons now use clean /learn/ URLs, with legacy URLs redirected. No actionable merge-blocking risk was identified in this review. Confirm the CI cheat sheet failure is unrelated to this change before merging.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "feat(site): serve course lessons at /learn//" states the main change: published course lessons move to clean /learn// URLs. The changeset covers the routing, r…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description is specific and on-topic. It names the clean URL form, the redirect behavior, the server, client, and documentation changes, the tests run, and the open preview checks. It matches the …
Full details: Title check

Explanation

The title "feat(site): serve course lessons at /learn/<phase>/<lesson>" states the main change: published course lessons move to clean /learn/<phase>/<lesson> URLs. The changeset covers the routing, redirects, Vercel rewrite, metadata, sitemaps, and client changes that support this form.

Full details: Description check

Explanation

The description is specific and on-topic. It names the clean URL form, the redirect behavior, the server, client, and documentation changes, the tests run, and the open preview checks. It matches the changeset, which adds /learn/<phase>/<lesson> routes, 308 redirects, and related updates across api/lesson.js, lib helpers, site files, and tests.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 715c912 and ce21cf7.

Files selected for processing: 4

  • scripts/test_function_bundles.js
  • site/lesson.html
  • site/test_build_artifacts.js
  • site/tts.js

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

…own names

The host adds rewrite path parameters to the request query. The route
used `phase` and `lesson`, which the lesson handler treats as unknown
query names, so a clean URL answered 308 to itself on the preview.
The parameters are now `cleanPhase` and `cleanLesson`, the names the
handler already accepts on a clean request.
@rohitg00
rohitg00 marked this pull request as ready for review November 12, 2026 12:28
devin-ai-integration[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

… URLs

Narration treats /learn/<phase>/<lesson> links as lesson
continuation, and its route key maps the query form of a course
lesson to the clean form, so playback continues when a link goes
through the redirect.

The fragment link handler leaves modified and non-primary clicks to
the browser.
devin-ai-integration[bot]

This comment was marked as resolved.

…smoke test

On a clean lesson URL, an in-page link gets the current path and
query in front of its fragment as soon as the reader points at,
focuses, or opens a menu on it. Copy link, open in new tab, and
modified clicks then stay on the lesson. The table of contents and
scroll handlers read the fragment from either form and leave
modified clicks to the browser.

The function bundle smoke test requests each lesson at its canonical
URL. It asked for a course lesson by the query form and got the
redirect.
…n lesson URLs

The agent readiness test expects course lessons at /learn/ in the
lesson manifest and the sitemap, checks that no two course lessons
share a clean URL, and keeps the query form for certification
lessons. Book chapters link to the clean lesson URL.
@rohitg00
rohitg00 merged commit 3abf286 into main Nov 12, 2026
14 of 15 checks passed
@rohitg00
rohitg00 deleted the feat/clean-lesson-urls branch November 12, 2026 14:58

This branch was successfully deployed

1 active deployment
Preview — a9d43403 Deployed Nov 12, 2026 by vercel[bot]
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