Skip to content

Relax GitHub cache policy for fresher page data#187

Merged
stylessh merged 1 commit into
mainfrom
relax-github-cache-policy
May 26, 2026
Merged

Relax GitHub cache policy for fresher page data#187
stylessh merged 1 commit into
mainfrom
relax-github-cache-policy

Conversation

@stylessh
Copy link
Copy Markdown
Owner

@stylessh stylessh commented May 26, 2026

Summary

  • Shortens server-side GitHub KV cache TTLs across lists, detail, activity, status, and metadata so requests revalidate against the GitHub API much sooner instead of waiting on webhook signals.
  • Re-enables React Query refetch-on-window-focus globally and removes per-page refetchOnMount: false / refetchOnWindowFocus: false overrides on review, commit, and repo views.
  • Lowers rate-limit cache extension floors so low-budget responses don't hold stale data for as long.

Test plan

  • Open a PR detail page, make a change on GitHub (title/comment/status), return to the tab — data should refresh within a few seconds without waiting for a webhook.
  • Switch away from a review page and back — PR header, comments, and file list should background-refetch.
  • Confirm repo overview latest-commit bar updates after a push to the default branch.
  • Verify no spike in rate-limit errors under normal browsing; stale fallback still works when rate limited.

Summary by CodeRabbit

Release Notes

  • Performance
    • Optimized data refresh behavior across the dashboard for improved responsiveness
    • Adjusted cache freshness durations to balance performance and data currency
    • Enhanced rate-limit handling to maintain optimal performance under API constraints
    • Restored automatic data refetching when returning to the app to keep information current

Review Change Stack

Shorten server and client TTLs and re-enable refetch-on-focus/mount so pages hit the GitHub API directly instead of relying mainly on webhook revalidation.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 26, 2026

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8959e4c6-6908-40f0-bbf2-36b5b27d14c8

📥 Commits

Reviewing files that changed from the base of the PR and between 94ca240 and 864b415.

📒 Files selected for processing (7)
  • apps/dashboard/src/components/pulls/review/review-page.tsx
  • apps/dashboard/src/components/repo/commit-page.tsx
  • apps/dashboard/src/components/repo/latest-commit-bar.tsx
  • apps/dashboard/src/lib/github-cache-policy.ts
  • apps/dashboard/src/lib/github-cache.test.ts
  • apps/dashboard/src/lib/github-cache.ts
  • apps/dashboard/src/lib/query-client.tsx
💤 Files with no reviewable changes (2)
  • apps/dashboard/src/lib/query-client.tsx
  • apps/dashboard/src/components/repo/latest-commit-bar.tsx

📝 Walkthrough

Walkthrough

React Query's global refetchOnWindowFocus default is re-enabled, and component-level refetch overrides are removed in favor of prebuilt query option builders. Cache policy stale times are shortened across user aggregates and repository caches, and adaptive rate-limiting fresh floors are reduced to 45 and 90 seconds.

Changes

Query Refetch and Cache Freshness

Layer / File(s) Summary
Component query option simplification
apps/dashboard/src/components/pulls/review/review-page.tsx, apps/dashboard/src/components/repo/commit-page.tsx, apps/dashboard/src/components/repo/latest-commit-bar.tsx
Three components remove explicit refetchOnMount and refetchOnWindowFocus overrides, delegating refetch control to prebuilt query option builders (githubPullPageQueryOptions, githubPullFilesInfiniteQueryOptions, githubPullReviewCommentsQueryOptions, githubReviewThreadStatusesQueryOptions, githubRepoCommitQueryOptions).
Global query client default removal
apps/dashboard/src/lib/query-client.tsx
The global refetchOnWindowFocus: false default is removed from createAppQueryClient, re-enabling React Query's library-default window-focus refetching behavior.
Cache policy TTL adjustments
apps/dashboard/src/lib/github-cache-policy.ts
Cache stale times are shortened across reposList, list, user-scoped mine aggregates and sub-entries (detail, activity, userActivity, status, workflowRun), and wider entries (contributions, repoMeta, repoParticipation, installationAccess, repoProtection); JSDoc for mine user-scoped aggregates is updated.
Adaptive cache freshness thresholds
apps/dashboard/src/lib/github-cache.ts, apps/dashboard/src/lib/github-cache.test.ts
Rate-limiting fresh floor thresholds are reduced from 2 min / 5 min to 45 sec / 90 sec for low/critical scenarios; test assertion for extends freshness when GitHub budget is low is updated to expect freshUntil of 90_500 instead of 300_500.

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • stylessh/diffkit#152: Introduces and configures the user-scoped mine cache policy entry that this PR further adjusts for shorter stale times.
  • stylessh/diffkit#162: Adds infinite pagination to the PR review page's fileSummariesQuery, which this PR refactors to use prebuilt query options instead of component-level overrides.
  • stylessh/diffkit#179: Heavily refactors github-cache.ts for local-first cache resolution and signal-driven background revalidation, overlapping with this PR's adjustments to fresh floor thresholds and refetch defaults.

Suggested labels

tembo

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the main objective of the changeset: relaxing GitHub cache policy to enable fresher page data through reduced TTLs and re-enabled refetching.
Description check ✅ Passed The description covers the key changes and includes a test plan with checkboxes, though screenshots section is missing (non-critical for this PR type).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch relax-github-cache-policy

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@stylessh stylessh merged commit dc5d34d into main May 26, 2026
4 of 5 checks passed
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