From 985bad8a0277d6d9b4d4745188a00df5657daaad Mon Sep 17 00:00:00 2001 From: orca-bug-scan-bot Date: Wed, 6 May 2026 20:10:58 -0700 Subject: [PATCH] fix: address pr-bug-scan findings from #1466 Cleared selectedRepoSlug synchronously at the top of the resolution effect so a repo switch invalidates the prior slug until the new IPC call resolves, preventing cross-repo PR mislinks during the in- --- src/renderer/src/hooks/useComposerState.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/hooks/useComposerState.ts b/src/renderer/src/hooks/useComposerState.ts index 68dfe9c6b2c..6b814e0b369 100644 --- a/src/renderer/src/hooks/useComposerState.ts +++ b/src/renderer/src/hooks/useComposerState.ts @@ -378,8 +378,13 @@ export function useComposerState(options: UseComposerStateOptions): UseComposerS ) const selectedRepoPath = selectedRepo?.path useEffect(() => { + // Why: clear synchronously on every change so a repo switch (path A → B) + // invalidates the prior slug until the new IPC call resolves. Without + // this, effectiveLinkedPR would accept a PR URL whose slug matches the + // previous repo during the in-flight window — exactly the cross-repo + // mislink the slug guard is meant to prevent. + setSelectedRepoSlug(null) if (!selectedRepoPath) { - setSelectedRepoSlug(null) return } let cancelled = false