diff --git a/src/renderer/src/components/right-sidebar/SourceControl.preview-open.test.tsx b/src/renderer/src/components/right-sidebar/SourceControl.preview-open.test.tsx index a7236b7bb77..9c54e96a54a 100644 --- a/src/renderer/src/components/right-sidebar/SourceControl.preview-open.test.tsx +++ b/src/renderer/src/components/right-sidebar/SourceControl.preview-open.test.tsx @@ -291,7 +291,53 @@ function clickViewAllButton(): void { }) } +async function waitForCondition(assertion: () => void): Promise { + let lastError: unknown + for (let attempt = 0; attempt < 20; attempt++) { + try { + assertion() + return + } catch (error) { + lastError = error + await act(async () => { + await new Promise((resolve) => setTimeout(resolve, 10)) + }) + } + } + throw lastError +} + describe('SourceControl preview row opens', () => { + it('shows Create PR chrome in embedded scoped worktree source control', async () => { + resetState({ + rightSidebarOpen: true, + getHostedReviewCreationEligibility: vi.fn().mockResolvedValue({ + provider: 'github', + review: null, + canCreate: true, + blockedReason: null, + nextAction: null + }), + remoteStatusesByWorktree: { + [mocks.activeWorktree.id]: { + hasUpstream: true, + upstreamName: 'origin/feature/source-control-preview', + ahead: 0, + behind: 0 + } + }, + gitBranchCompareSummaryByWorktree: { + [mocks.activeWorktree.id]: branchSummary() + } + }) + + renderSourceControl({ worktreeId: mocks.activeWorktree.id, embedded: true }) + + await waitForCondition(() => { + expect(container.textContent).toContain('Create PR') + }) + }) + it('passes preview=true when plain uncommitted row clicks open diff tabs', () => { resetState({ gitStatusByWorktree: { diff --git a/src/renderer/src/components/right-sidebar/SourceControl.tsx b/src/renderer/src/components/right-sidebar/SourceControl.tsx index 9848842cccc..7747dfda79c 100644 --- a/src/renderer/src/components/right-sidebar/SourceControl.tsx +++ b/src/renderer/src/components/right-sidebar/SourceControl.tsx @@ -1380,7 +1380,9 @@ function SourceControlInner({ const baseRefOwnedByWorktree = normalizedWorktreeBaseRef !== null const pinnedBaseRef = normalizedWorktreeBaseRef ?? normalizedRepoBaseRef const hasUncommittedEntries = entries.length > 0 - const hostedReviewSurfaceEnabled = !embedded + // Why: embedded folder sections are scoped to one child worktree, so hosted + // review actions can target that repo/host with the same identity as diffs. + const hostedReviewSurfaceEnabled = Boolean(activeWorktreeId && activeRepo && !isFolder) const hostedReviewCreation = hostedReviewCreationState &&