Skip to content
Prev Previous commit
Next Next commit
fix(cli): treat /copy 1 like /copy when no AI turn has text
  • Loading branch information
burrows99 committed Nov 16, 2026
commit f03697d6a6e551a2b3532207cc98ce69070014b3
8 changes: 8 additions & 0 deletions packages/cli/src/ui/commands/copyCommand.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,14 @@ math then literal: $x^2\$$`,
messageType: 'info',
content: 'Only 0 AI messages in this session.',
});
// `/copy 1` is documented as equivalent to `/copy`.
for (const args of ['', '1']) {
expect(await copyCommand.action(mockContext, args)).toEqual({
type: 'message',
messageType: 'info',
content: 'Last AI output contains no text to copy.',
});
}
expect(mockCopyToClipboard).not.toHaveBeenCalled();
});

Expand Down
8 changes: 6 additions & 2 deletions packages/cli/src/ui/commands/copyCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,12 @@ export const copyCommand: SlashCommand = {

const { messageIndex, subArgs } = parseLeadingMessageIndex(args);

// An indexed call falls through to the argument and range checks below.
if (messageIndex === null && aiMessages.length === 0) {
// `/copy 1` is the same as `/copy`; any other index falls through to the
// argument and range checks below.
if (
(messageIndex === null || messageIndex === 1) &&
aiMessages.length === 0
) {
return {
type: 'message',
messageType: 'info',
Expand Down
Loading