fix(github): never attach a PR to the primary worktree#37
Open
zaridan wants to merge 1 commit into
Open
Conversation
The primary (default-branch) worktree could surface a feature PR badge when a stale linked PR number was persisted on it. Enforce the invariant that the primary worktree is categorically PR-free: - getPRForBranchOutcome short-circuits to no-pr when isPrimaryWorktree is set, ignoring any stale persisted linked/fallback number and skipping implicit branch matching. The PR-refresh coordinator passes the flag from the candidate's isMainWorktree. - mergeWorktree drops linkedPR for the main worktree so no badge renders, provider-agnostically (GitHub/GitLab/Bitbucket/etc). - A load-time persistence cleanup scrubs any stale linkedPR persisted on the primary worktree (idempotent), dropping the existing bad state. Merged-implicit (stablyai#5524) and merged-for-current-head (stablyai#5877) behavior is unchanged for non-primary worktrees. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symptom
A feature PR (e.g.
RIQAPP-363: Phase 2 …) showed up attached to the Primary / default-branch worktree in the sidebar — the primary worktree idles onmainand must never carry a PR badge.Root cause
A stale persisted
linkedPRwas bound to the primary worktree id (${repoId}::${repoPath}). The renderer passed it aslinkedPRNumber, andgetPRForBranchOutcomere-hydrated it via exact PR lookup by number. This is not the implicit branch-match path that stablyai#5524 already guards (and the merged-only guard from stablyai#5524/stablyai#5877 didn't catch it because the PR is open).Fix — 3 layers + cleanup
getPRForBranchOutcomeshort-circuits tono-prwhen the newisPrimaryWorktreeoption is set, before any lookup — ignoring stale linked/fallback numbers and skipping implicit branch matching. The PR-refresh coordinator passes the flag fromcandidate.isMainWorktree, threaded fromworktree.isMainWorktreein the renderer candidate builder.mergeWorktreedropslinkedPRfor the main worktree, provider-agnostically (GitHub/GitLab/Bitbucket/etc), so no badge renders regardless of provider.clearLinkedPRForPrimaryWorktreesscrubs any stalelinkedPRoff disk at load (idempotent), so the existing stuck badge clears rather than just being hidden going forward.Tests
mergeWorktreeprimary/non-primary + persistence cleanup (idempotent, scrubs disk).Lint (
oxlint) clean; node + web typechecks clean.🤖 Generated with Claude Code