Skip to content

fix: refresh ListProjects cache after project creation#9391

Merged
ericpgreen2 merged 2 commits intomainfrom
ericgreen/refresh-list-projects-after-create
May 6, 2026
Merged

fix: refresh ListProjects cache after project creation#9391
ericpgreen2 merged 2 commits intomainfrom
ericgreen/refresh-list-projects-after-create

Conversation

@ericpgreen2
Copy link
Copy Markdown
Contributor

@ericpgreen2 ericpgreen2 commented May 5, 2026

  • Fixes a bug where newly created projects didn't appear on the org overview until manual refresh. Root cause: with the global refetchOnMount: false default, invalidateQueries against an unobserved query just marks it stale; nothing refetches on remount.
  • Adopts refetchOnMount: true + staleTime: Infinity on the ListProjects observers — refetches only after invalidation, otherwise reads cache.
  • Consolidates three cache keys (projects, projects?pageSize=100, projects?pageSize=1000) to one by standardizing all eight callers on pageSize: 1000. Also fixes a latent 20-cap bug at sites that passed no pageSize (server default _defaultPageSize = 20 in admin/server/page_token.go).
  • Extracts listProjectsForOrgQueryOptions(org) as a single source of truth for params + policy, delegating queryKey/queryFn to Orval's generated getAdminServiceListProjectsForOrganizationQueryOptions.

Checklist:

  • Covered by tests
  • Ran it and it works as intended
  • Reviewed the diff before requesting a review
  • Checked for unhandled edge cases
  • Linked the issues it closes
  • Checked if the docs need to be updated. If so, create a separate Linear DOCS issue
  • Intend to cherry-pick into the release branch
  • I'm proud of this work!

Developed in collaboration with Claude Code

- Adopts `refetchOnMount: true` + `staleTime: Infinity` on the `ListProjects` observers — refetches only after invalidation, otherwise reads cache.
- Consolidates three cache keys (`projects`, `projects?pageSize=100`, `projects?pageSize=1000`) to one by standardizing all eight callers on `pageSize: 1000`. Also fixes a latent 20-cap bug at sites that passed no `pageSize` (server default `_defaultPageSize = 20`).
- Extracts `listProjectsForOrgQueryOptions(org)` as a single source of truth for params + policy, delegating `queryKey`/`queryFn` to Orval's generated `getAdminServiceListProjectsForOrganizationQueryOptions`.
@ericpgreen2 ericpgreen2 requested a review from a team as a code owner May 5, 2026 18:33
@ericpgreen2 ericpgreen2 requested a review from AdityaHegde May 5, 2026 18:34
@ericpgreen2 ericpgreen2 self-assigned this May 5, 2026
@ericpgreen2 ericpgreen2 merged commit e9241a8 into main May 6, 2026
11 checks passed
@ericpgreen2 ericpgreen2 deleted the ericgreen/refresh-list-projects-after-create branch May 6, 2026 13:39
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.

2 participants