Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): find newly opened pull requests after agent turns #9125

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 6 commits intomain fromrefs/pull/9125/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

PR badges can stay missing after an agent opens a pull request. Branches pushed without -u can be missed entirely when their upstream still points to the default branch.

Refresh PR discovery after a turn on the thread's checked-out feature branch. The refresh respects background policy, skips unloaded repositories, preserves known PRs and failed-lookup backoff, and does not fetch Git remotes. Initial status loads and refreshes share a lock so an older response cannot hide a new PR. Auxiliary turn completions do not trigger another lookup while the main turn is active.

For a branch that still tracks the default branch, use its own remote-tracking ref to find the PR, including fork remotes. The worktree cache reuse and immediate merge settlement changes already on main remain unchanged.

Verified with 218 focused server tests, the server typecheck, and scoped lint. The cache-race test fails on the inherited code and passes with the fix. Git tests use real temporary repositories and local remotes with a fake hosting CLI. Browser and live hosting-provider behavior were not tested.

Original work by Theo Browne with Claude Fable 5.1 in Claude Code. Original commit authorship and co-author trailers are preserved.

Takeover fixes created with GPT-6 Astra (preview) in Codex.


Note

Medium Risk Changes PR head resolution, caching, and concurrent status updates; incorrect remote selection or lock ordering could show wrong PR state or stale badges, but behavior is heavily covered by new GitManager and broadcaster tests.

Overview Fixes missing PR badges after an agent opens a review, including branches pushed without -u while upstream still tracks the default branch.

Turn-end refresh: CheckpointReactor calls VcsStatusBroadcaster.refreshPullRequestStatus when a turn completes on the thread’s non-default checked-out branch (after drift adoption), skipping default branch, shared-worktree drift rejections, and auxiliary turns while the primary turn is still active.

GitManager: Adds refreshMissingPullRequest on remoteStatus to retry only a cached “no PR” result without clearing known PRs or failed-lookup backoff, and bypasses the remote-status result cache for that path. PR discovery now goes through resolveLookupHeadContext: when upstream is the default branch but a remote holds refs/remotes/<remote>/<branch>, lookup uses that own-name head (including forks); branchPullRequest verifies identity against the remote the lookup actually used.

VcsStatusBroadcaster: New turn-end API respects background policy and loaded remote cache; per-cwd write locks on remote reads prevent stale polls or initial loads from overwriting a fresher PR. Docs note the user-visible behavior.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit f1118b40ce02cfecba4c1812274d91cd9c6dee12. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Fix pull-request discovery after agent turns on non-default branches

  • Adds turn-end PR refresh in CheckpointReactor.ts: after a primary turn completes on a non-default branch, it calls a new refreshPullRequestStatus on VcsStatusBroadcaster to retry missing-PR lookups without fetching remotes
  • Adds refreshMissingPullRequest option through GitManager and GitWorkflowService so callers can invalidate only a cached null-PR entry while keeping known PRs and failed-lookup backoff intact
  • Adds resolveLookupHeadContext in GitManager.ts so PR lookup uses an own-name branch ref on a configured remote (including forks) instead of always falling back to the default upstream head
  • Adds per-cwd write lock (withRemoteWriteLock) in VcsStatusBroadcaster.ts to serialize remote status cache writes and prevent stale poll or initial-read results from overwriting a newer explicit refresh
  • Risk: remoteStatus now bypasses the broadcaster cache when refreshMissingPullRequest is set; if a caller passes this flag unexpectedly it will force a GitManager read instead of returning the cached status. Branch identity verification now derives the remote from the resolved head context rather than the saved upstream remote.
Macroscope summarized f1118b4.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. New suppression directive without an adjacent explanation of why the diagnostic is disabled here. Other occurrences in this file carry the standard rationale — consider adding it:

                  // Fake gh returns raw JSON stdout, matching the CLI boundary under test.
                  // @effect-diagnostics-next-line preferSchemaOverJson:off
      Posted via Macroscope — Effect Service Conventions
    3. github-actions[bot](GitHub profile, opens in a new tab)commented

      Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ℹ️ The exact PR base did not have a successful artifact. Baseline uses the latest successful main measurement shown below.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire13.6 KiB13.6 KiB+35 B (+0.3%)15.1 KiB✅
      CodexThread snapshot wire7.0 KiB7.0 KiB+7 B (+0.1%)7.3 KiB✅
      CodexLive turn WebSocket wire6.5 KiB6.6 KiB+28 B (+0.4%)7.8 KiB✅
      CodexLive turn WebSocket decoded57.0 KiB57.1 KiB+44 B (+0.1%)66.4 KiB✅
      CodexLive turn messages910+1 (+11.1%)21✅
      ClaudeTotal thread wire13.6 KiB13.5 KiB−65 B (−0.5%)15.1 KiB✅
      ClaudeThread snapshot wire7.0 KiB7.0 KiB−5 B (−0.1%)7.3 KiB✅
      ClaudeLive turn WebSocket wire6.6 KiB6.5 KiB−60 B (−0.9%)7.8 KiB✅
      ClaudeLive turn WebSocket decoded57.9 KiB57.8 KiB−88 B (−0.1%)66.4 KiB✅
      ClaudeLive turn messages108−2 (−20.0%)21✅

      Baseline: 617edab · PR result: f1118b4 · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 113.8 KiB
      • Claude decoded thread snapshot: 114.5 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    4. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This PR adds automatic turn-end PR discovery and changes branch resolution, caching, and remote-read synchronization across several production server components. It also introduces line-level preferSchemaOverJson:off diagnostic suppressions in tests, which requires human review.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. Note

      🤖 Claude Fable 5.1 responding on behalf of Theo

      Added the standard rationale line in 45b9475f.

    6. Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 87687d6ecf91be6a2e59cdf48e88a320d75a6edd. Configure [here](https://www.cursor.com/dashboard/bugbot).
    7. t3dotgg(GitHub profile, opens in a new tab) changed the title

Sign in to join this conversation.