refactor(web): migrate explore app lists from useSWR to TanStack Query #21248

Closed
opened 2026-02-21 20:11:36 -05:00 by yindo · 0 comments
Owner

Originally created by @lyzno1 on GitHub (Dec 24, 2025).

Originally assigned to: @lyzno1 on GitHub.

Summary

Refactor the Explore app list and the create-app-dialog template list to use TanStack Query instead of useSWR for data fetching.

Background

The project is migrating away from useSWR. Explore app lists are still using useSWR and should follow the same TanStack Query patterns used elsewhere.

Scope

Files to Modify

Components:

  • web/app/components/explore/app-list/index.tsx - Uses useSWR for /explore/apps
  • web/app/components/app/create-app-dialog/app-list/index.tsx - Uses useSWR for /explore/apps

Service Layer:

  • web/service/use-explore.ts - Add useExploreAppList
  • web/service/explore.ts - Remove unused functions installApp and getToolProviders (no references in web)

Tests:

  • N/A (no existing specs for these components)

New Hooks to Create

Hook Purpose
useExploreAppList Fetch categories + recommended app list for Explore/create-app-dialog

Implementation Notes

  1. Follow the existing pattern in web/service/use-apps.ts and web/service/use-workflow.ts.
  2. Use a query key under the explore namespace (e.g., [NAME_SPACE, 'appList']).
  3. Preserve the current sort order (recommended_apps sorted by position).
  4. Preserve fallback behavior (use initialData or placeholderData for empty categories/list).

Acceptance Criteria

  • No useSWR imports remain in the two components
  • useExploreAppList exists in web/service/use-explore.ts
  • Unused installApp and getToolProviders are removed from web/service/explore.ts
  • pnpm lint:fix and pnpm type-check:tsgo pass
Originally created by @lyzno1 on GitHub (Dec 24, 2025). Originally assigned to: @lyzno1 on GitHub. ## Summary Refactor the Explore app list and the create-app-dialog template list to use TanStack Query instead of useSWR for data fetching. ## Background The project is migrating away from useSWR. Explore app lists are still using useSWR and should follow the same TanStack Query patterns used elsewhere. ## Scope ### Files to Modify **Components:** - web/app/components/explore/app-list/index.tsx - Uses useSWR for `/explore/apps` - web/app/components/app/create-app-dialog/app-list/index.tsx - Uses useSWR for `/explore/apps` **Service Layer:** - web/service/use-explore.ts - Add `useExploreAppList` - web/service/explore.ts - Remove unused functions `installApp` and `getToolProviders` (no references in web) **Tests:** - N/A (no existing specs for these components) ### New Hooks to Create | Hook | Purpose | | --- | --- | | useExploreAppList | Fetch categories + recommended app list for Explore/create-app-dialog | ## Implementation Notes 1. Follow the existing pattern in `web/service/use-apps.ts` and `web/service/use-workflow.ts`. 2. Use a query key under the `explore` namespace (e.g., `[NAME_SPACE, 'appList']`). 3. Preserve the current sort order (`recommended_apps` sorted by `position`). 4. Preserve fallback behavior (use `initialData` or `placeholderData` for empty categories/list). ## Acceptance Criteria - [ ] No useSWR imports remain in the two components - [ ] `useExploreAppList` exists in `web/service/use-explore.ts` - [ ] Unused `installApp` and `getToolProviders` are removed from `web/service/explore.ts` - [ ] `pnpm lint:fix` and `pnpm type-check:tsgo` pass
yindo added the 💪 enhancement label 2026-02-21 20:11:36 -05:00
yindo closed this issue 2026-02-21 20:11:36 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#21248