GeezerVison is showing github.com — fix(server): stop GitHub quota probe cwd/failure from blocking PR reads by Artic0din · Pull Request #12235 · pingdotgg/t3code
Conversation
Artic0din
commented
Sep 17, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
What Changed
GitHubCli.execute's rate-limit preflight probe (the gh api rate_limit call that gates every pr view / pr list / repo view) ran with cwd: globalThis.process.cwd() instead of the caller's cwd. It now runs with the caller's input.cwd, and a probe failure no longer blocks the guarded read — it logs a warning and proceeds, relying on budget.query right after it to still catch a known-exhausted budget.
Two focused tests added: one asserts the probe now receives the caller's cwd, the other asserts a failing probe doesn't stop the real gh command from running.
Why
Filed as #12224, triaged by @juliusmarminge: on packaged desktop, apps/desktop/src/app/DesktopEnvironment.ts sets backendCwd to the user's home directory. Because the quota probe used process.cwd() rather than the project's cwd, it ran from $HOME there. A failed probe was never cached (timeToLive is zero on failure) and hard-failed the whole execute() call before the real read ran, so a background sweep like PullRequestSyncReactor's 1-minute pass could fail every single time with no way to recover, even though the actual pr view/pr list call it was guarding already had the correct project cwd and its own --repo targeting.
This makes the probe behave the way its name says: a courtesy check, not a precondition. Its own transport/command failure shouldn't be able to permanently block a read that would otherwise succeed.
UI Changes
N/A — server-side background reactor behavior only.
Checklist
- This PR is small and focused
- I explained what changed and why
- I included before/after screenshots for any UI changes (N/A, no UI change)
- I included a video for animation/interaction changes (N/A, no UI change)
Refs #12224
Model: Claude Sonnet 5. Harness: Claude Code.
Summary by CodeRabbit
- Bug Fixes
- GitHub CLI rate-limit checks now use the requesting command’s working directory.
- Quota checks are shared across projects on the same GitHub host, reducing redundant requests.
- Non-rate-limit probe failures no longer block GitHub operations, while rate-limit responses are surfaced appropriately.
- Tests
- Added coverage for working-directory handling, shared quota checks, and probe failure behavior.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
GitHubCli.execute's rate-limit preflight probe ran `gh api rate_limit`
with `globalThis.process.cwd()` instead of the caller's cwd. On
packaged desktop that is $HOME (apps/desktop sets backendCwd to the
user's home directory), so the probe could fail there even when the
actual read (pr view/pr list/repo view) had the correct project cwd
and would otherwise succeed.
Worse, a failed probe was never cached (`timeToLive` is zero on
failure) and blocked the guarded read outright, so every retry of a
sweep like PullRequestSyncReactor's 1-minute pass re-failed the probe
and the real gh command never ran.
Pass the caller's cwd into the probe, and treat a probe failure as an
unknown-budget courtesy check rather than a precondition: log a
warning and proceed to the actual read, which still passes through
budget.query for a known-exhausted budget.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Approvability
Verdict: Approved at 6f168e3
Macroscope's review found this PR approvable — This is a focused GitHub CLI bug fix with limited runtime impact: quota probes now use the request's cwd and probe failures no longer prevent the guarded read, while known quota exhaustion remains enforced. Tests cover both changed behaviors, with no schema, default, deployment, or static-analysis changes.
You can add or adjust custom eligibility rules. Learn more.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Preserve host/credential-level probe-result sharing while using the caller’s cwd for refreshes.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Updates GitHub CLI quota probing to use the caller’s working directory and avoid blocking reads when probes fail.
Changes:
- Passes
input.cwd to quota probes.
- Treats probe failures as warnings.
- Adds tests for cwd propagation and failure recovery.
File summaries
| File |
Summary |
apps/server/src/sourceControl/GitHubCli.ts |
Adjusts quota probe cwd handling and failure behavior. |
apps/server/src/sourceControl/GitHubCli.test.ts |
Tests cwd propagation and probe-failure recovery. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Sep 17, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
 
Understand this PR’s impact
Explore downstream dependencies and potential security impact with Blast Radius.
View blast radius →
Important
Review skipped
Review was skipped as selected files did not have any reviewable changes.
⚙️ Run configuration
Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID: c291398a-6f61-4192-8c11-678e8e02c4f7
📥 Commits
Reviewing files that changed from the base of the PR and between 78c3e10 and 2bdc1b7.
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:
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID: 063877a5-e498-4a80-9aae-427eaad3f99d
📥 Commits
Reviewing files that changed from the base of the PR and between 739cb4a and 78c3e10.
📒 Files selected for processing (2)
apps/server/src/sourceControl/GitHubCli.test.ts
apps/server/src/sourceControl/GitHubCli.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
📝 Walkthrough
Walkthrough
The GitHub CLI quota probe cache now uses host-and-credential scope. It records the caller cwd for refreshes. Rate-limit probe failures propagate, while other probe failures do not block reads. Tests cover these behaviors.
Changes
GitHub quota probe handling
| Layer / File(s) |
Summary |
Quota probe scope and failure handling apps/server/src/sourceControl/GitHubCli.ts, apps/server/src/sourceControl/GitHubCli.test.ts |
The cache key uses host and credential instead of cwd. The rate-limit command uses the recorded caller cwd. GitHubCliRateLimitError propagates, while other probe failures are logged and ignored. Tests verify cwd propagation, cross-project cache reuse, successful reads after command failure, and blocked reads after rate-limit failure. |
Priority: ⬇️ Low
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Low
Suggested reviewers: bil0000
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name |
Status |
Explanation |
| Title check |
✅ Passed |
The title clearly summarizes the main changes: correcting the GitHub quota probe working directory and preventing non-rate-limit probe failures from blocking pull request reads. |
| Description check |
✅ Passed |
The description includes the required What Changed, Why, UI Changes, and Checklist sections. It explains the problem, the implementation, and the expected behavior. It states that two tests were added… |
| Docstring Coverage |
✅ Passed |
No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2… |
| 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. |
✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment @coderabbitai help to get the list of available commands.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Self-review follow-up
Re-reviewed 6f168e3 against the source and ran the tests locally. Copilot's inline finding on GitHubCli.ts:495 is real and still unaddressed — details and a proposed fix below, plus two smaller items.
[PROBLEM] apps/server/src/sourceControl/GitHubCli.ts:495 — cwd in the quota cache key multiplies probes N×
Verdict: confirmed. Adding \0${input.cwd} to the quota cache key buys no correctness and costs one extra gh api rate_limit subprocess per project per sweep.
githubGraphQlBudget.ts:88,124 — both query and observe key on `${hostKey(host)}\0${CredentialScope}`. The budget state the probe feeds is host + credential scoped; it has no cwd dimension. Every per-cwd probe writes the same host-level budget.
PullRequestSyncReactor.ts:234 — syncGroup fans out per projectId, each with its own workspaceRoot. With timeToLive 30s against a 60s sweep, cost goes from 1 probe per sweep to N per sweep, N = projects with linked PRs on that host.
capacity: 32 (line 460) compounds it past 32 distinct keys — LRU eviction forces re-probes on top of TTL expiry.
This regresses the spawn-volume concern in #11220, which the triage above explicitly named as what makes this bug loud.
Proposed fix — keep the key host-scoped, resolve cwd at refresh time:
const probeCwds = new Map<string, string>();
const quota = yield* Cache.makeWith(
(key: string) => {
const host = key.split("\0")[0]!;
return executeRaw({
cwd: probeCwds.get(key) ?? globalThis.process.cwd(),
args: ["api", "rate_limit", "--hostname", host, "--jq", /* … */],
}).pipe(/* … */);
},
{ capacity: 32, timeToLive: /* … */ },
);
and at the call site:
const quotaKey = `${host}\0${credential?.credentialFingerprint ?? ""}`;
probeCwds.set(quotaKey, input.cwd);
yield* Cache.get(quota, quotaKey).pipe(Effect.catch(/* … */));
The map is bounded by host × fingerprint. A stale cwd is harmless now — bounded by the 30s TTL, and a probe failure no longer blocks the read.
Verified this rework keeps the new test green: probes quota using the caller's cwd asserts on the cwd the probe receives, not on the cache key, so it survives a host-keyed refactor unchanged.
[SUGGESTION] GitHubCli.ts:497 — fail-open swallows the probe's rate-limit signal
Effect.catch takes the whole error channel. Per fromVcsError (lines 236-246) the probe can fail as GitHubCliRateLimitError when failureKind === "rate-limited".
- Before: that propagated to the
Effect.tapError at line 508 → limits.recordRateLimit({ ...key, lease }) → host limiter pauses, caller gets a proper retryAt.
- After: swallowed →
budget.query passes (no observed data) → the real gh pr view runs, gets 403, and then records.
Self-correcting, but it spends an extra gh call under exactly the condition the probe exists to avoid. Narrowing it:
Effect.catchFilter(
(error) => error._tag !== "GitHubCliRateLimitError",
(error) => Effect.logWarning("GitHub API quota probe failed; proceeding without it", { host, error }),
)
Low severity — reasonable to leave as-is if the extra precision isn't worth the branch.
[SUGGESTION] Missing the test that would lock in the fix above
GitHubCli.test.ts:48 (shares quota checks…) asserts probes === 1, but every call uses cwd: "/repo", so it cannot catch the multiplication:
yield* gh.execute({ cwd: "/repo/a", args: ["pr", "list"] });
yield* gh.execute({ cwd: "/repo/b", args: ["pr", "list"] });
assert.strictEqual(probes, 1); // one host-scoped probe, two projects
Test evidence
vp test run apps/server/src/sourceControl/GitHubCli.test.ts → 18 passed (1 file).
Confirmed the two new tests aren't vacuous by reverting GitHubCli.ts to origin/main with the new test file in place:
× probes quota using the caller's cwd, not the process cwd
AssertionError: expected [ Array(1) ] to deeply equal [ '/repo/project-a' ]
× does not block the read when the quota probe itself fails
Tests 2 failed | 16 passed (18)
Both fail for the right reasons pre-fix, and the other 16 stay green.
Note on scope
The cwd half of this fix is defensive rather than causal — I retracted the "not a git repository" diagnosis on #12224, and gh api rate_limit --hostname <host> doesn't need a git checkout, so the underlying reason for the exit 1 is still unknown. The fail-open half is what actually resolves the reported impact. That's a further argument against paying an N× probe cost for the cwd change.
Model: Claude Opus 5. Harness: Claude Code.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Folding the caller's cwd into the quota cache key made the probe
per-project rather than per-host. The budget it feeds is keyed on
host plus credential scope (githubGraphQlBudget), so the extra
entries bought no correctness and cost one `gh api rate_limit`
subprocess per project per sweep: PullRequestSyncReactor.syncGroup
fans out per projectId, and the 30s TTL expires inside the 60s
sweep. The 32-entry capacity compounded it with eviction churn once
a user had more projects than that.
Keep the key as host plus credential fingerprint and record the
newest caller's cwd alongside it, so a refresh still spawns `gh`
from a real project directory while one probe serves every project
on that host. A stale cwd is bounded by the 30s TTL and is harmless
now that a probe failure no longer blocks the read.
Add the regression test the existing coverage could not catch: two
projects on one host must share a single probe.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Failing the probe open caught every error, including the one failure
that is the probe's whole point. A `rate-limited` exit maps to
GitHubCliRateLimitError, which previously reached the tapError below
and recorded the limit against the lease; swallowing it meant the
guarded read ran anyway, rediscovered the same 403, and only then
paused the host.
Recover from everything except that tag, so a dead probe stays a
courtesy check while a rate-limited one still reports what it found.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Applied the remaining suggestion from my self-review in 78c3e10.
[SUGGESTION] GitHubCli.ts:497 — fail-open swallowed the probe's rate-limit signal — fixed.
Effect.catch took the whole error channel, including the one failure that is the probe's entire purpose. A rate-limited exit maps to GitHubCliRateLimitError via fromVcsError, which previously reached the tapError at line 508 and called limits.recordRateLimit. Swallowing it meant the guarded read ran anyway, rediscovered the same 403, and only then paused the host.
Now recovers from everything except that tag:
Effect.catchIf(
(error) => error._tag !== "GitHubCliRateLimitError",
(error) =>
Effect.logWarning("GitHub API quota probe failed; proceeding without it", { host, error }),
)
Used Effect.catchIf rather than a conditional Effect.fail passthrough because the Effect language-service diagnostic asked for it (TS377116 effect(catchConditionalRefailToCatchIf)) — my first version tripped it.
Covering test asserts the error surfaces and that the guarded read never runs:
const error = yield* gh.execute({ cwd: "/repo", args: ["pr", "list"] }).pipe(Effect.flip);
assert.strictEqual(error._tag, "GitHubCliRateLimitError");
assert.deepStrictEqual(commands, []);
Verified it fails with the plain fail-open and passes after.
| Check |
Result |
vp test run apps/server/src/sourceControl/GitHubCli.test.ts |
20/20 pass |
vp run --filter t3 typecheck |
exit 0, 0 errors, no diagnostics in GitHubCli.ts |
vp lint / vp fmt --check (both changed files) |
clean |
That closes all three findings from the self-review above.
Model: Claude Opus 5. Harness: Claude Code.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Medium sourceControl/GitHubCli.ts:512
probeCwds retains every host\0credentialFingerprint and cwd indefinitely, so long-lived servers accumulate entries even though quota is bounded to 32 cached probes. Remove the mapping when Cache.get completes, including failed probes, so the auxiliary map does not grow without bound.
🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/server/src/sourceControl/GitHubCli.ts around line 512:
`probeCwds` retains every `host\0credentialFingerprint` and `cwd` indefinitely, so long-lived servers accumulate entries even though `quota` is bounded to 32 cached probes. Remove the mapping when `Cache.get` completes, including failed probes, so the auxiliary map does not grow without bound.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Note Grok responding on behalf of Julius.
Superseded by #14673, which removed the REST gh api rate_limit preflight probe entirely and replaced it with GraphQL rateLimit readings that never block the guarded read on failure. Closing this PR as obsolete.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
macroscope-review
Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews
size:S
10-29 changed lines (additions + deletions).
vouch:unvouched
Author is not yet trusted in the VOUCHED list.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|