@@ -447,6 +447,17 @@ export class ChatController {
447
447
description : i18n ( 'AWS.amazonq.context.files.description' ) ,
448
448
icon : 'file' as MynahIconsType ,
449
449
} ,
450
+ {
451
+ command : i18n ( 'AWS.amazonq.context.code.title' ) ,
452
+ children : [
453
+ {
454
+ groupName : i18n ( 'AWS.amazonq.context.code.title' ) ,
455
+ commands : [ ] ,
456
+ } ,
457
+ ] ,
458
+ description : i18n ( 'AWS.amazonq.context.code.description' ) ,
459
+ icon : 'code-block' as MynahIconsType ,
460
+ } ,
450
461
{
451
462
command : i18n ( 'AWS.amazonq.context.prompts.title' ) ,
452
463
children : [
@@ -471,7 +482,8 @@ export class ChatController {
471
482
commands : [ { command : commandName , description : commandDescription } ] ,
472
483
} )
473
484
}
474
- const promptsCmd : QuickActionCommand = contextCommand [ 0 ] . commands ?. [ 3 ]
485
+ const symbolsCmd : QuickActionCommand = contextCommand [ 0 ] . commands ?. [ 3 ]
486
+ const promptsCmd : QuickActionCommand = contextCommand [ 0 ] . commands ?. [ 4 ]
475
487
476
488
// Check for user prompts
477
489
try {
@@ -514,22 +526,40 @@ export class ChatController {
514
526
command : path . basename ( contextCommandItem . relativePath ) ,
515
527
description : path . join ( wsFolderName , contextCommandItem . relativePath ) ,
516
528
route : [ contextCommandItem . workspaceFolder , contextCommandItem . relativePath ] ,
517
- id : 'file' ,
529
+ label : 'file' as ContextCommandItemType ,
530
+ id : contextCommandItem . id ,
518
531
icon : 'file' as MynahIconsType ,
519
532
} )
520
- } else {
533
+ } else if ( contextCommandItem . type === 'folder' ) {
521
534
folderCmd . children ?. [ 0 ] . commands . push ( {
522
535
command : path . basename ( contextCommandItem . relativePath ) ,
523
536
description : path . join ( wsFolderName , contextCommandItem . relativePath ) ,
524
537
route : [ contextCommandItem . workspaceFolder , contextCommandItem . relativePath ] ,
525
- id : 'folder' ,
538
+ label : 'folder' as ContextCommandItemType ,
539
+ id : contextCommandItem . id ,
526
540
icon : 'folder' as MynahIconsType ,
527
541
} )
528
542
}
543
+ // TODO: Remove the limit of 25k once the performance issue of mynahUI in webview is fixed.
544
+ else if (
545
+ contextCommandItem . symbol &&
546
+ symbolsCmd . children &&
547
+ symbolsCmd . children [ 0 ] . commands . length < 25_000
548
+ ) {
549
+ symbolsCmd . children ?. [ 0 ] . commands . push ( {
550
+ command : contextCommandItem . symbol . name ,
551
+ description : `${ contextCommandItem . symbol . kind } , ${ path . join ( wsFolderName , contextCommandItem . relativePath ) } , L${ contextCommandItem . symbol . range . start . line } -${ contextCommandItem . symbol . range . end . line } ` ,
552
+ route : [ contextCommandItem . workspaceFolder , contextCommandItem . relativePath ] ,
553
+ label : 'code' as ContextCommandItemType ,
554
+ id : contextCommandItem . id ,
555
+ icon : 'code-block' as MynahIconsType ,
556
+ } )
557
+ }
529
558
}
530
559
}
531
560
532
561
this . messenger . sendContextCommandData ( contextCommand )
562
+ void LspController . instance . updateContextCommandSymbolsOnce ( )
533
563
}
534
564
535
565
private handlePromptCreate ( tabID : string ) {
@@ -951,13 +981,13 @@ export class ChatController {
951
981
}
952
982
triggerPayload . workspaceRulesCount = workspaceRules . length
953
983
954
- // Add context commands added by user to context
955
984
for ( const context of triggerPayload . context ) {
956
985
if ( typeof context !== 'string' && context . route && context . route . length === 2 ) {
957
986
contextCommands . push ( {
958
987
workspaceFolder : context . route [ 0 ] || '' ,
959
- type : context . icon === 'folder' ? 'folder' : 'file' ,
988
+ type : ( context . label || '' ) as ContextCommandItemType ,
960
989
relativePath : context . route [ 1 ] || '' ,
990
+ id : context . id ,
961
991
} )
962
992
}
963
993
}
@@ -972,11 +1002,7 @@ export class ChatController {
972
1002
workspaceFolders . sort ( )
973
1003
const workspaceFolder = workspaceFolders [ 0 ]
974
1004
for ( const contextCommand of contextCommands ) {
975
- const relativePath = path . relative (
976
- workspaceFolder ,
977
- path . join ( contextCommand . workspaceFolder , contextCommand . relativePath )
978
- )
979
- session . relativePathToWorkspaceRoot . set ( relativePath , contextCommand . workspaceFolder )
1005
+ session . relativePathToWorkspaceRoot . set ( contextCommand . workspaceFolder , contextCommand . workspaceFolder )
980
1006
}
981
1007
let prompts : AdditionalContextPrompt [ ] = [ ]
982
1008
try {
@@ -1006,6 +1032,8 @@ export class ChatController {
1006
1032
innerContext : prompt . content . substring ( 0 , additionalContentInnerContextLimit ) ,
1007
1033
type : contextType ,
1008
1034
relativePath : relativePath ,
1035
+ startLine : prompt . startLine ,
1036
+ endLine : prompt . endLine ,
1009
1037
}
1010
1038
1011
1039
triggerPayload . additionalContents . push ( entry )
@@ -1094,7 +1122,10 @@ export class ChatController {
1094
1122
if ( ! relativePathsOfMergedRelevantDocuments . includes ( relativePath ) && ! seen . includes ( relativePath ) ) {
1095
1123
triggerPayload . documentReferences . push ( {
1096
1124
relativeFilePath : relativePath ,
1097
- lineRanges : [ { first : - 1 , second : - 1 } ] ,
1125
+ lineRanges :
1126
+ additionalContent . name === 'symbol'
1127
+ ? [ { first : additionalContent . startLine , second : additionalContent . endLine } ]
1128
+ : [ { first : - 1 , second : - 1 } ] ,
1098
1129
} )
1099
1130
seen . push ( relativePath )
1100
1131
}
0 commit comments