refactor: migrate hooks to React Query for data fetching (#2536)
## Summary
- Replaced manual `useState`/`useEffect` data fetching patterns with
React Query's `useQuery` and `useMutation` in `useSettings`,
`useLoadAppFile`, `useLoadApps`, `useAppVersion`, and related hooks
- Added centralized query keys for `system`, `settings`, `appFiles`, and
`github` domains in `queryKeys.ts`
- Added new `useGithubRepos` and `useSystemPlatform` hooks using React
Query
- Simplified `TitleBar` and `ImportAppDialog` to use the updated hook
interfaces
## Test plan
- All 784 unit tests pass
- Verify settings load correctly on app startup
- Verify file loading works in the code viewer
- Verify app list loads and refreshes properly
- Verify title bar shows correct app version
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- devin-review-badge-begin -->
---
<a href="https://app.devin.ai/review/dyad-sh/dyad/pull/2536"
target="_blank">
<picture>
<source media="(prefers-color-scheme: dark)"
srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1">
<img
src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1"
alt="Open with Devin">
</picture>
</a>
<!-- devin-review-badge-end -->
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Touches core loading paths (settings, app list, file reads) and
caching/invalidations, so regressions could show up as stale data or
missing refreshes; changes are mostly refactors with minimal behavioral
intent.
>
> **Overview**
> **Migrates several app/system/settings data flows from local
state/Jotai-driven fetching to React Query.** `useLoadApps`,
`useLoadAppFile`, `useAppVersion`, and `useSettings` now use
`useQuery`/`useMutation` with cache updates and refresh via query
invalidation, and app favorites (`useAddAppToFavorite`) update the React
Query apps cache instead of an `appsListAtom` (which is removed).
>
> Adds new React Query-powered hooks (`useSystemPlatform`,
`useGithubRepos`) and extends `queryKeys` with `system`, `settings`,
`appFiles`, and `github` domains; UI callers (`TitleBar`,
`ImportAppDialog`, `app-details`) are adjusted to consume the new hooks.
E2E favorite-app tests are hardened by hovering before clicks and using
a longer assertion timeout.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
c82dfca589d0186d25cec33a2453fc5b3f28520b. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Migrated core data fetching to React Query to standardize caching,
loading, and error handling. Cleaned up UI and tests, removed the apps
Jotai atom, and made refresh flows consistent via query invalidation.
- **Refactors**
- Replaced manual state/effect with useQuery/useMutation in useSettings,
useLoadApps, useLoadAppFile, and useAppVersion.
- Centralized query keys for system, settings, appFiles, and github in
queryKeys.ts.
- Removed appsListAtom; apps now read/write via React Query. Kept Jotai
sync for settings and env vars.
- Simplified TitleBar (uses useSystemPlatform), ImportAppDialog (uses
useGithubRepos), and app-details (reads apps from useLoadApps).
- Updated useAddAppToFavorite to update the React Query cache.
- Reduced flakiness in favorite app e2e tests by hovering before clicks
and using a medium timeout.
- **New Features**
- Added useGithubRepos and useSystemPlatform hooks with session-level
caching.
<sup>Written for commit c82dfca589d0186d25cec33a2453fc5b3f28520b.
Summary will update on new commits.</sup>
<!-- End of auto-generated description by cubic. -->
---------
Co-authored-by:
Claude Opus 4.6 <noreply@anthropic.com>
正在显示
src/hooks/useGithubRepos.ts
0 → 100644
src/hooks/useSystemPlatform.ts
0 → 100644
请
注册
或者
登录
后发表评论