diff --git a/packages/navie/src/commands/review-command.ts b/packages/navie/src/commands/review-command.ts index 16a119056d..d812d880f1 100644 --- a/packages/navie/src/commands/review-command.ts +++ b/packages/navie/src/commands/review-command.ts @@ -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; } diff --git a/packages/navie/test/commands/review-command.spec.ts b/packages/navie/test/commands/review-command.spec.ts index 733a8994d8..496ab0b3f1 100644 --- a/packages/navie/test/commands/review-command.spec.ts +++ b/packages/navie/test/commands/review-command.spec.ts @@ -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(`\n${content}\n`), + }); + }); + it('includes the diff in the initial user prompt', async () => { const content = 'truly unique diff content'; const result = await read(