Skip to content

refactor(api): Migrate hooks to React Query and centralize query logic - #7206

Open
balazs-szucs wants to merge 18 commits into
Stirling-Tools:mainfrom
balazs-szucs:misc-tanstack
Open

refactor(api): Migrate hooks to React Query and centralize query logic#7206
balazs-szucs wants to merge 18 commits into
Stirling-Tools:mainfrom
balazs-szucs:misc-tanstack

Conversation

@balazs-szucs

Copy link
Copy Markdown
Collaborator

Description of Changes

Migrates misc to Tanstack. Main aim: better perf. Some centralization also.

Changes:

  • Refactored AppConfigProvider to use React Query (useQuery) for fetching and caching app configuration, replacing custom state and retry logic with query-based management. This improves error handling, retry behavior, and integration with other data-fetching logic.
  • Added helper functions for extracting error messages and HTTP status from errors, and centralized the logic for handling simulated configs and 401 responses.
  • Wrapped the core AppProviders tree with a QueryClientProvider and initialized the query client using useState, ensuring all child components have access to React Query context.
  • Updated the AppProviders signature and structure to support the new provider hierarchy.

Checklist

General

Documentation

Translations (if applicable)

UI Changes (if applicable)

  • Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR)

Testing (if applicable)

  • I have run task check to verify linters, typechecks, and tests pass
  • I have tested my changes locally. Refer to the Testing Guide for more details.

Copilot AI review requested due to automatic review settings July 30, 2026 18:52
@dosubot dosubot Bot added size:XL This PR changes 500-999 lines ignoring generated files. enhancement New feature or request labels Jul 30, 2026
@stirlingbot stirlingbot Bot added Front End Issues or pull requests related to front-end development API API-related issues or pull requests and removed enhancement New feature or request labels Jul 30, 2026
@stirlingbot stirlingbot Bot added the refactor Code changes that neither fix a bug nor add a feature label Jul 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Refactors frontend configuration/availability hooks to use TanStack React Query, centralizing fetch logic and query keys so config and feature-availability data is cached, deduped, and easier to invalidate consistently across the app.

Changes:

  • Migrated AppConfigProvider, endpoint availability, and group-enabled checks to useQuery with shared query keys and endpoint fetch helpers.
  • Added an editor-scoped QueryClientProvider and a shared QueryClient factory with default query behavior.
  • Updated/added test wrappers to provide QueryClientProvider for hooks that now depend on React Query context.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
frontend/editor/src/desktop/hooks/useSaasAppConfig.ts Moves SaaS app-config reads to React Query with invalidation on connection-mode changes.
frontend/editor/src/desktop/hooks/useGroupEnabled.ts Uses React Query for group-enabled checks while preserving offline short-circuit behavior.
frontend/editor/src/core/queryClient.ts Adds a shared QueryClient factory for editor defaults.
frontend/editor/src/core/queries/keys.ts Centralizes editor React Query keys.
frontend/editor/src/core/queries/endpoints.ts Centralizes endpoint/group-enabled fetch functions and endpoint availability normalization.
frontend/editor/src/core/hooks/usePosthogTracking.test.tsx Updates tests to wrap hooks in QueryClientProvider.
frontend/editor/src/core/hooks/useGroupEnabled.ts Migrates OSS group-enabled hook to React Query.
frontend/editor/src/core/hooks/useEndpointConfig.ts Migrates endpoint availability hooks to React Query with a shared invalidation helper.
frontend/editor/src/core/contexts/AppConfigContext.tsx Refactors AppConfigProvider to use React Query (retry, auth-page gating, invalidation).
frontend/editor/src/core/contexts/AppConfigContext.test.tsx Updates AppConfigContext tests to include QueryClientProvider.
frontend/editor/src/core/components/AppProviders.tsx Wraps the provider tree with QueryClientProvider and instantiates a stable client via useState.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread frontend/editor/src/core/hooks/useGroupEnabled.ts Outdated
Comment thread frontend/editor/src/desktop/hooks/useGroupEnabled.ts
Comment thread frontend/editor/src/core/hooks/useEndpointConfig.ts Outdated
Comment thread frontend/editor/src/core/contexts/AppConfigContext.tsx Outdated
@balazs-szucs

Copy link
Copy Markdown
Collaborator Author

/deploypr

@stirlingbot stirlingbot Bot added the has conflicts Pull request has merge conflicts with the base branch label Aug 4, 2026
# Conflicts:
#	frontend/editor/src/core/components/AppProviders.tsx
#	frontend/editor/src/core/hooks/useGroupEnabled.ts
#	frontend/editor/src/desktop/hooks/useGroupEnabled.ts
@stirlingbot stirlingbot Bot removed the has conflicts Pull request has merge conflicts with the base branch label Aug 6, 2026
@stirlingbot stirlingbot Bot added the has conflicts Pull request has merge conflicts with the base branch label Aug 7, 2026
# Conflicts:
#	frontend/editor/src/core/contexts/AppConfigContext.test.tsx
#	frontend/editor/src/core/contexts/AppConfigContext.tsx
#	frontend/editor/src/core/hooks/usePosthogTracking.test.tsx
@stirlingbot stirlingbot Bot added has conflicts Pull request has merge conflicts with the base branch and removed has conflicts Pull request has merge conflicts with the base branch labels Aug 7, 2026
@stirlingbot stirlingbot Bot removed the has conflicts Pull request has merge conflicts with the base branch label Aug 7, 2026
@stirlingbot stirlingbot Bot added the has conflicts Pull request has merge conflicts with the base branch label Aug 10, 2026
# Conflicts:
#	frontend/editor/src/core/hooks/useEndpointConfig.ts
@balazs-szucs
balazs-szucs requested a review from a team as a code owner August 16, 2026 20:47
@dosubot dosubot Bot added size:L This PR changes 100-499 lines ignoring generated files. and removed size:XL This PR changes 500-999 lines ignoring generated files. labels Aug 16, 2026
@github-actions github-actions Bot removed the has conflicts Pull request has merge conflicts with the base branch label Aug 16, 2026
@github-actions github-actions Bot added the has conflicts Pull request has merge conflicts with the base branch label Aug 27, 2026
@Frooodle

Copy link
Copy Markdown
Member

A lot of this tanstack got done by @ConnorYoh how much of this PR should remain?

@github-actions github-actions Bot removed the has conflicts Pull request has merge conflicts with the base branch label Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API API-related issues or pull requests Front End Issues or pull requests related to front-end development refactor Code changes that neither fix a bug nor add a feature size:L This PR changes 100-499 lines ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants