From 58b43e0d17073651db52e54cb11e641fe074ce65 Mon Sep 17 00:00:00 2001 From: Jinwoo Hong <73622457+Jinwoo-H@users.noreply.github.com> Date: Sun, 19 Apr 2026 00:12:45 -0400 Subject: [PATCH] fix(github): Needs My Review tab returns no results (#815) --- src/main/github/client-work-items.test.ts | 23 ++++++++++++----- src/main/github/client.ts | 30 +++++++++++++++++------ 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/src/main/github/client-work-items.test.ts b/src/main/github/client-work-items.test.ts index 7749527df..a43f98344 100644 --- a/src/main/github/client-work-items.test.ts +++ b/src/main/github/client-work-items.test.ts @@ -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', diff --git a/src/main/github/client.ts b/src/main/github/client.ts index 89bc860d0..efdf45938 100644 --- a/src/main/github/client.ts +++ b/src/main/github/client.ts @@ -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 }