Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): threads settle as soon as branch status sees their PR merge #17148

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

A merged PR showed "Merged" in the thread details panel, but the sidebar badge stayed open and the thread did not settle for about 40 seconds (seen on #17137).

#16761 fixed this for one read path: a PullRequestService.detail read that sees a new state tells the sync reactor, which re-reads the PR and updates the thread's link right away. But for a worktree thread on the PR branch, the panel shows the branch status lookup (GitManager → lookupStatusPr). That lookup told nobody, so only the 1-minute sweep caught the merge.

Now GitManager remembers the state its PR lookup last read for each PR. When the state changes, it announces the PR. The sync reactor listens to that stream as well as the detail stream. The status result is never trusted directly: the reactor still does its own fresh read before it changes the link.

Cost: at most one extra summary read when a branch lookup sees a PR change state.

Reviewed with sol-loop: 1 round with GPT-6.1 Sol on high.

Created with Claude Opus 5.5 in Claude Code.

🤖 Generated with Claude Code

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. juliusmarminge added labelsmacroscope-review

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

      Approvability

      Verdict: Approved at d85a48c

      Macroscope's review found this PR approvable — This is a focused server-side bug fix that adds in-memory PR state notifications and reuses the existing sync path, with targeted tests and no default, schema, deployment, security, billing, or authentication changes. An unresolved Medium automated finding notes that GitHub Enterprise URLs can still miss notifications, so that limitation remains a known risk.

      Notes:

      • This verdict was updated automatically after the outstanding correctness findings were resolved. Macroscope did not re-review the code.
      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire4.9 KiB5.0 KiB+23 B (+0.5%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB+23 B (+1.9%)2.0 KiB✅
      CodexLive turn WebSocket decoded20.8 KiB20.9 KiB+41 B (+0.2%)29.3 KiB✅
      CodexLive turn messages12+1 (+100.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.2 KiB21.2 KiB0 B (0.0%)29.3 KiB✅
      ClaudeLive turn messages110 (0.0%)8✅

      Baseline: 9381533 · PR result: d85a48c · 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: 108.5 KiB
      • Claude decoded thread snapshot: 108.8 KiB

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

    5. Review in Change Stack →

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Team
      • Run ID: 46800b26-d710-401e-b4a4-443a3cc10e9d
      📥 Commits

      Reviewing files that changed from the base of the PR and between 9381533771ef50d58304f79fac2b74ebd8932be7 and d85a48ccc6c64886cc2287cd4992fe797f3148e5.

      📒 Files selected for processing (4)
      • apps/server/src/git/GitManager.test.ts
      • apps/server/src/git/GitManager.ts
      • apps/server/src/orchestration-v2/PullRequestSyncReactor.test.ts
      • apps/server/src/orchestration-v2/PullRequestSyncReactor.ts

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.


      📝 Walkthrough

      Walkthrough

      GitManager now publishes pull-request state changes observed during lookups. PullRequestSyncReactor merges those notifications with pull-request service notifications and requests synchronization when either stream emits.

      Changes

      Pull-request state sync

      Layer / File(s)Summary
      Track and publish lookup state changes
      apps/server/src/git/GitManager.ts, apps/server/src/git/GitManager.test.ts
      GitManager validates and normalizes pull-request lookup results, remembers observed states in a bounded map, and publishes keys when states change. Tests cover changes from open to merged and a first lookup that is merged.
      Use state notifications to request sync
      apps/server/src/orchestration-v2/PullRequestSyncReactor.ts, apps/server/src/orchestration-v2/PullRequestSyncReactor.test.ts
      PullRequestSyncReactor merges notifications from GitManager and PullRequestService. The test harness provides an empty GitManager notification stream.

      Priority: ➖ Normal

      Estimated code review effort: 3 (Moderate) | ~20 minutes

      Change: Bug fix

      Sequence Diagram(s)

      sequenceDiagram
        participant GitManager
        participant PullRequestService
        participant PullRequestSyncReactor
        GitManager->>PullRequestSyncReactor: Publish pull-request state change
        PullRequestService->>PullRequestSyncReactor: Publish pull-request state change
        PullRequestSyncReactor->>PullRequestSyncReactor: Request sync for either notification

      Suggested reviewers: juliusmarminge

      Merge Risk: ⚪ Minimal · up to d85a4

      No confirmed issue currently prevents merging. Normal checks should still run.

      🚥 Pre-merge checks | ✅ 4
      ✅ Passed checks (4 passed)
      Check nameStatusExplanation
      Title check✅ PassedThe title clearly and concisely describes the main server fix: threads settle when branch status detects that a pull request has merged.
      Description check✅ PassedThe description clearly explains the problem and the implementation. It references related issue context and describes the expected verification scope. It does not use the required section headings an…
      Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
      ✨ Finishing Touches
      📝 Generate docstrings
      • Commit to this branch
      • Create a new PR
      🧪 Generate unit tests (beta)
      • Commit to this branch
      • Create a new PR
      • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

      Comment `@coderabbitai help` to get the list of available commands.

Sign in to join this conversation.