@@ -447,6 +447,17 @@ export class ChatController {
447447 description : i18n ( 'AWS.amazonq.context.files.description' ) ,
448448 icon : 'file' as MynahIconsType ,
449449 } ,
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+ } ,
450461 {
451462 command : i18n ( 'AWS.amazonq.context.prompts.title' ) ,
452463 children : [
@@ -471,7 +482,8 @@ export class ChatController {
471482 commands : [ { command : commandName , description : commandDescription } ] ,
472483 } )
473484 }
474- const promptsCmd : QuickActionCommand = contextCommand [ 0 ] . commands ?. [ 3 ]
485+ const symbolsCmd : QuickActionCommand = contextCommand [ 0 ] . commands ?. [ 3 ]
486+ const promptsCmd : QuickActionCommand = contextCommand [ 0 ] . commands ?. [ 4 ]
475487
476488 // Check for user prompts
477489 try {
@@ -514,22 +526,40 @@ export class ChatController {
514526 command : path . basename ( contextCommandItem . relativePath ) ,
515527 description : path . join ( wsFolderName , contextCommandItem . relativePath ) ,
516528 route : [ contextCommandItem . workspaceFolder , contextCommandItem . relativePath ] ,
517- id : 'file' ,
529+ label : 'file' as ContextCommandItemType ,
530+ id : contextCommandItem . id ,
518531 icon : 'file' as MynahIconsType ,
519532 } )
520- } else {
533+ } else if ( contextCommandItem . type === 'folder' ) {
521534 folderCmd . children ?. [ 0 ] . commands . push ( {
522535 command : path . basename ( contextCommandItem . relativePath ) ,
523536 description : path . join ( wsFolderName , contextCommandItem . relativePath ) ,
524537 route : [ contextCommandItem . workspaceFolder , contextCommandItem . relativePath ] ,
525- id : 'folder' ,
538+ label : 'folder' as ContextCommandItemType ,
539+ id : contextCommandItem . id ,
526540 icon : 'folder' as MynahIconsType ,
527541 } )
528542 }
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+ }
529558 }
530559 }
531560
532561 this . messenger . sendContextCommandData ( contextCommand )
562+ void LspController . instance . updateContextCommandSymbolsOnce ( )
533563 }
534564
535565 private handlePromptCreate ( tabID : string ) {
@@ -951,13 +981,13 @@ export class ChatController {
951981 }
952982 triggerPayload . workspaceRulesCount = workspaceRules . length
953983
954- // Add context commands added by user to context
955984 for ( const context of triggerPayload . context ) {
956985 if ( typeof context !== 'string' && context . route && context . route . length === 2 ) {
957986 contextCommands . push ( {
958987 workspaceFolder : context . route [ 0 ] || '' ,
959- type : context . icon === 'folder' ? 'folder' : 'file' ,
988+ type : ( context . label || '' ) as ContextCommandItemType ,
960989 relativePath : context . route [ 1 ] || '' ,
990+ id : context . id ,
961991 } )
962992 }
963993 }
@@ -972,11 +1002,7 @@ export class ChatController {
9721002 workspaceFolders . sort ( )
9731003 const workspaceFolder = workspaceFolders [ 0 ]
9741004 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 )
9801006 }
9811007 let prompts : AdditionalContextPrompt [ ] = [ ]
9821008 try {
@@ -1006,6 +1032,8 @@ export class ChatController {
10061032 innerContext : prompt . content . substring ( 0 , additionalContentInnerContextLimit ) ,
10071033 type : contextType ,
10081034 relativePath : relativePath ,
1035+ startLine : prompt . startLine ,
1036+ endLine : prompt . endLine ,
10091037 }
10101038
10111039 triggerPayload . additionalContents . push ( entry )
@@ -1094,7 +1122,10 @@ export class ChatController {
10941122 if ( ! relativePathsOfMergedRelevantDocuments . includes ( relativePath ) && ! seen . includes ( relativePath ) ) {
10951123 triggerPayload . documentReferences . push ( {
10961124 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 } ] ,
10981129 } )
10991130 seen . push ( relativePath )
11001131 }
0 commit comments