Show branch-discovered PRs on worktrees with no linked PRs (#5894)
Allow branch-discovered GitHub and GitLab PRs to display on the worktree card even when the worktree has no explicitly linked PR metadata. This is enabled by passing the review hint key option down and allowing the PR display logic to show neutral branch-level lookups when no linked review key is present.
This commit is contained in:
parent
b51a995703
commit
55456e0c2d
|
|
@ -247,6 +247,30 @@ describe('WorktreeCard linked PR display', () => {
|
|||
expect(markup).not.toContain('Stale branch PR')
|
||||
})
|
||||
|
||||
it('shows branch-discovered GH PR status when the worktree has no linked PR', async () => {
|
||||
settings = { experimentalNewWorktreeCardStyle: true }
|
||||
hostedReviewCache = {
|
||||
'local::repo-1::feature/local-branch': {
|
||||
data: makeHostedReview({ number: 456, title: 'Branch PR', state: 'open' }),
|
||||
fetchedAt: Date.now(),
|
||||
linkedReviewHintKey: ''
|
||||
}
|
||||
}
|
||||
const { default: WorktreeCard } = await import('./WorktreeCard')
|
||||
|
||||
const markup = renderWorktreeCardMarkup(
|
||||
<WorktreeCard
|
||||
worktree={makeWorktree({ linkedPR: null })}
|
||||
repo={makeRepo()}
|
||||
isActive={false}
|
||||
/>
|
||||
)
|
||||
|
||||
expect(markup).toContain('PR checks: Passing')
|
||||
expect(markup).toContain('text-emerald-500/80')
|
||||
expect(markup).not.toContain('Branch')
|
||||
})
|
||||
|
||||
it('shows branch-discovered hosted review providers without linked worktree metadata', async () => {
|
||||
settings = { experimentalNewWorktreeCardStyle: true }
|
||||
hostedReviewCache = {
|
||||
|
|
|
|||
|
|
@ -409,7 +409,10 @@ const WorktreeCard = React.memo(function WorktreeCard({
|
|||
linkedGitLabMR,
|
||||
linkedBitbucketPR,
|
||||
linkedAzureDevOpsPR,
|
||||
linkedGiteaPR
|
||||
linkedGiteaPR,
|
||||
{
|
||||
reviewHintKey: hostedReviewEntry?.linkedReviewHintKey
|
||||
}
|
||||
)
|
||||
const issue: IssueInfo | null | undefined = worktree.linkedIssue
|
||||
? issueEntry !== undefined
|
||||
|
|
|
|||
|
|
@ -60,7 +60,23 @@ describe('getWorktreeCardPrDisplay', () => {
|
|||
expect(getWorktreeCardPrDisplay(undefined, null)).toBeNull()
|
||||
})
|
||||
|
||||
it('ignores cached branch PR details when the worktree is unlinked', () => {
|
||||
it('ignores linked-lookup PR details when the worktree is unlinked', () => {
|
||||
expect(
|
||||
getWorktreeCardPrDisplay(pr, null, null, null, null, null, {
|
||||
reviewHintKey: 'github:123'
|
||||
})
|
||||
).toBeNull()
|
||||
})
|
||||
|
||||
it('shows branch-discovered GitHub PR details when the worktree is unlinked', () => {
|
||||
expect(
|
||||
getWorktreeCardPrDisplay(pr, null, null, null, null, null, {
|
||||
reviewHintKey: ''
|
||||
})
|
||||
).toBe(pr)
|
||||
})
|
||||
|
||||
it('treats missing cache hints as unsafe for unlinked GitHub PR details', () => {
|
||||
expect(getWorktreeCardPrDisplay(pr, null)).toBeNull()
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,10 @@ export type WorktreeCardPrDisplay =
|
|||
status?: HostedReviewInfo['status']
|
||||
}
|
||||
|
||||
type WorktreeCardPrDisplayOptions = {
|
||||
reviewHintKey?: string
|
||||
}
|
||||
|
||||
function getLinkedReviewNumber(
|
||||
provider: LinkedReviewMetadataProvider,
|
||||
links: LinkedReviewNumbers
|
||||
|
|
@ -60,7 +64,8 @@ export function getWorktreeCardPrDisplay(
|
|||
linkedGitLabMR: number | null = null,
|
||||
linkedBitbucketPR: number | null = null,
|
||||
linkedAzureDevOpsPR: number | null = null,
|
||||
linkedGiteaPR: number | null = null
|
||||
linkedGiteaPR: number | null = null,
|
||||
options: WorktreeCardPrDisplayOptions = {}
|
||||
): WorktreeCardPrDisplay | null {
|
||||
const links = {
|
||||
linkedPR,
|
||||
|
|
@ -75,7 +80,12 @@ export function getWorktreeCardPrDisplay(
|
|||
}
|
||||
const linkedReviewNumber = getLinkedReviewNumber(review.provider, links)
|
||||
if (linkedReviewNumber === null) {
|
||||
return review.provider === 'github' || review.provider === 'gitlab' ? null : review
|
||||
if (review.provider !== 'github' && review.provider !== 'gitlab') {
|
||||
return review
|
||||
}
|
||||
// Why: GitHub/GitLab linked lookups can outlive the worktree metadata
|
||||
// that requested them. A neutral branch lookup is safe to show unlinked.
|
||||
return options.reviewHintKey === '' ? review : null
|
||||
}
|
||||
if (review.number === linkedReviewNumber) {
|
||||
return review
|
||||
|
|
|
|||
Loading…
Reference in New Issue