Problem#
The pull request sync refetches a linked pull request's stack over REST (repos/{owner}/{repo}/stacks?pull_request=N) whenever its summary changes, and every read spent core quota even when the stack hadn't changed. Telemetry from 44 servers sharing one GitHub account showed getPullRequestStack at about 710 REST requests/hr, with no conditional requests.
Fix#
getPullRequestStack keeps the last body and ETag per credential and sends If-None-Match, so an unchanged stack comes back as a 304, which GitHub doesn't charge for. Each request is pinned to the credential its validator is keyed by, so a 304 never returns another account's body. A 401 still invalidates the credential the same way it does unpinned.
Bottom of a 2-PR stack; #22073 builds on it.
Verification#
- New test: a polled stack is revalidated with its ETag, the cached body is returned on a 304, and a different credential doesn't reuse the first one's validator.
vp test run packages/source-control-github/src/server/GitHubPullRequestApi.test.ts, plus lint and typecheck for packages/source-control-github.
Done by Claude Opus 5.5 in Claude Code, running in T3 Code.
🤖 Generated with Claude Code
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed