Skip to content

Commit

Permalink
fix: Review now includes code selections
Browse files Browse the repository at this point in the history
The JetBrains is still sending pinned items as 'code selections',
instead of located files. This means that in IntelliJ, pinned items
would not be considered during `@review`.
  • Loading branch information
dustinbyrne committed Dec 17, 2024
1 parent 18feabf commit 8ea7137
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/navie/src/commands/review-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,15 @@ ${userPrompt}
{ locations }
);
}

// For backwards compatibility, include the code selections which have been sent
// without a location.
pinnedItemLookup.push(
...pinnedItems
.filter(UserContext.isCodeSelectionItem)
.map((cs) => ({ ...cs, type: ContextV2.ContextItemType.CodeSelection }))
);

return pinnedItemLookup;
}

Expand Down
28 changes: 28 additions & 0 deletions packages/navie/test/commands/review-command.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,34 @@ lgtm
});
});

it('includes the code selections which have been sent without a location', async () => {
const content = 'here is some review criteria';
const result = await read(
command.execute({
question: 'review',
userOptions: new UserOptions(new Map()),
codeSelection: [
{
type: 'code-selection',
content,
},
{
type: 'code-snippet',
location: 'git diff',
content: 'diff content',
},
],
})
);

const [firstArgument]: [Message[]] = (completionService.complete as jest.Mock).mock.calls[0];
expect(result).toEqual(exampleSummaryMarkdown);
expect(firstArgument[1]).toStrictEqual({
role: 'user',
content: expect.stringContaining(`<code-selection>\n${content}\n</code-selection>`),
});
});

it('includes the diff in the initial user prompt', async () => {
const content = 'truly unique diff content';
const result = await read(
Expand Down

0 comments on commit 8ea7137

Please sign in to comment.