Repository navigation
feat(docs): server-render docs behind a persistent sidebar with hash deep-link scrolling - #61
Conversation
Move the doc tree into a docs layout so it stays mounted across doc navigation instead of remounting and flashing. Server-render the list into the sidebar and hydrate the doc read view through a server prefetch, so first paint is complete and loading skeletons cover only the content pane.
The browser's native hash scroll fires before the doc content and its heading ids exist, so a link like /d/<token>#a-heading lands at the top. Scroll the matching heading into view once the reader mounts and whenever the hash changes, on both the public and internal reading views.
There was a problem hiding this comment.
pulkitxm has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 47 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThe docs area now uses shared shell and sidebar components, route-level React Query hydration, a permission-aware empty pane, pane-specific loading skeletons, centralized list payload construction, and hash-based heading navigation. ChangesDocs data hydration
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant DocsRoute
participant DocsLayout
participant DocsSidebar
participant DocSurface
participant DocsQuery
DocsRoute->>DocsLayout: render docs route
DocsLayout->>DocsQuery: prefetch docs list
DocsQuery-->>DocsLayout: dehydrated list state
DocsLayout->>DocsSidebar: render sidebar with write permission
DocsRoute->>DocsQuery: prefetch document detail
DocsQuery-->>DocSurface: hydrated document state
DocsSidebar->>DocsRoute: navigate to selected document or new document
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/web/src/app/(app)/docs/[id]/page.tsx (1)
10-25: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winValidate the route parameters before fetching.
idandeditare URL-controlled values. Parse them with a shared Zod schema before passingidtodehydratedDocor deriving edit mode.As per coding guidelines, validate every external input with Zod.
🤖 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 `@apps/web/src/app/`(app)/docs/[id]/page.tsx around lines 10 - 25, Update DocPage to validate the resolved route and query values with the shared Zod schema before using them: validate id before passing it to dehydratedDoc, and validate edit before deriving startEditing. Reuse the repository’s existing schema/validation conventions and use the parsed values rather than the raw URL-controlled inputs.Source: Coding guidelines
🧹 Nitpick comments (1)
apps/web/src/features/docs/use-hash-scroll.test.tsx (1)
77-89: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd regression coverage for
hashchange.The suite currently verifies initial mount scrolling and the empty-hash case, but not the listener path introduced by
useHashScroll. Render the reader first, change the hash afterward, and assert that the matching heading scrolls.🤖 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 `@apps/web/src/features/docs/use-hash-scroll.test.tsx` around lines 77 - 89, Add a regression test in the “reader hash deep link” suite that renders via renderReader with no initial hash, changes window.location.hash afterward to a known heading such as rules, and waits for scrolled to contain that heading. Exercise the useHashScroll hashchange listener path rather than only initial mount behavior.
🤖 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 `@apps/web/src/app/api/docs/route.ts`:
- Around line 5-6: Validate searchParamsOf(request) with the shared docs-list
filter Zod schema in the GET handler before passing it to docListPayload. In
apps/web/src/lib/api/docs.ts lines 8-10, replace the filter: unknown parameter
with the schema-inferred filter type; update both affected sites accordingly.
In `@apps/web/src/features/docs/doc-reader.tsx`:
- Line 49: Update the useHashScroll readiness token in the document reader to
include the current document’s identity along with the joined heading IDs.
Preserve the existing heading-ID behavior while ensuring navigation to a
different document produces a distinct token even when headings and URL hash are
unchanged.
In `@apps/web/src/features/docs/doc-surface.tsx`:
- Around line 132-134: Update the useEffect that sets unsavedDocId in the
document surface to return a cleanup function that calls setUnsavedDocId(null)
when the pane unmounts or its dependencies change, while preserving the existing
marker-setting behavior.
In `@apps/web/src/lib/query/docs-prefetch.ts`:
- Around line 19-27: Update the detail-fetch error handling around getDoc in
docs-prefetch.ts to catch only the typed not-found domain error and return null
for that case. Ensure authorization, database, rendering, and all other failures
are rethrown so they reach the request’s error handling path, using the typed
error symbol from `@orbit/shared/errors`.
---
Outside diff comments:
In `@apps/web/src/app/`(app)/docs/[id]/page.tsx:
- Around line 10-25: Update DocPage to validate the resolved route and query
values with the shared Zod schema before using them: validate id before passing
it to dehydratedDoc, and validate edit before deriving startEditing. Reuse the
repository’s existing schema/validation conventions and use the parsed values
rather than the raw URL-controlled inputs.
---
Nitpick comments:
In `@apps/web/src/features/docs/use-hash-scroll.test.tsx`:
- Around line 77-89: Add a regression test in the “reader hash deep link” suite
that renders via renderReader with no initial hash, changes window.location.hash
afterward to a known heading such as rules, and waits for scrolled to contain
that heading. Exercise the useHashScroll hashchange listener path rather than
only initial mount behavior.
🪄 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: 125b7a23-9c28-4ea0-8667-0acd73178576
📒 Files selected for processing (22)
apps/web/src/app/(app)/docs/[id]/loading.tsxapps/web/src/app/(app)/docs/[id]/page.tsxapps/web/src/app/(app)/docs/layout.tsxapps/web/src/app/(app)/docs/loading.tsxapps/web/src/app/(app)/docs/page.tsxapps/web/src/app/api/docs/route.tsapps/web/src/components/keyboard-hints.test.tsxapps/web/src/features/docs/doc-reader.tsxapps/web/src/features/docs/doc-surface.tsxapps/web/src/features/docs/docs-empty-pane.tsxapps/web/src/features/docs/docs-shell.tsxapps/web/src/features/docs/docs-sidebar.test.tsxapps/web/src/features/docs/docs-sidebar.tsxapps/web/src/features/docs/docs-skeleton.test.tsxapps/web/src/features/docs/docs-skeleton.tsxapps/web/src/features/docs/docs-workspace.tsxapps/web/src/features/docs/outline.test.tsapps/web/src/features/docs/use-docs-tree.tsapps/web/src/features/docs/use-hash-scroll.test.tsxapps/web/src/features/docs/use-hash-scroll.tsapps/web/src/lib/api/docs.tsapps/web/src/lib/query/docs-prefetch.ts
💤 Files with no reviewable changes (1)
- apps/web/src/features/docs/docs-workspace.tsx
Validate the doc list filter with docFilterSchema at the route boundary, fold the doc id into the hash-scroll readiness token so a switch between docs that share a heading id still scrolls, clear the unsaved marker when the doc pane unmounts, and only swallow a not-found detail prefetch while rethrowing every other failure.
There was a problem hiding this comment.
pulkitxm has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
Persist the doc tree in a docs layout, server-render the read view and tree data via hydration, and auto-scroll hash deep links into view.