fix(server): a merge settles every thread in the PR's worktree again #43264
Opennikalezah(GitHub profile, opens in a new tab)wants to merge 2 commits into
main fromrefs/pull/43264/headopened View on GitHubnikalezah(GitHub profile, opens in a new tab) linked this to fix #43263
tanstack-source added labelsbug
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
juliusmarminge added labelstakeover:in-progress
- @@ -2339,0 +2363,21 @@2363+ number: 42,2364+ url: "https://example.test/owner/repository/pull/42",2365+ },2366+ });2367+ const fixture = yield* makeHarness({2368+ snapshot: makeSnapshot([owner, sibling, cachedSibling, localSibling]),2369+ settings: {2370+ ...DEFAULT_SERVER_SETTINGS,2371+ sidebarAutoSettleOnMerge: true,2372+ sidebarAutoSettleAfterDays: null,2373+ },2374+ existingWorktreePaths: ["/worktrees/feature/.git"],2375+ branchPullRequest: () => Effect.succeed(makeBranchPullRequest("merged")),2376+ });2377+2378+ yield* Effect.gen(function* () {2379+ const reactor = yield* ThreadSettlementService.ThreadSettlementServiceV2;2380+ yield* startHarness(reactor, fixture.activation, fixture.snapshotReads);2381+ yield* fixture.publishMerge;2382+ yield* Queue.take(fixture.snapshotReads);2383+ yield* reactor.drain;
Pushedba0345f
juliusmarminge added labelstakeover:needs-julius
juliusmarminge removed labelstakeover:in-progress
Sign in to join this conversation.


Important
Review skipped#
Review was skipped as selected files did not have any reviewable changes.
97f80897-9093-47fc-aaee-b02bb4a160d3Reviewing files that changed from the base of the PR and between 18b933b6638d814e8311c89a09c6752bda7b2a0b and ba0345f2beffa9cc0c56579633b1086ee5f1673a.
You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Walkthrough
Settlement now applies terminal pull-request ownership checks according to whether a thread uses the project checkout or a worktree. A test covers merge-triggered settlement for threads sharing a worktree.
Changes: Thread settlement
apps/server/src/orchestration-v2/ThreadSettlementService.ts,apps/server/src/orchestration-v2/ThreadSettlementService.test.tsEstimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Low
Suggested reviewers:
juliusmarminge,only21milMerge Risk:
Low · previous review
18b93This change restores auto-settlement of sibling threads that share a worktree when a PR is merged or closed, while Local threads keep the existing protection. The production logic looks aligned with the issue. The new regression test may read results before the merge sweep finishes and could fail intermittently, so tighten its wait before relying on it in CI.
Pre-merge checks:
4
#40564and the affected worktree threads. It has a Change section that explains the narrowed ownership …#43263] requires that merging or closing a PR settles every thread in the same worktree, including threads that do not link the PR. The diff at ThreadSettlementService.ts adds an inProjectCheckout(th…#43263describes. The added test covers the same worktree se…Full details: Title check
Explanation
The title names the main change: a merge settles every thread in the PR's worktree again. It is a conventional commit with the fix(server) scope. The changeset narrows the ownership check in ThreadSettlementService so worktree lookups settle from the branch's merged or closed PR, which matches the title.
Full details: Description check
Explanation
The description follows the template. It has a Problem section that explains the regression from
#40564and the affected worktree threads. It has a Change section that explains the narrowed ownership check. It has a Scope section that links#43263as the bug issue. It has a Verification section with a real-app run, a new focused test, and the result of check:changed. It notes what is not in this change. The template asks for a model and harness line, and the author gave one (Claude Opus 5.5 in Claude Code). The template's HTML comments are not present, and the description does not strictly use the template headings. The content covers each required item, so the check passes.Full details: Linked Issues check
Explanation
[
#43263] requires that merging or closing a PR settles every thread in the same worktree, including threads that do not link the PR. The diff at ThreadSettlementService.ts adds an inProjectCheckout(thread) predicate. It returns true only when the lookup cwd equals the project workspaceRoot, or when no cwd is set. ownedByAnotherThread now returns false for worktree lookups, so a worktree thread settles from its branch's merged or closed PR. The linked-reference skip is also gated by inProjectCheckout, so worktree threads are not blocked by another thread's link. The explicitlyLinked read runs only when some candidate lookup is in the project checkout. Local threads keep the#40564ownership check (#40554). The summary reports a new worker test covering worktree siblings with and without a cached PR and a Local sibling. That test was not inspected directly in this review. The issue requirement is implemented in source code at the reviewed head.Full details: Out of Scope Changes check
Explanation
All changes are in ThreadSettlementService.ts and its test file. The service changes are limited to the ownership and linked-PR checks that
#43263describes. The added test covers the same worktree settlement behavior. The PR description's claim that the explicitlyLinked read is limited to project-checkout sweeps matches the code. No unrelated behavior change was found in the inspected diff.Finishing Touches
Generate unit tests (beta)