Skip to content

fix(server): return fresh live pull request reads - #6472

Open
Adamulek123 wants to merge 3 commits into
pingdotgg:mainfrom
Adamulek123:t3code/pr-refresh-freshness
Open

fix(server): return fresh live pull request reads#6472
Adamulek123 wants to merge 3 commits into
pingdotgg:mainfrom
Adamulek123:t3code/pr-refresh-freshness

Conversation

@Adamulek123

@Adamulek123 Adamulek123 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

What Changed

Expired list, detail, activity, and line-stat cache reads now wait for and return the newly fetched host value. Diff reads retain stale-while-revalidate because they are expensive, are not live-polled, and already bypass held values after explicit refreshes and mutations.

Why

The previous stale-while-revalidate wrapper returned the old value to each live poll and updated only the server cache in the background. The client did not receive that background result, leaving automatic refresh one cycle behind and potentially stale indefinitely after returning to a tab. Narrowing the change to live-polled mutable reads fixes freshness without putting diff loading back on the interaction critical path.

Validation

  • vp test run apps/server/src/pullRequest/PullRequestService.test.ts (87 tests passed)
  • vp run --filter t3 typecheck
  • Regression test advances the Effect test clock past the list TTL and verifies the first expired read receives the second host response

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • No UI change requires before/after screenshots
  • No animation or interaction change requires a video

Generated with GPT-5.6 in the Codex harness.


Note

Medium Risk
Changes caching semantics for frequently polled reads—callers may wait on host/CLI after TTL expiry instead of instant stale responses, which fixes freshness but increases latency on those paths.

Overview
Live-polled pull request reads (list, detail, activity, listStats) no longer use stale-while-revalidate. After the Effect cache TTL expires, the next read blocks on a fresh host fetch and returns that result instead of immediately serving an old value while refreshing in the background.

diff still uses stale-while-revalidate via a dedicated staleDiff helper (the generic staleWhileRevalidate and LIST_STALE_WINDOW / DETAIL_STALE_WINDOW are removed). Epoch-based invalidate behavior is unchanged.

A regression test advances TestClock past the 30s list TTL and asserts the second list call hits the host again and returns the updated payload.

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

Note

Return fresh data on first read after cache expiry for pull request list, detail, activity, and stats

Previously, PullRequestService used stale-while-revalidate for list, detail, activity, and listStats caches, serving stale data on the first read after TTL expiry while refreshing in the background. These methods now call Cache.get(...) directly, so the first read after expiry blocks on a fresh fetch and returns up-to-date data.

  • Diff responses retain stale-while-revalidate behavior via a specialized staleDiff closure that refreshes in the background within DIFF_STALE_WINDOW.
  • Behavioral Change: callers that previously received an instant (stale) response after cache expiry will now wait for a live provider fetch on list, detail, activity, and listStats reads.

Macroscope summarized 99b64ec.

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4515d29b-d501-4782-8dc3-b7e699fe0ec6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Aug 13, 2026

@macroscopeapp macroscopeapp Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One finding: an invariant comment was deleted from code that this PR keeps. Everything else (namespace imports, Foo["Service"] usage, service/layer shape, error handling) is unchanged and conventional.

Posted via Macroscope — Effect Service Conventions

Comment thread apps/server/src/pullRequest/PullRequestService.ts
@macroscopeapp

macroscopeapp Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

This PR removes stale-while-revalidate caching for multiple PR service endpoints (list, detail, activity, listStats), changing user-facing latency behavior. Users will now wait for fresh network requests rather than receiving cached responses. This architectural change to caching strategy warrants human review.

You can customize Macroscope's approvability policy. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant