Skip to content

Commit 2544a7b

Browse files
authored
Do not await clipboard image data when not supported (microsoft#229835)
Don't await clipboard image data when not supported
1 parent 178c125 commit 2544a7b

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/vs/workbench/contrib/chat/browser/actions/chatContextActions.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,6 @@ class AttachContextAction extends Action2 {
334334
return;
335335
}
336336

337-
const imageData = await clipboardService.readImage();
338-
339337
const usedAgent = widget.parsedInput.parts.find(p => p instanceof ChatRequestAgentPart);
340338
const slowSupported = usedAgent ? usedAgent.agent.metadata.supportsSlowVariables : true;
341339
const quickPickItems: (IChatContextQuickPickItem | QuickPickItem)[] = [];
@@ -351,13 +349,16 @@ class AttachContextAction extends Action2 {
351349
}
352350
}
353351

354-
if (isImage(imageData) && configurationService.getValue<boolean>('chat.experimental.imageAttachments')) {
355-
quickPickItems.push({
356-
id: await imageToHash(imageData),
357-
kind: 'image',
358-
label: localize('imageFromClipboard', 'Image from Clipboard'),
359-
iconClass: ThemeIcon.asClassName(Codicon.fileMedia),
360-
});
352+
if (configurationService.getValue<boolean>('chat.experimental.imageAttachments')) {
353+
const imageData = await clipboardService.readImage();
354+
if (isImage(imageData)) {
355+
quickPickItems.push({
356+
id: await imageToHash(imageData),
357+
kind: 'image',
358+
label: localize('imageFromClipboard', 'Image from Clipboard'),
359+
iconClass: ThemeIcon.asClassName(Codicon.fileMedia),
360+
});
361+
}
361362
}
362363

363364
if (widget.viewModel?.sessionId) {

0 commit comments

Comments
 (0)