fix(server): threads settle as soon as a client sees their PR merge #16761
main fromrefs/pull/16761/head·merged by t3dotgg(GitHub profile, opens in a new tab) View on GitHubA 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
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
Approvability#
Verdict: Approved at
16f6678Macroscope'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).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
mainmeasurement shown below.Provider Metric Main baseline This PR Impact PR ceiling Codex Total thread wire 4.9 KiB 5.0 KiB +23 B (+0.5%) 6.8 KiB ✅ Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB +23 B (+1.9%) 2.0 KiB ✅ Codex Live turn WebSocket decoded 20.8 KiB 20.9 KiB +41 B (+0.2%) 29.3 KiB ✅ Codex Live turn messages 1 2 +1 (+100.0%) 8 ✅ Claude Total thread wire 5.0 KiB 5.0 KiB −41 B (−0.8%) 6.8 KiB ✅ Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB −41 B (−3.3%) 2.0 KiB ✅ Claude Live turn WebSocket decoded 21.2 KiB 21.2 KiB −41 B (−0.2%) 29.3 KiB ✅ Claude Live turn messages 2 1 −1 (−50.0%) 8 ✅ Baseline:
250e052· PR result:16f6678· Source CI: successScenario 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.
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.tsapps/server/src/orchestration-v2/PullRequestSyncReactor.tsapps/server/src/pullRequest/PullRequestService.test.tsapps/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.tsThe service compares detail readings by merge state, updatedAt, andobservedAt. 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.tsThe 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 keySuggested reviewers:
juliusmarmingeMerge Risk: ⚪ Minimal · up to
16f66No 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 name Status Explanation Title check ✅ Passed The title clearly summarizes the main change: threads settle sooner when a client sees that a pull request has merged. Description check ✅ Passed The description clearly explains the problem and the change. It does not include the required scope and approval information or verification results. 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 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.t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes