Skip to content

fix(server): reuse pr state when settling threads - #9459

Merged
maria-rcks merged 1 commit into
pingdotgg:mainfrom
maria-rcks:t3code/fix-merged-pr-thread-settling
Sep 3, 2026
Merged

maria-rcks merged 1 commit into
pingdotgg:mainfrom
maria-rcks:t3code/fix-merged-pr-thread-settling

Conversation

@maria-rcks

@maria-rcks maria-rcks commented Sep 3, 2026 •

Copy link
Copy Markdown
Collaborator

Merged threads could remain active for about two minutes because automatic settlement looked up PR state from the project root while the sidebar refreshed the same branch from its worktree. Since GitManager caches PR lookups by cwd for two minutes, those paths held independent state. This reuses the live worktree for settlement, falls back to the project root after deletion, and is verified by 9 focused reactor tests plus the server typecheck.

Built by gpt-5.6-sol in the Codex harness.


Note

Low Risk
Behavior change is limited to cwd selection for existing settlement PR lookups, with filesystem existence checks and fallback to the prior root path.

Overview
Fixes delayed auto-settlement when a thread’s PR was already merged but the sidebar had fresher state: branch PR lookups during settlement sweeps now use the thread’s live worktree path when it still exists, matching the sidebar, so both paths share GitManager’s cwd-keyed PR cache (2-minute TTL). If the worktree path is missing on disk, settlement falls back to the project workspace root as before.

Lookup grouping and git.branchPullRequest calls use this per-thread cwd instead of always using project.workspaceRoot. Tests add a FileSystem noop layer and a case that asserts live vs deleted worktrees get the expected cwd values.

Reviewed by Cursor Bugbot for commit 3612d88. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Fix ThreadSettlementReactor to use existing worktree path for branch PR lookups

  • ThreadSettlementReactor.make now depends on a FileSystem service and checks whether each eligible thread's worktree path exists before running branch pull-request lookups
  • Existing worktree paths are preferred as the lookup cwd; when the worktree is absent or the existence check fails, the project workspace root is used as before
  • Existence checks run concurrently up to 8 at a time, with filesystem failures treated as non-existent paths
  • Test harness gains a mocked FileSystem layer controlled by existingWorktreePaths, and a new test verifies cwd selection for both existing and missing worktrees in ThreadSettlementReactor.test.ts
  • Risk: GitManager.branchPullRequest calls now receive per-thread cwd values instead of always the project workspace root; any callers relying on the old fixed cwd behavior in ThreadSettlementReactor.ts should verify grouping still works correctly

Macroscope summarized 3612d88.

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Sep 3, 2026
@macroscopeapp

ghost commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 3612d88

Macroscope's review found this PR approvable — This is a small, isolated server bug fix that aligns settlement PR lookups with the thread’s existing worktree while retaining a safe root fallback. The runtime change is limited to PR-state freshness during settlement sweeps and is covered by a focused regression test.

You can add or adjust custom eligibility rules. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant