Repository navigation
fix: restore docs width before first paint - #1383
Conversation
|
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
tanstack-com | c8f8318 | Oct 15 2026, 11:21 PM |
There was a problem hiding this comment.
🔇 Additional comments: 5
src/utils/docs-width.ts: 1
3-3: LGTM!src/routes/__root.tsx: 1
58-58: LGTM!The static analysis hint on Line 360 is a false positive.
DOCS_WIDTH_BOOTSTRAPis a compile-time constant and does not contain user input. The existingTHEME_BOOTSTRAPscript uses the same pattern.Also applies to: 360-360
tests/docs-width.test.ts: 1
25-25: Test coverage is acceptable. The test clock is deterministic.
Date.nowis stubbed to a fixed value of 1000, so the TTL tests do not depend on system time. This matches the retrieved learning on deterministic time-based tests.src/components/LibraryLayout.tsx: 2
1448-1454: 🎯 Functional CorrectnessThe setter and bootstrap script use compatible values and storage formats.
useLocalStoragestores{ value, ttl: null }when no TTL is supplied. The bootstrap script accepts that shape. It writes100%forvalue: true; the constrained state uses the existing900pxCSS fallback. No change is required.
1448-1454: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.Move the width values into shared constants.
The setter hard-codes
'100%'and'900px'. The container class on Line 1494 repeats900pxas the CSS fallback. The bootstrap script insrc/utils/docs-width.tslikely sets the same variable. These values can drift apart. Export the widths fromsrc/utils/docs-width.tsand reuse them here. Use a CSS variable default in the stylesheet for the class fallback.The change is optional. The code works now.
Source: Learnings
ℹ️ Review info
⚙️ Run configuration
- Configuration used: defaults
- Review profile: CHILL
- Plan: Advanced
- Run ID:
76f39907-e626-4d77-b639-5ba14fd8f0c0
📒 Files selected for processing: 4
src/components/LibraryLayout.tsxsrc/routes/__root.tsxsrc/utils/docs-width.tstests/docs-width.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
Saved expanded docs currently render at 900px before hydration restores the full width. Read the existing preference in the document head and use a CSS width variable so the server-rendered content starts at the right width. The toggle updates that variable and keeps the existing React state and persistence behavior. Missing, expired, invalid or unavailable storage retains the constrained default.
Fixes #948. Thanks to @azizbecha for the original report and the prepaint restoration approach in azizbecha#1.
Verified on current main in a credential-free local app with default Redact. Frame samples at 1700 × 950 reproduced 900px → 1240px before the fix. With the fix, expanded reloads stayed at 1240px from the first sampled frame through hydration, and constrained reloads stayed at 900px. Repeated toggles, navigation between Overview and Quick Start, and the 375px layout also passed. Navigation used public Router docs through the existing local-docs bridge after an unauthenticated GitHub fetch failed.
pnpm testpassed: typechecking, lint, 552 unit tests, 2,269 chat tests and 20 desktop tests, with 4 unit and 1 desktop skips. Three new tests cover initial restoration, expiry and unavailable storage. Browser measurements were on the development app, not a deployed production build.Summary by CodeRabbit