Skip to content

feat: implement caching for Environments and Schedules pages using React Query - #1246

Merged
harshil-2096 merged 14 commits into
mainfrom
chore/hv/react-query-envs-schedul-page
Nov 20, 2026
Merged

harshil-2096 merged 14 commits into
mainfrom
chore/hv/react-query-envs-schedul-page

Conversation

@harshil-2096

@harshil-2096 harshil-2096 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #

Changes

How was this tested?

Checklist

  • I have read the contributing guidelines
  • pnpm build, pnpm test, pnpm typecheck, pnpm lint:ci, and pnpm format:check pass locally
  • Tests added/updated where it makes sense
  • No hand-edits to generated code (packages/trueforge-sdk, python/trueforge_sdk, .github/fern/openapi/openapi.json, docs/openapi.json) — fork PRs omit SDK regen; maintainers regenerate after merge
  • Docs / .env.example updated if configuration or behavior changed

Note

Medium Risk
Touches permission caching and list consistency for admin-style pages; behavior is fail-closed on permission expansion failures but could briefly show stale grants during refetch.

Overview
Environments and Schedules no longer fetch lists, details, and runs through local useState loaders. They now read through the shared server React Query client (useQuery / useQueries, keepPreviousData), with scoped pagination cursors so page tokens reset when page size or agent filter changes and nav stays disabled while placeholder data is loading.

Mutations (create, update, delete, run now, flags) invalidate the relevant query keys instead of manually reloading; environment pending-status polling patches the cached list via setQueryData.

useResourcePermissions is moved onto React Query as well, reusing prior grants while the id set grows and failing closed on server swaps or failed expansions.

Unit tests cover list cache reuse on remount, refetch/invalidation after delete, pagination cursor safety, pinned-schedule transitions, and run-history error handling.

Reviewed by Cursor Bugbot for commit cc97e08. Bugbot is set up for automated code reviews on this repo. Configure here.

@changeset-bot

changeset-bot Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 91e911e

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

This PR includes changesets to release 1 package
Name Type
@truefoundry/trueforge-ui 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

Base automatically changed from chore/hv/react-query-server-client to main November 20, 2026 09:22
…schedul-page

Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	packages/trueforge-ui/src/atoms/environments/EnvironmentsPage.tsx
#	packages/trueforge-ui/src/atoms/schedules/SchedulesPage.tsx
#	packages/trueforge-ui/test/atoms/schedules/SchedulesPage.test.tsx
#	packages/trueforge-ui/test/server/queryClient.test.tsx
#	pnpm-lock.yaml
@datadog-official

datadog-official Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Code Quality  Code Vulnerabilities  IaC  Library Vulnerabilities  Secrets

⚠️ Warnings

🛠️ 4 Code quality issues detected

Medium: typescript-best-practices/prefer-object-spread Prefer using an object spread over `Object.assign` View rule
packages/trueforge-ui/src/hooks/useResourcePermissions.ts:65
Low: typescript-best-practices/boolean-prop-naming Consistent naming for boolean props View rule
packages/trueforge-ui/test/atoms/schedules/SchedulesPage.test.tsx:637
Low: typescript-best-practices/boolean-prop-naming Consistent naming for boolean props View rule
packages/trueforge-ui/test/atoms/environments/EnvironmentsPage.test.tsx:542
Low: typescript-best-practices/boolean-prop-naming Consistent naming for boolean props View rule
packages/trueforge-ui/src/atoms/schedules/SchedulesPage.tsx:285

ℹ️ Info

No other issues found (see more)

🛡️ No new code vulnerabilities
📚 No new vulnerable libraries detected
🧱 No new Infrastructure as Code (IaC) issues
🔑 No new secrets detected

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: cc97e08 | Docs | Give us feedback!

…flag changes

Co-authored-by: Cursor <cursoragent@cursor.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Ignore pagination cursors from placeholder data, show only the pinned schedule whose id matches, surface failed run lists instead of caching them as empty, and drop the meta type assertion in permissions placeholder data.

Co-authored-by: Cursor <cursoragent@cursor.com>
@harshil-2096
harshil-2096 enabled auto-merge (squash) November 20, 2026 12:26
@harshil-2096
harshil-2096 merged commit 7d84a06 into main Nov 20, 2026
10 checks passed
@harshil-2096
harshil-2096 deleted the chore/hv/react-query-envs-schedul-page branch November 20, 2026 12:31

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit cc97e08. Configure here.

}
wasSettingsOpenRef.current = settingsOpen;
}, [settingsOpen, loadEnvironments, pageToken, pageSize]);
}, [settingsOpen, refetchEnvironments]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale environment pages after updates

Low Severity

Closing settings only refetches the active environments list query, and pending-build polling only setQueryDatas that same key. Other cached environments.list entries (different page size or token) stay fresh for staleTime and can still show old rows or pending status. Create, update, and delete already invalidate queryKeys.environments.all().

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit cc97e08. Configure here.

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