@@ -25,6 +25,7 @@ import { ResourceMap } from 'vs/base/common/map';
25
25
import { FileAccess , Schemas , matchesSomeScheme } from 'vs/base/common/network' ;
26
26
import { clamp } from 'vs/base/common/numbers' ;
27
27
import { basename } from 'vs/base/common/path' ;
28
+ import { basenameOrAuthority , dirname } from 'vs/base/common/resources' ;
28
29
import { equalsIgnoreCase } from 'vs/base/common/strings' ;
29
30
import { ThemeIcon } from 'vs/base/common/themables' ;
30
31
import { URI } from 'vs/base/common/uri' ;
@@ -41,6 +42,7 @@ import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
41
42
import { FileKind , FileType } from 'vs/platform/files/common/files' ;
42
43
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
43
44
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection' ;
45
+ import { ILabelService } from 'vs/platform/label/common/label' ;
44
46
import { WorkbenchCompressibleAsyncDataTree , WorkbenchList } from 'vs/platform/list/browser/listService' ;
45
47
import { ILogService } from 'vs/platform/log/common/log' ;
46
48
import { IOpenerService } from 'vs/platform/opener/common/opener' ;
@@ -58,6 +60,7 @@ import { CONTEXT_CHAT_RESPONSE_SUPPORT_ISSUE_REPORTING, CONTEXT_REQUEST, CONTEXT
58
60
import { IChatProgressRenderableResponseContent } from 'vs/workbench/contrib/chat/common/chatModel' ;
59
61
import { chatAgentLeader , chatSubcommandLeader } from 'vs/workbench/contrib/chat/common/chatParserTypes' ;
60
62
import { IChatCommandButton , IChatContentReference , IChatFollowup , IChatProgressMessage , IChatResponseProgressFileTreeData , InteractiveSessionVoteDirection } from 'vs/workbench/contrib/chat/common/chatService' ;
63
+ import { IChatVariablesService } from 'vs/workbench/contrib/chat/common/chatVariables' ;
61
64
import { IChatProgressMessageRenderData , IChatRenderData , IChatResponseMarkdownRenderData , IChatResponseViewModel , IChatWelcomeMessageViewModel , isRequestVM , isResponseVM , isWelcomeVM } from 'vs/workbench/contrib/chat/common/chatViewModel' ;
62
65
import { IWordCountResult , getNWords } from 'vs/workbench/contrib/chat/common/chatWordCounter' ;
63
66
import { createFileIconThemableTreeContainerScope } from 'vs/workbench/contrib/files/browser/views/explorerView' ;
@@ -800,17 +803,22 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
800
803
801
804
listDisposables . add ( list . onDidOpen ( ( e ) => {
802
805
if ( e . element ) {
803
- this . openerService . open (
804
- 'uri' in e . element . reference ? e . element . reference . uri : e . element . reference ,
805
- {
806
- fromUserGesture : true ,
807
- editorOptions : {
808
- ...e . editorOptions ,
809
- ...{
810
- selection : 'range' in e . element . reference ? e . element . reference . range : undefined
806
+ const uriOrLocation = 'variableName' in e . element . reference ? e . element . reference . value : e . element . reference ;
807
+ const uri = URI . isUri ( uriOrLocation ) ? uriOrLocation :
808
+ uriOrLocation ?. uri ;
809
+ if ( uri ) {
810
+ this . openerService . open (
811
+ uri ,
812
+ {
813
+ fromUserGesture : true ,
814
+ editorOptions : {
815
+ ...e . editorOptions ,
816
+ ...{
817
+ selection : 'range' in e . element . reference ? e . element . reference . range : undefined
818
+ }
811
819
}
812
- }
813
- } ) ;
820
+ } ) ;
821
+ }
814
822
}
815
823
} ) ) ;
816
824
listDisposables . add ( list . onContextMenu ( ( e ) => {
@@ -1163,10 +1171,13 @@ class ContentReferencesListPool extends Disposable {
1163
1171
alwaysConsumeMouseWheel : false ,
1164
1172
accessibilityProvider : {
1165
1173
getAriaLabel : ( element : IChatContentReference ) => {
1166
- if ( URI . isUri ( element . reference ) ) {
1167
- return basename ( element . reference . path ) ;
1174
+ const reference = element . reference ;
1175
+ if ( 'variableName' in reference ) {
1176
+ return reference . variableName ;
1177
+ } else if ( URI . isUri ( reference ) ) {
1178
+ return basename ( reference . path ) ;
1168
1179
} else {
1169
- return basename ( element . reference . uri . path ) ;
1180
+ return basename ( reference . uri . path ) ;
1170
1181
}
1171
1182
} ,
1172
1183
@@ -1212,6 +1223,8 @@ class ContentReferencesListRenderer implements IListRenderer<IChatContentReferen
1212
1223
1213
1224
constructor (
1214
1225
private labels : ResourceLabels ,
1226
+ @ILabelService private readonly labelService : ILabelService ,
1227
+ @IChatVariablesService private readonly chatVariablesService : IChatVariablesService ,
1215
1228
) { }
1216
1229
1217
1230
renderTemplate ( container : HTMLElement ) : IChatContentReferenceListTemplate {
@@ -1220,18 +1233,30 @@ class ContentReferencesListRenderer implements IListRenderer<IChatContentReferen
1220
1233
return { templateDisposables, label } ;
1221
1234
}
1222
1235
1223
- renderElement ( element : IChatContentReference , index : number , templateData : IChatContentReferenceListTemplate , height : number | undefined ) : void {
1236
+ renderElement ( data : IChatContentReference , index : number , templateData : IChatContentReferenceListTemplate , height : number | undefined ) : void {
1237
+ const reference = data . reference ;
1224
1238
templateData . label . element . style . display = 'flex' ;
1225
- const uri = 'uri' in element . reference ? element . reference . uri : element . reference ;
1226
- if ( matchesSomeScheme ( uri , Schemas . mailto , Schemas . http , Schemas . https ) ) {
1227
- templateData . label . setResource ( { resource : uri , name : uri . toString ( ) } , { icon : Codicon . globe } ) ;
1239
+ if ( 'variableName' in reference ) {
1240
+ if ( reference . value ) {
1241
+ const uri = URI . isUri ( reference . value ) ? reference . value : reference . value . uri ;
1242
+ const title = this . labelService . getUriLabel ( dirname ( uri ) , { relative : true } ) ;
1243
+ templateData . label . setResource ( { resource : uri , name : basenameOrAuthority ( uri ) , description : `#${ reference . variableName } ` } , { title } ) ;
1244
+ } else {
1245
+ const variable = this . chatVariablesService . getVariable ( reference . variableName ) ;
1246
+ templateData . label . setLabel ( `#${ reference . variableName } ` , undefined , { title : variable ?. description } ) ;
1247
+ }
1228
1248
} else {
1229
- templateData . label . setFile ( uri , {
1230
- fileKind : FileKind . FILE ,
1231
- // Should not have this live-updating data on a historical reference
1232
- fileDecorations : { badges : false , colors : false } ,
1233
- range : 'range' in element . reference ? element . reference . range : undefined
1234
- } ) ;
1249
+ const uri = 'uri' in reference ? reference . uri : reference ;
1250
+ if ( matchesSomeScheme ( uri , Schemas . mailto , Schemas . http , Schemas . https ) ) {
1251
+ templateData . label . setResource ( { resource : uri , name : uri . toString ( ) } , { icon : Codicon . globe } ) ;
1252
+ } else {
1253
+ templateData . label . setFile ( uri , {
1254
+ fileKind : FileKind . FILE ,
1255
+ // Should not have this live-updating data on a historical reference
1256
+ fileDecorations : { badges : false , colors : false } ,
1257
+ range : 'range' in reference ? reference . range : undefined
1258
+ } ) ;
1259
+ }
1235
1260
}
1236
1261
}
1237
1262
0 commit comments