Skip to content

Commit e997280

Browse files
authored
fix image hover langauge and some omission issues (microsoft#250692)
fix hover isues
1 parent 1a73941 commit e997280

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/vs/workbench/contrib/chat/browser/chatAttachmentWidgets.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ export class FileAttachmentWidget extends AbstractChatAttachmentWidget {
227227
hoverElement.setAttribute('aria-label', ariaLabel);
228228
this.element.classList.add('warning');
229229

230-
hoverElement.textContent = localize('chat.fileAttachmentHover', "{0} does not support this {1} type.", this.currentLanguageModel ? this.languageModelsService.lookupLanguageModel(this.currentLanguageModel.identifier)?.name : this.currentLanguageModel, 'file');
230+
hoverElement.textContent = localize('chat.fileAttachmentHover', "{0} does not support this file type.", this.currentLanguageModel ? this.languageModelsService.lookupLanguageModel(this.currentLanguageModel.identifier)?.name : this.currentLanguageModel ?? 'This model');
231231
this._register(this.hoverService.setupManagedHover(hoverDelegate, this.element, hoverElement, { trapFocus: true }));
232232
}
233233
}
@@ -305,7 +305,7 @@ function createImageElements(resource: URI | undefined, name: string, fullName:
305305
element: HTMLElement,
306306
buffer: ArrayBuffer | Uint8Array,
307307
hoverService: IHoverService, ariaLabel: string,
308-
currentLanguageModelName: string,
308+
currentLanguageModelName: string | undefined,
309309
clickHandler: () => void,
310310
currentLanguageModel?: ILanguageModelChatMetadataAndIdentifier,
311311
omittedState?: OmittedState): IDisposable {
@@ -333,7 +333,7 @@ function createImageElements(resource: URI | undefined, name: string, fullName:
333333

334334
if ((!supportsVision && currentLanguageModel) || omittedState === OmittedState.Full) {
335335
element.classList.add('warning');
336-
hoverElement.textContent = localize('chat.fileAttachmentHover', "{0} does not support this {1} type.", currentLanguageModelName, 'image');
336+
hoverElement.textContent = localize('chat.imageAttachmentHover', "{0} does not support images.", currentLanguageModelName ?? 'This model');
337337
disposable.add(hoverService.setupDelayedHover(element, { content: hoverElement, appearance: { showPointer: true } }));
338338
} else {
339339
disposable.add(hoverService.setupDelayedHover(element, { content: hoverElement, appearance: { showPointer: true } }));
@@ -599,7 +599,7 @@ export class NotebookCellOutputChatAttachmentWidget extends AbstractChatAttachme
599599
}
600600

601601
const clickHandler = async () => await this.openResource(resource, false, undefined);
602-
const currentLanguageModelName = this.currentLanguageModel ? this.languageModelsService.lookupLanguageModel(this.currentLanguageModel.identifier)?.name ?? this.currentLanguageModel.identifier : 'unknown';
602+
const currentLanguageModelName = this.currentLanguageModel ? this.languageModelsService.lookupLanguageModel(this.currentLanguageModel.identifier)?.name ?? this.currentLanguageModel.identifier : undefined;
603603
const buffer = this.getOutputItem(resource, attachment)?.data.buffer ?? new Uint8Array();
604604
this._register(createImageElements(resource, attachment.name, attachment.name, this.element, buffer, this.hoverService, ariaLabel, currentLanguageModelName, clickHandler, this.currentLanguageModel, attachment.omittedState));
605605
}

src/vs/workbench/contrib/chat/browser/chatContentParts/chatAttachmentsContentPart.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { localize } from '../../../../../nls.js';
1414
import { RawContextKey } from '../../../../../platform/contextkey/common/contextkey.js';
1515
import { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js';
1616
import { ResourceLabels } from '../../../../browser/labels.js';
17-
import { IChatRequestVariableEntry, isElementVariableEntry, isImageVariableEntry, isNotebookOutputVariableEntry, isPasteVariableEntry, isSCMHistoryItemVariableEntry } from '../../common/chatModel.js';
17+
import { IChatRequestVariableEntry, isElementVariableEntry, isImageVariableEntry, isNotebookOutputVariableEntry, isPasteVariableEntry, isSCMHistoryItemVariableEntry, OmittedState } from '../../common/chatModel.js';
1818
import { ChatResponseReferencePartStatusKind, IChatContentReference } from '../../common/chatService.js';
1919
import { DefaultChatAttachmentWidget, ElementChatAttachmentWidget, FileAttachmentWidget, ImageAttachmentWidget, NotebookCellOutputChatAttachmentWidget, PasteAttachmentWidget, SCMHistoryItemAttachmentWidget, ToolSetOrToolItemAttachmentWidget } from '../chatAttachmentWidgets.js';
2020

@@ -53,13 +53,16 @@ export class ChatAttachmentsContentPart extends Disposable {
5353
const resource = URI.isUri(attachment.value) ? attachment.value : attachment.value && typeof attachment.value === 'object' && 'uri' in attachment.value && URI.isUri(attachment.value.uri) ? attachment.value.uri : undefined;
5454
const range = attachment.value && typeof attachment.value === 'object' && 'range' in attachment.value && Range.isIRange(attachment.value.range) ? attachment.value.range : undefined;
5555
const correspondingContentReference = this.contentReferences.find((ref) => (typeof ref.reference === 'object' && 'variableName' in ref.reference && ref.reference.variableName === attachment.name) || (URI.isUri(ref.reference) && basename(ref.reference.path) === attachment.name));
56+
const isAttachmentOmitted = correspondingContentReference?.options?.status?.kind === ChatResponseReferencePartStatusKind.Omitted;
57+
const isAttachmentPartialOrOmitted = isAttachmentOmitted || correspondingContentReference?.options?.status?.kind === ChatResponseReferencePartStatusKind.Partial;
5658

5759
let widget;
5860
if (attachment.kind === 'tool' || attachment.kind === 'toolset') {
5961
widget = this.instantiationService.createInstance(ToolSetOrToolItemAttachmentWidget, attachment, undefined, { shouldFocusClearButton: false, supportsDeletion: false }, container, this._contextResourceLabels, hoverDelegate);
6062
} else if (isElementVariableEntry(attachment)) {
6163
widget = this.instantiationService.createInstance(ElementChatAttachmentWidget, attachment, undefined, { shouldFocusClearButton: false, supportsDeletion: false }, container, this._contextResourceLabels, hoverDelegate);
6264
} else if (isImageVariableEntry(attachment)) {
65+
attachment.omittedState = isAttachmentPartialOrOmitted ? OmittedState.Full : attachment.omittedState;
6366
widget = this.instantiationService.createInstance(ImageAttachmentWidget, resource, attachment, undefined, { shouldFocusClearButton: false, supportsDeletion: false }, container, this._contextResourceLabels, hoverDelegate);
6467
} else if (resource && (attachment.kind === 'file' || attachment.kind === 'directory')) {
6568
widget = this.instantiationService.createInstance(FileAttachmentWidget, resource, range, attachment, correspondingContentReference, undefined, { shouldFocusClearButton: false, supportsDeletion: false }, container, this._contextResourceLabels, hoverDelegate);
@@ -73,9 +76,6 @@ export class ChatAttachmentsContentPart extends Disposable {
7376
widget = this.instantiationService.createInstance(DefaultChatAttachmentWidget, resource, range, attachment, correspondingContentReference, undefined, { shouldFocusClearButton: false, supportsDeletion: false }, container, this._contextResourceLabels, hoverDelegate);
7477
}
7578

76-
const isAttachmentOmitted = correspondingContentReference?.options?.status?.kind === ChatResponseReferencePartStatusKind.Omitted;
77-
const isAttachmentPartialOrOmitted = isAttachmentOmitted || correspondingContentReference?.options?.status?.kind === ChatResponseReferencePartStatusKind.Partial;
78-
7979
let ariaLabel: string | null = null;
8080

8181
if (isAttachmentPartialOrOmitted) {

0 commit comments

Comments
 (0)