Skip to content

Reuse existing tanstack queries#2947

Merged
dimaMachina merged 5 commits intomainfrom
reuse-existing-tanstack-queries
Apr 1, 2026
Merged

Reuse existing tanstack queries#2947
dimaMachina merged 5 commits intomainfrom
reuse-existing-tanstack-queries

Conversation

@dimaMachina
Copy link
Copy Markdown
Collaborator

No description provided.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 1, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agents-api Ready Ready Preview, Comment Apr 1, 2026 2:12pm
agents-docs Ready Ready Preview, Comment Apr 1, 2026 2:12pm
agents-manage-ui Ready Ready Preview, Comment Apr 1, 2026 2:12pm

Request Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 1, 2026

🦋 Changeset detected

Latest commit: b0192f0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 10 packages
Name Type
@inkeep/agents-manage-ui Patch
@inkeep/agents-api Patch
@inkeep/agents-cli Patch
@inkeep/agents-core Patch
@inkeep/agents-email Patch
@inkeep/agents-mcp Patch
@inkeep/agents-sdk Patch
@inkeep/agents-work-apps Patch
@inkeep/ai-sdk-provider Patch
@inkeep/create-agents Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dimaMachina
Copy link
Copy Markdown
Collaborator Author

@claude add a changeset

@inkeep-internal-ci
Copy link
Copy Markdown
Contributor

inkeep-internal-ci Bot commented Apr 1, 2026

Claude finished @dimaMachina's task in 51s —— View job


Adding changeset

  • Analyze PR changes
  • Create changeset

Added a patch changeset for @inkeep/agents-manage-ui: "Reuse existing TanStack Query hooks for project fetching instead of manual fetch calls"

Pushed in commit b0192f0.
|

@pullfrog
Copy link
Copy Markdown
Contributor

pullfrog Bot commented Apr 1, 2026

TL;DR — Replaces ad-hoc fetchProjects calls in three manage-UI pages with the shared useProjectsQuery TanStack Query hook, eliminating duplicate fetches and local state for the projects list.

Key changes

  • Replace manual project fetching with useProjectsQuery in billing page — Drops the projectCount state and fetchProjects call from the Promise.all, using the cached query result instead.
  • Replace manual project fetching with useProjectsQuery in cost page — Removes the useEffect + useState pair for projects in favor of the shared query hook.
  • Replace manual project fetching with useProjectsQuery in ProjectAccessDialog — Decouples project loading from membership loading, renames loadingloadingMemberships for clarity, and derives combined loading state.
  • Remove useProjectActions from Biome stable-result list — Cleans up an entry that is no longer needed.
  • Add changeset for @inkeep/agents-manage-ui — Patch-level changeset documenting the hook reuse.

Summary | 5 files | 5 commits | base: mainreuse-existing-tanstack-queries


Shared useProjectsQuery hook replaces imperative fetches

Before: Each page independently called fetchProjects(tenantId) inside useEffect or Promise.all, storing results in local useState. Multiple pages mounting simultaneously would fire separate network requests for the same data.
After: All three consumers use the existing useProjectsQuery hook backed by TanStack Query, so projects are fetched once and shared across components via the query cache.

In ProjectAccessDialog, the enabled: open option ensures the query only fires when the dialog is visible. The previously monolithic loading state is split: isProjectsFetching tracks the query, while loadingMemberships tracks the membership API call. A derived loading combines both before render.

billing/page.tsx · cost/page.tsx · project-access-dialog.tsx · biome.jsonc

Pullfrog  | View workflow run | Triggered by Pullfrog | Using Claude Opus𝕏

Copy link
Copy Markdown
Contributor

@pullfrog pullfrog Bot left a comment

Choose a reason for hiding this comment

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

Clean refactor — replaces ad-hoc fetchProjects calls and local state with the shared useProjectsQuery hook across billing, cost, and project-access-dialog. No behavioral regressions spotted; initialData: [] in the query hook ensures projects is always an array, so the .length / .map() call sites are safe. The biome.jsonc cleanup correctly removes a stale useProjectActions entry that no longer exists in the codebase.

Pullfrog  | View workflow run | Using Claude Opus𝕏

@github-actions github-actions Bot deleted a comment from claude Bot Apr 1, 2026
@dimaMachina dimaMachina added this pull request to the merge queue Apr 1, 2026
Merged via the queue into main with commit d27011a Apr 1, 2026
25 of 26 checks passed
@dimaMachina dimaMachina deleted the reuse-existing-tanstack-queries branch April 1, 2026 14:30
Gaurav-Narayan-Varma pushed a commit that referenced this pull request Apr 1, 2026
* upd

* upd

* upd

* upd

* Add changeset for reusing TanStack Query hooks

Co-authored-by: Dimitri POSTOLOV <[email protected]>

---------

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Dimitri POSTOLOV <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant