Uh oh!
There was an error while loading. Please reload this page.
feat: snapshot calculator - #6715
Conversation
WalkthroughAdds an interactive Snapshot Calculator (React component + CSS) and a new docs page; also inserts two tip blocks into the archival snapshots guide recommending the calculator. The component computes required lite/diff snapshot specs, resolves availability from archive listings, and generates a download script. Changes
Sequence Diagram(s)sequenceDiagram
%% participants
participant User as User
participant UI as SnapshotCalculator (UI)
participant Archive as Archive Listings
participant Downloader as Download System
User->>UI: Enter epoch, select network & mode
UI->>UI: Compute current/base epochs and required snapshot specs
UI->>Archive: Fetch lite listing
UI->>Archive: Fetch diff listing
Archive-->>UI: Return listings
UI->>UI: Build index and resolve specs to URLs/status
UI->>UI: Generate bash/aria2c download script
UI-->>User: Display snapshot list, availability, warnings, and script
User->>Downloader: Copy/run script or click links to download
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
LesnyRumcajs
commented
Mar 11, 2026
Unblocked, now the archive supports |
d259175 to
bc0ea7eCompareThere was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/src/components/SnapshotCalculator/index.tsx`:
- Around line 211-216: When reusing a cached index in the useEffect (check of
cacheRef.current[network]) clear the component error state so a stale warning
isn't shown; inside the early-return branch where you call setIndex(cached),
also reset the error state (e.g., call setError(false) or setError(undefined)
consistent with how error is represented) so that the banner is removed when a
valid cached index is used.
- Around line 174-180: The current endpoints.map block in SnapshotCalculator
(the async callback creating responses) swallows non-2xx responses by returning
an empty items array, which hides 404/500 as “no snapshots”; instead, when
resp.ok is false you should throw an Error (or reject) so Promise.all fails and
the caller can set listingError. Update the async map callback that calls
fetch(ep.url, { signal }) to throw a descriptive error including ep.url and
resp.status (and optionally resp.statusText) when !resp.ok, then parse
resp.json() into ListingResponse and return { type: ep.type, items: data.items
?? [] } as before.
- Around line 107-136: The download script currently treats any snapshot with
downloadUrl === null as "missing" even while listings are still loading; update
generateDownloadScript so the "missing" list only includes snapshots that are
definitively resolved-and-unavailable (e.g., change missing = snapshots.filter(s
=> s.downloadUrl === null && s.<resolvedFlag> === true) or s.status ===
'resolved' depending on the ResolvedSnapshot shape) while keeping available =
snapshots.filter(s => s.downloadUrl !== null); adjust the warning block to use
that new missing list so unresolved/loading entries are not reported as NOT
available.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 8223b02b-c23e-40e2-97c3-221724ea1009
📒 Files selected for processing (4)
docs/docs/users/guides/advanced/archival_snapshots.mddocs/docs/users/guides/advanced/snapshot_calculator.mdxdocs/src/components/SnapshotCalculator/SnapshotCalculator.module.cssdocs/src/components/SnapshotCalculator/index.tsx
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
836b588 to
688a5a8CompareThere was a problem hiding this comment.
🧹 Nitpick comments (1)
docs/src/components/SnapshotCalculator/index.tsx (1)
291-293: Consider handling clipboard API errors.
navigator.clipboard.writeTextreturns a Promise that can reject (e.g., if permissions are denied or the API is unavailable). Silently ignoring failures may confuse users.♻️ Optional: Add minimal error handling
const handleCopyScript = () => { - navigator.clipboard.writeText(downloadScript);+ navigator.clipboard.writeText(downloadScript).catch(() => {+ // Fallback or silent fail - clipboard may be unavailable+ }); };Alternatively, provide user feedback on success/failure if desired.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/src/components/SnapshotCalculator/index.tsx` around lines 291 - 293, handleCopyScript currently calls navigator.clipboard.writeText(downloadScript) without handling rejection; update the handleCopyScript function to await or attach a .catch to navigator.clipboard.writeText(downloadScript) and handle failures (e.g., show an error toast/console.error or fallback to document.execCommand) and optionally confirm success (e.g., success toast) so permission or API failures are not silently ignored; reference the handleCopyScript function, the downloadScript variable, and navigator.clipboard.writeText when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@docs/src/components/SnapshotCalculator/index.tsx`:
- Around line 291-293: handleCopyScript currently calls
navigator.clipboard.writeText(downloadScript) without handling rejection; update
the handleCopyScript function to await or attach a .catch to
navigator.clipboard.writeText(downloadScript) and handle failures (e.g., show an
error toast/console.error or fallback to document.execCommand) and optionally
confirm success (e.g., success toast) so permission or API failures are not
silently ignored; reference the handleCopyScript function, the downloadScript
variable, and navigator.clipboard.writeText when making the change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: d46ae138-98e0-4a21-a195-c0e4cb09df4f
📒 Files selected for processing (4)
docs/docs/users/guides/advanced/archival_snapshots.mddocs/docs/users/guides/advanced/snapshot_calculator.mdxdocs/src/components/SnapshotCalculator/SnapshotCalculator.module.cssdocs/src/components/SnapshotCalculator/index.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
- docs/src/components/SnapshotCalculator/SnapshotCalculator.module.css
- docs/docs/users/guides/advanced/archival_snapshots.md
Summary of changes
Changes introduced in this pull request:
Reference issue to close (if applicable)
Closes#6695
Other information and links
Change checklist
Outside contributions
Summary by CodeRabbit
New Features
Documentation