Skip to content

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

Description

@dhruvil-1207

Problem Statement

When developers work on a spotty local network, travel, or encounter temporary GitHub API rate-limiting blocks, the core dashboard widgets can freeze, display heavy loading spinners, or drop into empty un-hydrated states. There is currently no persistent client-side state backup to display immediate fallback metric snapshots.

Proposed Solution

Implement a lightweight client-side data resiliency layer using a Stale-While-Revalidate (SWR) model:

  1. Local Snapshot Storage: Intercept successful incoming API dashboard metrics payloads (commit streaks, PR tracking analytics, goals) and store them as a stringified JSON snapshot in localStorage with a timestamp.
  2. Instant Hydration & Silent Sync: On initial dashboard load, immediately populate UI cards with the saved localStorage snapshot if available. Concurrently dispatch a background fetch request to sync live data and silently update the layout state once resolved.

Feature Area

Dashboard

Alternatives Considered

  • Forcing strict loading states: Keeping the layout blocked behind a continuous loading spinner panel until a live network bridge resolves, which hurts UX speed and breaks accessibility during offline sessions.

Acceptance Criteria

  • Dashboard displays the last cached metrics instantly on hard refresh without a prolonged blank loading state.
  • Toggling the browser network connection to "Offline" retains existing metric values instead of crashing widget components.
  • Background network requests silently overwrite the stale local storage baseline metrics once internet connectivity re-establishes.
  • Proper handling ensures zero runtime crashes if localStorage is completely empty or disabled by browser flags.

Additional Context

This is an isolated client-side enhancement focused purely on developer experience (DX) and frontend speed optimization. I am a GSSoC '26 contributor and am ready to build this caching wrapper cleanly. Could you please review and assign this issue to me?

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestgssoc:assignedGSSoC: Issue assigned to a contributorneeds-triageNeeds maintainer triage

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions