Repository navigation
fix(composer): ignore delayed PR/MR lookups after you change the form - #26954
Conversation
3c45023 to
0c1d57c
Compare
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🔵 Low · up to A delayed lookup can replace form choices after switching hosts. This is a narrow, fixable risk to address before merging. Pre-merge checks |
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
ccf65500-1660-4ed9-8df0-676c2e673435
📒 Files selected for processing (26)
src/renderer/src/hooks/composer-state/async-composer-state.tssrc/renderer/src/hooks/composer-state/async-model.tssrc/renderer/src/hooks/composer-state/branch-start-point-actions.test.tssrc/renderer/src/hooks/composer-state/branch-start-point-actions.tssrc/renderer/src/hooks/composer-state/composer-decisions.tssrc/renderer/src/hooks/composer-state/composer-deferred-source-name.test.tssrc/renderer/src/hooks/composer-state/composer-external-sync.tssrc/renderer/src/hooks/composer-state/composer-name-ownership.test.tssrc/renderer/src/hooks/composer-state/composer-name-source-selection.test.tssrc/renderer/src/hooks/composer-state/composer-review-base-fencing.test.tssrc/renderer/src/hooks/composer-state/composer-review-base-submit-cache.test.tssrc/renderer/src/hooks/composer-state/composer-review-base-test-fixture.tssrc/renderer/src/hooks/composer-state/composer-source-state.tssrc/renderer/src/hooks/composer-state/composer-submit-source-ownership.test.tssrc/renderer/src/hooks/composer-state/github-provider-selection.tssrc/renderer/src/hooks/composer-state/github-submit-resolution.tssrc/renderer/src/hooks/composer-state/gitlab-provider-selection.tssrc/renderer/src/hooks/composer-state/issue-source-actions.tssrc/renderer/src/hooks/composer-state/multiple-create-reset.test.tssrc/renderer/src/hooks/composer-state/project-target-actions.tssrc/renderer/src/hooks/composer-state/source-identity-actions.tssrc/renderer/src/hooks/composer-state/source-selection-decisions.tssrc/renderer/src/hooks/composer-state/target-change-actions.tssrc/renderer/src/hooks/composer-state/work-item-source-actions.tssrc/renderer/src/hooks/useComposerState-host-context-boundaries.test.tssrc/renderer/src/hooks/useComposerState-host-retarget.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
| @@ -131,7 +132,7 @@ export function useTargetChangeActions(input: TargetChangeActionsInput) { | |||
| setForkPushWarning(null) | |||
| } | |||
| if (!options.preserveStartFrom) { | |||
| smartGitHubPrStartPointSelectionRef.current = null | |||
| smartSourceSelectionRef.current = null | |||
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Fence non-GitHub-PR lookups during preserved repository changes.
A same-project host switch preserves smartSourceSelectionRef.current unless it contains a GitHub PR. A pending GitLab MR or GitHub submit lookup can therefore pass its identity guard and publish a result from the previous repository context. Clear the shared selection ref for non-GitHub-PR selections while retaining the existing GitHub PR retargeting.
Suggested fix
- if (!options.preserveStartFrom) {
+ if (!options.preserveStartFrom || smartSourceSelectionRef.current?.kind !== 'github-pr') {
smartSourceSelectionRef.current = null
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // Why: only a GitHub PR re-resolves on the new host; other review bases are kept as before. | |
| if (options.preserveStartFrom && smartSourceSelectionRef.current?.kind === 'github-pr') { | |
| smartSourceSelectionRef.current = retargetGitHubPrStartPointSelection( | |
| smartSourceSelectionRef.current, | |
| value | |
| ) | |
| setBaseBranch(undefined) | |
| setCompareBaseRef(undefined) | |
| setPushTarget(undefined) | |
| setBranchNameOverride(undefined) | |
| setBranchNameOverridePreservesNameEdits(false) | |
| branchAutoNameRef.current = '' | |
| setForkPushWarning(null) | |
| } | |
| if (!options.preserveStartFrom || smartSourceSelectionRef.current?.kind !== 'github-pr') { | |
| smartSourceSelectionRef.current = null |
ELI5
When you pick a GitHub PR or GitLab MR in the New Workspace composer, Orca looks up its base branch in the background. If you change your mind before that lookup finishes (pick a different issue, change the base, switch project or folder), the old answer could still arrive and overwrite what you chose. Now an old answer is ignored once you've moved on.
What Changed
#123lookup started by pressing Create could also overwrite a name you edited while it ran.Why
There was already one marker for GitHub PR lookups. Extending it to the other lookups fixes all of them in one place, including switches between providers, instead of adding a separate flag per provider. Renderer-only; no wire, storage or host changes.
Linked Issue
Follow-up to #26937 (no separate issue).
Visual Proof
Before/after captures from the original PR description are still accurate for the GitLab MR case: choose MR !2, switch to another issue and base, then let the MR lookup finish. Before: the MR's base replaces your choice. After: your choice stays.
Testing
New tests in
composer-review-base-fencing,composer-review-base-submit-cacheandcomposer-submit-source-ownership. With the GitLab fix removed, the GitLab cases fail against main (late reply overwrites the form). The full composer suite passes (20 files, 209 tests).pnpm tc:web,oxlint,check:code-quality:changedandpnpm lint(owner-routing ratchet at 0) pass.Review
Rebuilt on current main (kept main's owner routing in the three conflicting files). P0/P1 review found one regression: a resolved GitLab MR base was cleared on a same-project host switch. Fixed, with a regression test. A second note (typing a branch while a PR/MR lookup is pending is still overwritten when it lands) is existing behavior on main and left as is.
Agent skill upstream boundary
Checklist