Skip to content

feat: Add SWR local storage cache layer for offline dashboard resiliency#2883

Open
dhruvil-1207 wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
dhruvil-1207:feat/dashboard-swr-cache
Open

feat: Add SWR local storage cache layer for offline dashboard resiliency#2883
dhruvil-1207 wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
dhruvil-1207:feat/dashboard-swr-cache

Conversation

@dhruvil-1207

Copy link
Copy Markdown

Fixes #2801

Description

Implemented a lightweight client-side data resiliency layer using a Stale-While-Revalidate (SWR) model for the core dashboard widgets.

This ensures that if a developer works on a spotty local network or encounters GitHub API rate-limits, the dashboard avoids crashing or showing endless loading spinners by instantly hydrating from a local snapshot while syncing live data in the background.

Changes Made

  • PRMetrics, StreakTracker, and GoalTracker: Intercepted incoming API dashboard metrics payloads.
  • Added localStorage caching with timestamps.
  • Implemented immediate UI hydration on load using the saved snapshot.
  • Added silent background fetching to fetch live data and overwrite the stale snapshot without disrupting the user layout.
  • Handled errors gracefully so the dashboard doesn't crash if localStorage is completely empty or disabled.

Testing

  • Tested locally by simulating an "Offline" network in Chrome DevTools.
  • Verified that widgets instantly display cached data on hard refresh.
  • Confirmed that failed background requests are quietly swallowed, preventing UI crashes.

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:feature GSSoC type bonus: new feature type:bug GSSoC type bonus: bug fix type:design GSSoC type bonus: UI/design (+10 pts) type:performance GSSoC type bonus: performance (+15 pts) and removed gssoc26 GSSoC 2026 contribution labels Jun 27, 2026
@github-actions

Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug GSSoC type bonus: bug fix type:design GSSoC type bonus: UI/design (+10 pts) type:feature GSSoC type bonus: new feature type:performance GSSoC type bonus: performance (+15 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] Add Stale-While-Revalidate (SWR) Local Storage Cache Layer for Offline Dashboard Resiliency

1 participant