mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-07-09 17:19:02 +00:00
fix(cli): skip thought parts in copy output (#4738)
This commit is contained in:
parent
16dd99fa3c
commit
58b4f35dfa
2 changed files with 27 additions and 1 deletions
|
|
@ -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');
|
||||
|
||||
|
|
|
|||
|
|
@ -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('');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue