Skip to content

feat: skeleton loaders for page navigation#50

Merged
rohanchkrabrty merged 6 commits intomainfrom
feat_skeleton_loaders
May 7, 2026
Merged

feat: skeleton loaders for page navigation#50
rohanchkrabrty merged 6 commits intomainfrom
feat_skeleton_loaders

Conversation

@rsbh
Copy link
Copy Markdown
Member

@rsbh rsbh commented May 7, 2026

Summary

  • Add isLoading state to PageProvider with explicit loading flag for docs page fetches
  • Refactor PageProvider — extract fetchApiSpecs and fetchPageData into useCallback, use useRef for path tracking
  • Add Skeleton to Theme interface — each theme provides its own skeleton component
  • Create skeleton loaders for both default and paper themes using Apsara <Skeleton>
  • DocsPage renders theme-specific skeleton during client-side navigation

Test plan

  • Navigate between pages — skeleton shows during loading
  • Verify skeleton matches each theme's content layout
  • SSR initial load should not show skeleton
  • Error pages (404) should not show skeleton
  • API pages should not show skeleton

🤖 Generated with Claude Code

rsbh and others added 2 commits May 7, 2026 13:35
Extract fetch logic into useCallback (fetchApiSpecs, fetchPageData).
Both callbacks own their loading state. Use ref for currentPath to
avoid stale dependency. DocsPage renders loading placeholder when
isLoading is true.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add Skeleton component to Theme interface. Each theme provides its own
skeleton matching its content layout. DocsPage renders theme skeleton
when isLoading is true.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chronicle Ready Ready Preview, Comment May 7, 2026 9:26am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Review Change Stack

Warning

Rate limit exceeded

@rsbh has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 17 minutes and 55 seconds before requesting another review.

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 26e07e82-b5f0-40d9-b436-3ed5b11e7df0

📥 Commits

Reviewing files that changed from the base of the PR and between 8908d22 and a1759cc.

📒 Files selected for processing (2)
  • packages/chronicle/src/lib/page-context.tsx
  • packages/chronicle/src/themes/paper/Skeleton.tsx
📝 Walkthrough

Walkthrough

This PR introduces a loading skeleton UI feature to Chronicle's page renderer. The Theme interface gains an optional Skeleton component, PageContext adds isLoading state and async fetch callbacks, skeleton UI components are created for both default and paper themes with CSS styling, and DocsPage is updated to display loaders during data fetches.

Changes

Loading Skeleton UI Feature

Layer / File(s) Summary
Type Contracts
packages/chronicle/src/types/theme.ts, packages/chronicle/src/lib/page-context.tsx
Theme interface adds optional Skeleton: React.ComponentType; PageContextValue interface adds isLoading: boolean field.
Skeleton UI Components
packages/chronicle/src/themes/default/Skeleton.tsx, packages/chronicle/src/themes/paper/Skeleton.tsx, packages/chronicle/src/themes/paper/Page.module.css
PageSkeleton components render page-like layouts with header and 30 line placeholders; CSS adds .headerLoader and .loader styles with viewport-spanning container height.
Page Context Loading State
packages/chronicle/src/lib/page-context.tsx
PageProvider adds isLoading state and currentPathRef guard; fetchApiSpecs and fetchPageData callbacks manage async fetches with error handling; route handlers updated to use callbacks with cancellation support.
Theme Exports
packages/chronicle/src/themes/default/index.ts, packages/chronicle/src/themes/paper/index.ts
defaultTheme and paperTheme objects include Skeleton: PageSkeleton mapping; both modules export PageSkeleton alongside existing components.
DocsPage Integration
packages/chronicle/src/pages/DocsPage.tsx
DocsPage destructures isLoading and errorStatus from context; retrieves both Page and Skeleton from theme; conditionally renders Skeleton while loading or when page unavailable.

Possibly Related PRs

Suggested Reviewers

  • rohilsurana
  • rohanchkrabrty

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately describes the main feature being added: skeleton loaders for page navigation. It matches the primary change across all modified files.
Description check ✅ Passed The description is directly related to the changeset, detailing the key changes including isLoading state, refactored PageProvider, Skeleton interface extension, and skeleton implementations for themes.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat_skeleton_loaders

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/chronicle/src/lib/page-context.tsx (1)

61-63: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Remove unused isApisRoute — CI is failing on this.

The function is never called; the API route branch in useEffect already uses route.type === RouteType.ApiIndex || route.type === RouteType.ApiPage directly.

🔧 Proposed fix
-function isApisRoute(pathname: string): boolean {
-  return pathname === '/apis' || pathname.startsWith('/apis/');
-}
-
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/chronicle/src/lib/page-context.tsx` around lines 61 - 63, The
function isApisRoute in page-context.tsx is unused and causing CI to fail;
remove the entire isApisRoute function declaration (function
isApisRoute(pathname: string): boolean { ... }) and any associated imports that
only existed for it, and verify there are no remaining references to isApisRoute
(the code already checks route.type === RouteType.ApiIndex ||
RouteType.ApiPage). After deletion, run tests/CI to confirm the unused symbol
error is resolved.
🧹 Nitpick comments (1)
packages/chronicle/src/lib/page-context.tsx (1)

108-114: 💤 Low value

Move PageData interface to module scope.

TypeScript interfaces declared inside a function body are syntactically legal but unusual and can confuse tooling. Hoisting it alongside the other type declarations at module scope makes it independently documentable and reusable.

♻️ Proposed refactor
+interface PageData {
+  frontmatter: Frontmatter;
+  relativePath: string;
+  originalPath?: string;
+  prev?: PageNavLink | null;
+  next?: PageNavLink | null;
+}
+
 export function PageProvider(...) {
   ...
-  interface PageData {
-    frontmatter: Frontmatter;
-    relativePath: string;
-    originalPath?: string;
-    prev?: PageNavLink | null;
-    next?: PageNavLink | null;
-  }
-
   const fetchPageData = useCallback(async (slug: string[]): Promise<PageData> => {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/chronicle/src/lib/page-context.tsx` around lines 108 - 114, The
PageData interface is currently declared inside a function scope; move its
declaration to module scope alongside other type declarations so it’s reusable
and discoverable. Locate the PageData interface, cut it out of the function
body, and paste it at the top-level of the module with the other interfaces
(keeping the same properties: frontmatter, relativePath, originalPath?, prev?,
next?); ensure any references to PageData (e.g., in function signatures or
generics) remain unchanged and import/export behavior is preserved if
applicable.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/chronicle/src/lib/page-context.tsx`:
- Around line 116-130: When starting a new docs navigation, clear any stale
page/error synchronously so the skeleton stays visible during the entire
fetch+MDX load: before invoking the async IIFE that calls fetchPageData and
loadMdx, call setPage(null) and setErrorStatus(null) (the minimal fix) so !page
remains true until the IIFE finishes; alternatively, for a more robust fix move
setIsLoading(true)/setIsLoading(false) out of fetchPageData/fetchApiSpecs and
wrap the entire effect (fetch + loadMdx) in a single loading scope, but do not
change render guards in DocsPage.
- Around line 116-130: The try/catch in fetchPageData is a no-op because the
catch only rethrows; remove the catch and wrap the fetch logic in a try/finally
so setIsLoading(false) still runs. Edit the fetchPageData function to drop the
catch block (leaving the try with the fetch, res.ok check and return await
res.json()) and keep the finally that calls setIsLoading(false) so errors
propagate naturally; reference: fetchPageData and setIsLoading.

In `@packages/chronicle/src/themes/paper/Page.module.css`:
- Around line 241-244: .headerLoader sets align-items: center but lacks display:
flex, so centering won't work; update the CSS rule for .headerLoader to make it
a flex container (add display: flex) so align-items takes effect, and ensure
this class is applied to the wrapper passed as containerClassName to the
<Skeleton> component so the skeleton content is vertically centered.

In `@packages/chronicle/src/themes/paper/Skeleton.tsx`:
- Line 1: Remove the unused Flex import from the module import statement in
Skeleton.tsx: locate the import line that currently imports { Flex, Skeleton }
and delete Flex so only Skeleton is imported; this removes the unused symbol
causing the CI/linter failure and leaves the Skeleton component usage intact.

In `@packages/chronicle/src/types/theme.ts`:
- Line 23: The Theme interface currently requires Skeleton: React.ComponentType
which breaks existing themes; make the Skeleton property optional on the Theme
interface (i.e., Skeleton?: React.ComponentType) so older theme objects still
type-check, and update DocsPage (where Skeleton is used) to guard its render by
checking for theme.Skeleton and falling back to a default or null when absent;
ensure getTheme continues to provide Skeleton for built-in themes so runtime
behavior is unchanged.

---

Outside diff comments:
In `@packages/chronicle/src/lib/page-context.tsx`:
- Around line 61-63: The function isApisRoute in page-context.tsx is unused and
causing CI to fail; remove the entire isApisRoute function declaration (function
isApisRoute(pathname: string): boolean { ... }) and any associated imports that
only existed for it, and verify there are no remaining references to isApisRoute
(the code already checks route.type === RouteType.ApiIndex ||
RouteType.ApiPage). After deletion, run tests/CI to confirm the unused symbol
error is resolved.

---

Nitpick comments:
In `@packages/chronicle/src/lib/page-context.tsx`:
- Around line 108-114: The PageData interface is currently declared inside a
function scope; move its declaration to module scope alongside other type
declarations so it’s reusable and discoverable. Locate the PageData interface,
cut it out of the function body, and paste it at the top-level of the module
with the other interfaces (keeping the same properties: frontmatter,
relativePath, originalPath?, prev?, next?); ensure any references to PageData
(e.g., in function signatures or generics) remain unchanged and import/export
behavior is preserved if applicable.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4fbaf86f-e6c0-4fd9-a59a-3f6db7cc2f6a

📥 Commits

Reviewing files that changed from the base of the PR and between f0630e8 and 8908d22.

📒 Files selected for processing (8)
  • packages/chronicle/src/lib/page-context.tsx
  • packages/chronicle/src/pages/DocsPage.tsx
  • packages/chronicle/src/themes/default/Skeleton.tsx
  • packages/chronicle/src/themes/default/index.ts
  • packages/chronicle/src/themes/paper/Page.module.css
  • packages/chronicle/src/themes/paper/Skeleton.tsx
  • packages/chronicle/src/themes/paper/index.ts
  • packages/chronicle/src/types/theme.ts

Comment thread packages/chronicle/src/lib/page-context.tsx
Comment thread packages/chronicle/src/themes/paper/Page.module.css
Comment thread packages/chronicle/src/themes/paper/Skeleton.tsx Outdated
Comment thread packages/chronicle/src/types/theme.ts
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread packages/chronicle/src/lib/page-context.tsx Outdated
@rohanchkrabrty rohanchkrabrty merged commit b372853 into main May 7, 2026
4 checks passed
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