fix(github): Needs My Review tab returns no results (#815)

This commit is contained in:
Jinwoo Hong 2026-04-19 00:12:45 -04:00 committed by GitHub
parent d45755274f
commit 58b43e0d17
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 39 additions and 14 deletions

View file

@ -75,9 +75,7 @@ describe('listWorkItems', () => {
}
])
})
const items = await listWorkItems('/repo-root', 10, 'assignee:@me')
expect(ghExecFileAsyncMock).toHaveBeenNthCalledWith(
1,
[
@ -156,9 +154,7 @@ describe('listWorkItems', () => {
}
])
})
const items = await listWorkItems('/repo-root', 10, 'is:pr is:draft')
expect(ghExecFileAsyncMock).toHaveBeenCalledTimes(1)
expect(ghExecFileAsyncMock).toHaveBeenCalledWith(
[
@ -193,6 +189,23 @@ describe('listWorkItems', () => {
])
})
it('passes review-requested as a --search qualifier (gh CLI has no dedicated flag)', async () => {
getOwnerRepoMock.mockResolvedValueOnce({ owner: 'acme', repo: 'widgets' })
ghExecFileAsyncMock.mockResolvedValueOnce({ stdout: '[]' })
await listWorkItems('/repo-root', 10, 'review-requested:@me is:open')
expect(ghExecFileAsyncMock).toHaveBeenCalledTimes(1)
expect(ghExecFileAsyncMock).toHaveBeenCalledWith(
expect.arrayContaining(['--search', 'review-requested:@me']),
{ cwd: '/repo-root' }
)
expect(ghExecFileAsyncMock).not.toHaveBeenCalledWith(
expect.arrayContaining(['--review-requested']),
expect.anything()
)
})
it('returns open issues and PRs for the all-open preset query', async () => {
getOwnerRepoMock.mockResolvedValueOnce({ owner: 'acme', repo: 'widgets' })
ghExecFileAsyncMock
@ -225,9 +238,7 @@ describe('listWorkItems', () => {
}
])
})
const items = await listWorkItems('/repo-root', 10, 'is:open')
expect(ghExecFileAsyncMock).toHaveBeenCalledWith(
[
'issue',

View file

@ -305,17 +305,31 @@ function buildWorkItemListArgs(args: {
out.push('--label', label)
}
}
if (kind === 'pr' && query.reviewRequested) {
out.push('--review-requested', query.reviewRequested)
}
if (kind === 'pr' && query.reviewedBy) {
out.push('--reviewed-by', query.reviewedBy)
}
if (kind === 'pr' && query.scope === 'pr' && query.state === 'open' && query.freeText === '') {
if (
kind === 'pr' &&
query.scope === 'pr' &&
query.state === 'open' &&
query.freeText === '' &&
!query.reviewRequested &&
!query.reviewedBy
) {
out.push('--draft')
}
// review-requested and reviewed-by are not supported as standalone gh CLI flags,
// so they must be passed as GitHub search qualifiers via --search.
const searchParts: string[] = []
if (kind === 'pr' && query.reviewRequested) {
searchParts.push(`review-requested:${query.reviewRequested}`)
}
if (kind === 'pr' && query.reviewedBy) {
searchParts.push(`reviewed-by:${query.reviewedBy}`)
}
if (query.freeText) {
out.push('--search', query.freeText)
searchParts.push(query.freeText)
}
if (searchParts.length > 0) {
out.push('--search', searchParts.join(' '))
}
return out
}