Skip to content

fix(github): automatic linked-PR clears unselect instead of deleting references - #31989

Closed
thefrikidude wants to merge 1 commit into
stablyai:mainfrom
thefrikidude:fix/linked-pr-clear-keeps-references
Closed

thefrikidude wants to merge 1 commit into
stablyai:mainfrom
thefrikidude:fix/linked-pr-clear-keeps-references

Conversation

@thefrikidude

Copy link
Copy Markdown
Contributor

ELI5

When you attach pull requests to a workspace whose own branch has no PR, Orca kept quietly forgetting them, one per refresh. Orca was using "stop highlighting this PR" and "remove this PR from the list" as the same action. Now the automatic cleanup only stops highlighting it, and the PR stays in the list.

What Changed

Before: on a workspace whose branch has no PR of its own, each PR refresh (for example opening the hover card) cleared the selected PR. That deleted it from the workspace's references. The next orca reference add auto-selected the first remaining PR, so the next refresh deleted that one too, until the workspace lost them all.

After: the same refresh unselects the PR (linkedPR becomes null) and every reference stays in linkedItems.

Mechanism: the branch-mismatch and merged-divergence clears wrote { linkedPR: null }. In normalizeWorkspaceAttachmentUpdate, a null legacy slot removes the matching item from linkedItems. A new buildUnselectLinkedReviewUpdate helper (src/renderer/src/store/github/linked-review-unselect.ts) nulls every review slot and passes the current linkedItems, so the normalizer unselects without removing. All five automatic clear call sites use it (pull-request-actions.ts, pull-request-execution.ts x2, refresh-event-actions.ts x2).

Why

References added with orca reference add or "Manage links…" should stay until the user removes them. The clears exist so Checks does not stay pinned to a PR from another branch, and unselecting satisfies that.

Alternatives considered:

  • Skipping the clear for explicitly added references needs a way to tell explicit from discovered links; unselect-only needs no new state.
  • Not auto-selecting reviews[0] is untouched. That auto-select is now harmless, since the follow-up clear only unselects.

Behavior note: a stale branch-linked PR on a normal branch now stays in the workspace's reference list, unselected, instead of vanishing.

Linked Issue

Fixes #31962

Visual Proof

N/A. No visible UI change; the fix changes which metadata the automatic refresh writes. Verified end to end in a running app (see Testing).

Testing

Real app (isolated dev instance via ORCA_BACKGROUND_LAUNCH=1, driven over CDP; throwaway repo on branch umbrella with origin = stablyai/orca; PRs #31982, #31981, #31980 attached with orca reference add), calling the renderer's fetchPRForBranch four times:

linkedPR after refresh linkedItems
Without the fix 31981 [31981, 31980] (#31982 deleted)
With the fix null [31982, 31981, 31980] (unchanged over 4 refreshes)

Automated:

  • New regression test linked-review-unselect.test.ts: unselecting keeps both references.
  • Updated six existing assertions in github-pr-branch-linked-pr-divergence.test.ts and github-pr-branch-coordinator-events.test.ts that expected the old { linkedPR: null } payload.
  • pnpm test src/renderer/src/store passes (490 files) and pnpm tc:web passes. Full pnpm lint, pnpm test and pnpm build were not run locally; CI will cover them.

Platform tested: macOS only.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

AI Disclosure

Written with Claude (Sonnet 5.5) via Claude Code. I reviewed the diff and ran the verification above.

Author: X @thefrikidude

Review

AI code-review summary (self-review):

  • Cross-platform: no platform-specific code; renderer store logic only.
  • SSH/remote/local: the update goes through the existing updateWorktreeMeta path, which already handles remote and runtime hosts. Existing shouldApply* guards are unchanged. Not tested against SSH.
  • Agents/integrations/providers: all review slots (GitHub, GitLab, Bitbucket, Azure DevOps, Gitea) are nulled together, matching the selection-clear semantics.
  • Mobile / folder workspaces: no mobile-specific change. Folder workspaces have no branch-mismatch clear. Not tested.
  • Performance: one extra array read per clear; the clears are rare.
  • Security: none; no new inputs or I/O.
  • UI quality: not applicable.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Security, cross-platform (Linux, Windows, macOS), Remote SSH, Mobile, backwards compatibility and performance considered; see Review.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

🤖 Generated with Claude Code

…references

The branch-mismatch and merged-divergence refresh clears wrote
`linkedPR: null`, which the attachment normalizer treats as removing the
item from `linkedItems`. References added via `orca reference add` on a
workspace whose own branch has no PR were therefore deleted one per refresh.

Clear only the review selection and keep the items.

Fixes stablyai#31962

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a7a0d103-789e-40f9-90de-5ef418a44a4e
📥 Commits

Reviewing files that changed from the base of the PR and between 885cd6f and 12c268f.

📒 Files selected for processing: 7
  • src/renderer/src/store/github/linked-review-unselect.test.ts
  • src/renderer/src/store/github/linked-review-unselect.ts
  • src/renderer/src/store/github/pull-request-actions.ts
  • src/renderer/src/store/github/pull-request-execution.ts
  • src/renderer/src/store/github/refresh-event-actions.ts
  • src/renderer/src/store/slices/github-pr-branch-coordinator-events.test.ts
  • src/renderer/src/store/slices/github-pr-branch-linked-pr-divergence.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Walkthrough

Automatic linked-review clear paths now use a shared update that clears legacy linked-review fields while retaining the workspace attachments in linkedItems. The changes cover pull-request actions, lookup execution, and refresh-event handling. Tests check that the attachments remain after the selected review is cleared and update expectations for the affected clear paths.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 12c26

The automatic clear can unselect a review without the investigated path deleting a newly added workspace reference. No merge-blocking issue is established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: automatic linked-PR clears now unselect the PR without deleting its references.
Description check Passed The description is complete and directly aligned with the template. It explains the user impact, mechanism, rationale, linked issue, testing, platform scope, and checklist status. It also records that…
Linked Issues check Passed Issue #31962 requires automatic branch-mismatch and divergence clears to unselect the linked PR without deleting references added with orca reference add or “Manage links…”. The new `buildUnselectLi…
Out of Scope Changes check Passed The changes stay within issue #31962. They add one helper, replace the five automatic clear payloads, and update focused tests for the preserved-reference behavior. No unrelated product behavior or fi…
Full details: Description check

Explanation

The description is complete and directly aligned with the template. It explains the user impact, mechanism, rationale, linked issue, testing, platform scope, and checklist status. It also records that full lint, test, typecheck, and build commands were not run locally and are expected to run in CI.

Full details: Linked Issues check

Explanation

Issue #31962 requires automatic branch-mismatch and divergence clears to unselect the linked PR without deleting references added with orca reference add or “Manage links…”. The new buildUnselectLinkedReviewUpdate clears all review selection slots and restores the current linkedItems. All five automatic clear call sites use this helper. The regression test verifies that selection becomes null while both references remain. The updated coordinator and divergence tests cover the new update payload.

Full details: Out of Scope Changes check

Explanation

The changes stay within issue #31962. They add one helper, replace the five automatic clear payloads, and update focused tests for the preserved-reference behavior. No unrelated product behavior or files are changed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@thefrikidude

Copy link
Copy Markdown
Contributor Author

Closing as superseded by #32263, which already fixes this on main: automatic linked-PR clears now unselect the review via CLEARED_HOSTED_REVIEW_SELECTION_UPDATES while preserving linkedItems references.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Automatic linked-PR clears delete orca reference add PRs one per refresh when the workspace branch has no PR

1 participant