Skip to content

refactor(web): migrate to SWR for data fetching#585

Open
silent-cipher wants to merge 3 commits into
mainfrom
refactor/swr-data-fetching
Open

refactor(web): migrate to SWR for data fetching#585
silent-cipher wants to merge 3 commits into
mainfrom
refactor/swr-data-fetching

Conversation

@silent-cipher
Copy link
Copy Markdown
Collaborator

closes #474

Copilot AI review requested due to automatic review settings May 30, 2026 17:54
@FilOzzy FilOzzy added this to FOC May 30, 2026
@github-project-automation github-project-automation Bot moved this to 📌 Triage in FOC May 30, 2026
@silent-cipher silent-cipher self-assigned this May 30, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the web app’s config/providers data fetching to SWR to ensure requests like /api/config are deduplicated and cached across multiple consumers (addressing duplicate fetches noted in #474).

Changes:

  • Add SWR and configure global SWR defaults in the web app entrypoint.
  • Refactor useNetworkConfig and useProvidersList to use SWR with shared fetcher + cache keys (apiPaths).
  • Update web tests to mock SWR-backed hooks and isolate SWR cache per test where needed.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pnpm-lock.yaml Adds swr dependency and updates lockfile snapshot entries.
apps/web/package.json Declares swr as a web dependency.
apps/web/src/main.tsx Wraps the app in SWRConfig to set global SWR options.
apps/web/src/api/client.ts Introduces a generic SWR fetcher and centralized apiPaths key builders.
apps/web/src/hooks/useProvidersList.ts Migrates providers list fetching to SWR.
apps/web/src/hooks/useNetworkConfig.ts Migrates /api/config fetching to SWR for shared caching.
apps/web/src/pages/Landing.test.tsx Mocks useNetworkConfig to avoid SWR-backed network/config behavior in this test.
apps/web/src/components/shared/Network/NetworkSwitcher.test.tsx Wraps renders with SWRConfig using a fresh cache per test.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread apps/web/src/hooks/useNetworkConfig.ts Outdated
Comment thread apps/web/src/hooks/useProvidersList.ts Outdated
Comment thread apps/web/src/hooks/useProvidersList.ts
@BigLep BigLep moved this from 📌 Triage to 🔎 Awaiting review in FOC Jun 1, 2026
@BigLep BigLep requested a review from SgtPooki June 1, 2026 00:21
@BigLep
Copy link
Copy Markdown
Contributor

BigLep commented Jun 1, 2026

@silent-cipher : I wanted to check: is there any issues with merging in this work before GA? I want to make sure we don't impact GA with adding multiple-network support to dealbot. We absolutely should get that added to dealbot, but I'd preferr to live with the status quo to keep us stable at the moment.

@silent-cipher
Copy link
Copy Markdown
Collaborator Author

No, I don't see any issues with merging this before GA. Agreed that stability is what we should optimize for right now.

@BigLep BigLep added this to the M4.5: GA Fast Follows milestone Jun 2, 2026
Copy link
Copy Markdown
Collaborator

@SgtPooki SgtPooki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, but one change requested.. up to you

Comment thread apps/web/src/hooks/useNetworkConfig.ts Outdated
@socket-security
Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedaxios@​1.13.5982510095100
Addedfilecoin-pin@​0.21.07810010094100
Addedany-signal@​4.2.01001009781100
Addedclass-transformer@​0.5.110010010082100
Addedclass-validator@​0.14.310010010084100
Addedassemblyscript@​0.19.23951008592100
Addedcron@​4.4.010010010086100

View full report

@BigLep BigLep moved this from 🔎 Awaiting review to ✔️ Approved by reviewer in FOC Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✔️ Approved by reviewer

Development

Successfully merging this pull request may close these issues.

optimize useNetworkConfig /api/config fetch calls

5 participants