Repository navigation
fix(server): threads settle right away when a watched PR merges - #26395
Conversation
A PR watch held auto-settle until the watch reactor's next 2-minute sweep, even after the merged snapshot had synced. The reactor ends merged watches without a wake, so a merged link's watch no longer holds the thread. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — Merged PR watches no longer keep threads pending while watch cleanup catches up. This aligns completion bookkeeping with the existing watch lifecycle and leaves other pending work unchanged. You can add or adjust custom eligibility rules. Learn more. |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
State-aware pull request watch filtering packages/shared/src/orchestrationV2PendingBackgroundWork.ts, packages/shared/src/orchestrationV2PendingBackgroundWork.test.ts |
The pull request type now includes a nullable snapshot state. The pending-work calculation omits watches for merged pull requests. Tests verify that closed pull requests remain in pending-work results. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Possibly related issues
pingdotgg/t3code#25160: This change omits merged pull request watches from pending background work. The issue requests a merge wake for verification.pingdotgg/t3code#26083: This change modifies how merged pull request watches affect pending background work. The issue describes a race that can lose the post-merge wake.
Suggested reviewers: juliusmarminge, maria-rcks
Merge Risk: 
Minimal · up to 08813
-
The change removes completed merged-PR watches without dropping closed-PR or unrelated pending work, so no actionable merge risk remains.
Pre-merge checks: 
3 · 
1
-
Failed checks: 1 warning Passed checks: 3 passedFull details: Description check
-
Explanation
The description clearly explains the problem, fix, behavior for merged and closed pull requests, verification, and policy conflict. It does not provide the required Scope and approval information or explain why the change qualifies for the small, obvious bug exemption.
Resolution
Add a Scope and approval section. Link the triaged issue or maintainer approval with the approval comment, or explain why this focused fix qualifies as an obvious bug without prior approval. Organize the existing content under the required Problem, Change, Scope and approval, and Verification headings.
-
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 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.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
Main now skips merged PRs in pullRequestWatchTasks (pingdotgg#26395). That check moves into the shared isWatchedLink helper so the monitor row lookup follows the same rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dotgg#26395) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 2a73827)
A thread with a PR watch did not settle when its PR merged. It sat in "Waiting on Watching pull request #N" for up to 2 minutes. In one case the agent merged #26387 at 10:00:02 and the server synced the merged snapshot at 10:00:03. The turn ended at 10:00:13, but the thread settled only at 10:01:30.
The cause: a watched link counts as awaited background work, and awaited work blocks auto-settle. The watch reactor ends a merged PR's watch without waking the agent, but only on its next 2-minute sweep. So the watch held the thread for nothing.
The fix: a watch whose link snapshot is already
mergedno longer counts as pending work. This gives:merge with cleanuporfull send): the thread settles when the turn ends.t3_background_waitfor CI or deploy) still hold the thread, so the bug from #24681 does not come back.Proof: the existing watch test table gets a merged row and a closed row. It fails on
mainand passes here. I replayed the real thread state at 10:00:13 throughderivePendingBackgroundWork. Onmainit returns the watch task, which holds the thread. With this fix it returns nothing.vp run check:changedpasses.Policy conflict: #26271 and #25181 go the other way: a merge wakes the agent, and #25181 also defers settlement while a merged watch is active. This PR assumes merges stay silent. Only one policy should land.
Council review
Rounds: 2
Made with Claude Opus 5.5 in Claude Code, run from T3 Code.
🤖 Generated with Claude Code