Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): threads settle as soon as a client sees their PR merge #16761

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/16761/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

A PR merged on GitHub showed "Merged" in the thread details panel right away, but the sidebar badge stayed open and the thread did not settle for up to a minute.

The two views read different sources. The panel reads the PR detail from the host. The sidebar and settlement read the snapshot on the thread's PR link, which only the sync reactor writes, on a 1-minute sweep. The detail read already knew the new state, but nothing told the reactor.

Now a detail read that sees a PR for the first time, or in a new state, announces it. The sync reactor listens and syncs that link at once, so the badge updates and the thread settles as soon as any client (or a PR watch) sees the merge. Only detail reads announce, ordered by updatedAt and then observedAt, and merged stays final, so stale cached reads cannot flip a link back. The 1-minute sweep stays as the fallback.

Cost: at most one extra summary read per state change a reader sees.

Reviewed by GPT-6.1 Sol over 3 rounds (plan, code, follow-up).

Created with Claude Opus 5.5 in Claude Code.

🤖 Generated with Claude Code

    1. juliusmarminge added labelsmacroscope-review

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

    3. Approvability

      Verdict: Approved at 16f6678

      Macroscope's review found this PR approvable — This is a small, targeted synchronization bug fix that connects fresh pull-request detail observations to the existing thread snapshot and settlement path. Its bounded state tracking and event-driven refresh are covered by focused tests, with the periodic sweep retained as a fallback.

      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.

      ℹ️ 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 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 KiB−41 B (−0.8%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB−41 B (−3.3%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.2 KiB21.2 KiB−41 B (−0.2%)29.3 KiB✅
      ClaudeLive turn messages21−1 (−50.0%)8✅

      Baseline: 250e052 · PR result: 16f6678 · 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: 3ec6e626-59b7-4a32-bbce-a6bdc55fe7b9
      📥 Commits

      Reviewing files that changed from the base of the PR and between 655dfbe8ba87f0f9ef1d6fad83c20634634653aa and 16f6678f523e2d8c40387bf41421d13207758b13.

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

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


      📝 Walkthrough

      Walkthrough

      Detail reads now publish accepted pull-request state changes. The sync reactor consumes these notifications and requests a sync without waiting for the next scheduled sweep.

      Changes

      Pull request state-change sync

      Layer / File(s)Summary
      Track and publish detail-read state changes
      apps/server/src/pullRequest/PullRequestService.ts, apps/server/src/pullRequest/PullRequestService.test.ts
      The service compares detail readings by merge state, updatedAt, and observedAt. It publishes a key when an accepted detail reading changes state. Tests cover initial and changed states, repeated readings, and stale readings.
      Request syncs from state-change notifications
      apps/server/src/orchestration-v2/PullRequestSyncReactor.ts, apps/server/src/orchestration-v2/PullRequestSyncReactor.test.ts
      The reactor consumes state-change notifications and requests a sync. The test verifies that a notification invalidates the pull-request reference and dispatches a sync without advancing the clock.

      Priority: ⬇️ Low

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

      Change: Bug fix

      Sequence Diagram(s)

      sequenceDiagram
        participant PullRequestService
        participant StateChangePubSub
        participant PullRequestSyncReactor
        PullRequestService->>StateChangePubSub: publish ThreadPullRequestKey
        StateChangePubSub->>PullRequestSyncReactor: emit state-change key
        PullRequestSyncReactor->>PullRequestSyncReactor: requestSync for the key

      Suggested reviewers: juliusmarminge

      Merge Risk: ⚪ Minimal · up to 16f66

      No actionable merge-blocking risk remains. Detail reads can request prompt syncs, and stale reads do not revert a held merge.

      🚥 Pre-merge checks | ✅ 4
      ✅ Passed checks (4 passed)
      Check nameStatusExplanation
      Title check✅ PassedThe title clearly summarizes the main change: threads settle sooner when a client sees that a pull request has merged.
      Description check✅ PassedThe description clearly explains the problem and the change. It does not include the required scope and approval information or verification results.
      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.