Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions packages/cli/src/ui/commands/copyCommand.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,32 @@ describe('copyCommand', () => {
});
});

it('should not copy thought parts from the last AI message', async () => {
if (!copyCommand.action) throw new Error('Command has no action');

const historyWithThoughtPart = [
{
role: 'model',
parts: [
{ text: 'internal reasoning', thought: true },
{ text: 'Visible report' },
],
},
];

mockGetHistoryShallow.mockReturnValue(historyWithThoughtPart);
mockCopyToClipboard.mockResolvedValue(undefined);

const result = await copyCommand.action(mockContext, '');

expect(mockCopyToClipboard).toHaveBeenCalledWith('Visible report');
expect(result).toEqual({
type: 'message',
messageType: 'info',
content: 'Last output copied to the clipboard',
});
});

it('should filter out non-text parts', async () => {
if (!copyCommand.action) throw new Error('Command has no action');

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/ui/commands/copyCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ export const copyCommand: SlashCommand = {
}
// Extract text from the parts
const lastAiOutput = lastAiMessage.parts
?.filter((part) => part.text)
?.filter((part) => part.text && !part.thought)
.map((part) => part.text)
.join('');

Expand Down
Loading