@@ -25,7 +25,7 @@ import { IOpenerService, OpenInternalOptions } from '../../../../platform/opener
25
25
import { IThemeService , FolderThemeIcon } from '../../../../platform/theme/common/themeService.js' ;
26
26
import { IResourceLabel , ResourceLabels , IFileLabelOptions } from '../../../browser/labels.js' ;
27
27
import { revealInSideBarCommand } from '../../files/browser/fileActions.contribution.js' ;
28
- import { IChatRequestPasteVariableEntry , IChatRequestVariableEntry , IElementVariableEntry , INotebookOutputVariableEntry , ISCMHistoryItemVariableEntry , OmittedState } from '../common/chatModel.js' ;
28
+ import { IChatRequestPasteVariableEntry , IChatRequestToolEntry , IChatRequestToolSetEntry , IChatRequestVariableEntry , IElementVariableEntry , INotebookOutputVariableEntry , ISCMHistoryItemVariableEntry , OmittedState } from '../common/chatModel.js' ;
29
29
import { ILanguageModelChatMetadataAndIdentifier , ILanguageModelsService } from '../common/languageModels.js' ;
30
30
import { chatAttachmentResourceContextKey } from './chatContentParts/chatAttachmentsContentPart.js' ;
31
31
import { KeyCode } from '../../../../base/common/keyCodes.js' ;
@@ -52,6 +52,8 @@ import { ResourceContextKey } from '../../../common/contextkeys.js';
52
52
import { Location , SymbolKind } from '../../../../editor/common/languages.js' ;
53
53
import { IChatContentReference } from '../common/chatService.js' ;
54
54
import { getHistoryItemEditorTitle , getHistoryItemHoverContent } from '../../scm/browser/util.js' ;
55
+ import { ILanguageModelToolsService , ToolSet } from '../common/languageModelToolsService.js' ;
56
+ import { Iterable } from '../../../../base/common/iterator.js' ;
55
57
56
58
abstract class AbstractChatAttachmentWidget extends Disposable {
57
59
public readonly element : HTMLElement ;
@@ -465,6 +467,54 @@ export class DefaultChatAttachmentWidget extends AbstractChatAttachmentWidget {
465
467
}
466
468
}
467
469
470
+ export class ToolSetOrToolItemAttachmentWidget extends AbstractChatAttachmentWidget {
471
+ constructor (
472
+ attachment : IChatRequestToolSetEntry | IChatRequestToolEntry ,
473
+ currentLanguageModel : ILanguageModelChatMetadataAndIdentifier | undefined ,
474
+ options : { shouldFocusClearButton : boolean ; supportsDeletion : boolean } ,
475
+ container : HTMLElement ,
476
+ contextResourceLabels : ResourceLabels ,
477
+ hoverDelegate : IHoverDelegate ,
478
+ @ILanguageModelToolsService toolsService : ILanguageModelToolsService ,
479
+ @ICommandService commandService : ICommandService ,
480
+ @IOpenerService openerService : IOpenerService ,
481
+ @IHoverService hoverService : IHoverService
482
+ ) {
483
+ super ( attachment , options , container , contextResourceLabels , hoverDelegate , currentLanguageModel , commandService , openerService ) ;
484
+
485
+
486
+ const toolOrToolSet = Iterable . find ( toolsService . getTools ( ) , tool => tool . id === attachment . id ) ?? Iterable . find ( toolsService . toolSets . get ( ) , toolSet => toolSet . id === attachment . id ) ;
487
+
488
+ let name = attachment . name ;
489
+ const icon = attachment . icon ?? Codicon . tools ;
490
+
491
+ if ( toolOrToolSet ) {
492
+ name = toolOrToolSet . toolReferenceName ?? name ;
493
+ }
494
+
495
+ this . label . setLabel ( `$(${ icon . id } )\u00A0${ name } ` , undefined ) ;
496
+
497
+ this . element . style . cursor = 'pointer' ;
498
+ this . element . ariaLabel = localize ( 'chat.attachment' , "Attached context, {0}" , name ) ;
499
+
500
+ let hoverContent : string | undefined ;
501
+
502
+ if ( toolOrToolSet instanceof ToolSet ) {
503
+ hoverContent = localize ( 'toolset' , "{0} - {1}" , toolOrToolSet . description ?? toolOrToolSet . displayName , toolOrToolSet . source . label ) ;
504
+ } else if ( toolOrToolSet ) {
505
+ hoverContent = localize ( 'tool' , "{0} - {1}" , toolOrToolSet . userDescription ?? toolOrToolSet . modelDescription , toolOrToolSet . source . label ) ;
506
+ }
507
+
508
+ if ( hoverContent ) {
509
+ this . _register ( hoverService . setupManagedHover ( hoverDelegate , this . element , hoverContent , { trapFocus : true } ) ) ;
510
+ }
511
+
512
+ this . attachClearButton ( ) ;
513
+ }
514
+
515
+
516
+ }
517
+
468
518
export class NotebookCellOutputChatAttachmentWidget extends AbstractChatAttachmentWidget {
469
519
constructor (
470
520
resource : URI ,
0 commit comments