Skip to content

GitHub cache: fresher My lists, repo-scoped invalidation#152

Merged
stylessh merged 2 commits intomainfrom
stylessh/github-cache-revalidation-tuning
Apr 18, 2026
Merged

GitHub cache: fresher My lists, repo-scoped invalidation#152
stylessh merged 2 commits intomainfrom
stylessh/github-cache-revalidation-tuning

Conversation

@stylessh
Copy link
Copy Markdown
Owner

@stylessh stylessh commented Apr 18, 2026

This PR tightens caching for user-facing "My" aggregates and fixes overly broad server cache invalidation for repo-scoped lists.

My pulls / issues / reviews

  • Added a dedicated mine policy (30s client staleTime, 15m gcTime) and use it for githubMyPullsQueryOptions / githubMyIssuesQueryOptions and the matching GraphQL mine resources freshForMs.
  • Mine cache merge now replaces with the latest fetch unless the run was partial (timedOut), so merged/closed items are not resurrected from older cache after webhook-driven refetch.

Signals / rate limit

  • Repo PR and issue list endpoints (pulls.repo, issues.repo) now key revalidation off repoMeta:owner/repo instead of global pulls.mine / issues.mine, avoiding unnecessary refetches across all users and repos.
  • User search (getPullsFromUser, getIssuesFromUser) uses repoMeta only when owner and repo are set; otherwise TTL only (no incorrect global mine coupling).

Resilience

  • Signal timestamp poll fallback reduced from 5 minutes to 90 seconds when the WebSocket path misses an update.

Summary by CodeRabbit

  • New Features

    • Added optimized caching behavior for user-scoped pulls and issues with shorter refresh intervals.
  • Bug Fixes

    • Improved cache merge logic for personalized content to prioritize fresh data when available.
    • Increased polling frequency from 5 minutes to 90 seconds for faster updates.

Introduce a shorter mine policy for My pulls/issues/reviews on client and
server, refresh mine aggregates without merging closed items back from cache,
and shorten the signal poll fallback. Scope repo list and repo-filtered user
search caches to repoMeta instead of global mine keys to cut spurious
refetches and rate-limit churn.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 18, 2026

Warning

Rate limit exceeded

@stylessh has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 8 minutes and 6 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 8 minutes and 6 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7c3933fd-0fba-433c-8fa3-e0caa07dc32b

📥 Commits

Reviewing files that changed from the base of the PR and between 5f5a5e1 and 8e903b9.

📒 Files selected for processing (2)
  • apps/dashboard/src/lib/github.functions.ts
  • apps/dashboard/src/lib/github.types.ts
📝 Walkthrough

Walkthrough

This pull request optimizes cache behavior for user-scoped GitHub data (pulls, issues, reviews). It introduces a new cache policy with shorter stale time and updates cache invalidation to use more granular, scoped keys instead of global ones, while also reducing the polling interval for signal updates.

Changes

Cohort / File(s) Summary
Cache Policy Addition
apps/dashboard/src/lib/github-cache-policy.ts
Added new cache policy entry mine with 30-second stale time and 15-minute garbage collection time for user-scoped aggregates.
Cache Invalidation & Merge Behavior
apps/dashboard/src/lib/github.functions.ts
Added helper function revalidationSignalKeysForUserItemSearch for granular cache invalidation. Changed merge strategy for user-scoped pulls/issues to perform full refresh when data is not stale. Updated server functions to use scoped revalidation keys instead of global ones and adjusted freshness timing to use new mine cache policy.
Query Configuration
apps/dashboard/src/lib/github.query.ts
Updated React Query cache timing for githubMyPullsQueryOptions and githubMyIssuesQueryOptions to use the new mine cache policy instead of list policy.
Polling Optimization
apps/dashboard/src/lib/use-github-signal-stream.ts
Reduced polling interval from 5 minutes to 90 seconds in useGitHubSignalPoll for faster signal stream updates.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The PR description is detailed and well-structured, covering all major changes (My lists caching, revalidation scoping, and polling improvements), but does not follow the provided template structure with required sections. Restructure the description to match the template with Summary, Changes, Test Plan, and Screenshots sections for consistency with repository standards.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely captures the main changes: introducing a dedicated cache policy for My lists and scoping cache invalidation to repos instead of global keys.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch stylessh/github-cache-revalidation-tuning

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

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 18, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
diffkit 8e903b9 Apr 18 2026, 03:19 AM

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/dashboard/src/lib/github.functions.ts`:
- Around line 4475-4494: The merge functions mergeMyPullsCachedWithFresh and
mergeMyIssuesCachedWithFresh incorrectly use fresh.timedOut to decide whether to
union with existing cache; change the logic to use a new per-fetch boolean
(e.g., partial or incomplete) that you set only when the aggregate actually
missed one of its own sources, and leave timedOut for the global UI/telemetry
signal (keep hasRecentGitHubTimeouts() setting timedOut in
getMyPullsResult/getMyIssuesResult but do not use it for merge decisions);
update the merge callers (including the other occurrences at the noted ranges)
to check fresh.partial (or fresh.incomplete) instead of fresh.timedOut so fully
successful refreshes are not merged with stale cache entries.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bc99c77d-b9d8-4c2f-b7aa-8850e064a5eb

📥 Commits

Reviewing files that changed from the base of the PR and between 80664b8 and 5f5a5e1.

📒 Files selected for processing (4)
  • apps/dashboard/src/lib/github-cache-policy.ts
  • apps/dashboard/src/lib/github.functions.ts
  • apps/dashboard/src/lib/github.query.ts
  • apps/dashboard/src/lib/use-github-signal-stream.ts

Comment thread apps/dashboard/src/lib/github.functions.ts Outdated
CodeRabbit: timedOut is also set via hasRecentGitHubTimeouts(), so using it
for cache union could resurrect stale rows after an unrelated timeout.
Introduce partial when results.length < sources.length and use that for
mergeMyPullsCachedWithFresh / mergeMyIssuesCachedWithFresh only.
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