@@ -90,7 +90,6 @@ import type { IMenu } from '../../../../platform/actions/common/actions.js';
9090import { IContextMenuService } from '../../../../platform/contextview/browser/contextView.js' ;
9191import { TerminalContribCommandId } from '../terminalContribExports.js' ;
9292import type { IProgressState } from '@xterm/addon-progress' ;
93- import { refreshShellIntegrationInfoStatus } from './terminalTooltip.js' ;
9493import { generateUuid } from '../../../../base/common/uuid.js' ;
9594import { PromptInputState } from '../../../../platform/terminal/common/capabilities/commandDetection/promptInputModel.js' ;
9695import { hasKey , isNumber , isString } from '../../../../base/common/types.js' ;
@@ -465,7 +464,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
465464 capabilityListeners . get ( e . id ) ?. dispose ( ) ;
466465 const refreshInfo = ( ) => {
467466 this . _labelComputer ?. refreshLabel ( this ) ;
468- refreshShellIntegrationInfoStatus ( this ) ;
467+ this . _refreshShellIntegrationInfoStatus ( this ) ;
469468 } ;
470469 switch ( e . id ) {
471470 case TerminalCapability . CwdDetection : {
@@ -499,7 +498,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
499498 }
500499 }
501500 } ) ) ;
502- this . _register ( this . onDidChangeShellType ( ( ) => refreshShellIntegrationInfoStatus ( this ) ) ) ;
501+ this . _register ( this . onDidChangeShellType ( ( ) => this . _refreshShellIntegrationInfoStatus ( this ) ) ) ;
503502 this . _register ( this . capabilities . onDidRemoveCapability ( e => {
504503 capabilityListeners . get ( e . id ) ?. dispose ( ) ;
505504 } ) ) ;
@@ -888,7 +887,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
888887 // Register and update the terminal's shell integration status
889888 this . _register ( Event . runAndSubscribe ( xterm . shellIntegration . onDidChangeSeenSequences , ( ) => {
890889 if ( xterm . shellIntegration . seenSequences . size > 0 ) {
891- refreshShellIntegrationInfoStatus ( this ) ;
890+ this . _refreshShellIntegrationInfoStatus ( this ) ;
892891 }
893892 } ) ) ;
894893
@@ -922,6 +921,54 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
922921 return xterm ;
923922 }
924923
924+ // Debounce this to avoid impacting input latency while typing into the prompt
925+ @debounce ( 500 )
926+ private _refreshShellIntegrationInfoStatus ( instance : ITerminalInstance ) {
927+ if ( ! instance . xterm ) {
928+ return ;
929+ }
930+ const cmdDetectionType = (
931+ instance . capabilities . get ( TerminalCapability . CommandDetection ) ?. hasRichCommandDetection
932+ ? nls . localize ( 'shellIntegration.rich' , 'Rich' )
933+ : instance . capabilities . has ( TerminalCapability . CommandDetection )
934+ ? nls . localize ( 'shellIntegration.basic' , 'Basic' )
935+ : instance . usedShellIntegrationInjection
936+ ? nls . localize ( 'shellIntegration.injectionFailed' , "Injection failed to activate" )
937+ : nls . localize ( 'shellIntegration.no' , 'No' )
938+ ) ;
939+
940+ const detailedAdditions : string [ ] = [ ] ;
941+ if ( instance . shellType ) {
942+ detailedAdditions . push ( `Shell type: \`${ instance . shellType } \`` ) ;
943+ }
944+ const cwd = instance . cwd ;
945+ if ( cwd ) {
946+ detailedAdditions . push ( `Current working directory: \`${ cwd } \`` ) ;
947+ }
948+ const seenSequences = Array . from ( instance . xterm . shellIntegration . seenSequences ) ;
949+ if ( seenSequences . length > 0 ) {
950+ detailedAdditions . push ( `Seen sequences: ${ seenSequences . map ( e => `\`${ e } \`` ) . join ( ', ' ) } ` ) ;
951+ }
952+ const promptType = instance . capabilities . get ( TerminalCapability . PromptTypeDetection ) ?. promptType ;
953+ if ( promptType ) {
954+ detailedAdditions . push ( `Prompt type: \`${ promptType } \`` ) ;
955+ }
956+ const combinedString = instance . capabilities . get ( TerminalCapability . CommandDetection ) ?. promptInputModel . getCombinedString ( ) ;
957+ if ( combinedString !== undefined ) {
958+ detailedAdditions . push ( `Prompt input: \`\`\`${ combinedString } \`\`\`` ) ;
959+ }
960+ const detailedAdditionsString = detailedAdditions . length > 0
961+ ? '\n\n' + detailedAdditions . map ( e => `- ${ e } ` ) . join ( '\n' )
962+ : '' ;
963+
964+ instance . statusList . add ( {
965+ id : TerminalStatus . ShellIntegrationInfo ,
966+ severity : Severity . Info ,
967+ tooltip : `${ nls . localize ( 'shellIntegration' , "Shell integration" ) } : ${ cmdDetectionType } ` ,
968+ detailedTooltip : `${ nls . localize ( 'shellIntegration' , "Shell integration" ) } : ${ cmdDetectionType } ${ detailedAdditionsString } `
969+ } ) ;
970+ }
971+
925972 async runCommand ( commandLine : string , shouldExecute : boolean , commandId ?: string ) : Promise < void > {
926973 let commandDetection = this . capabilities . get ( TerminalCapability . CommandDetection ) ;
927974 const siInjectionEnabled = this . _configurationService . getValue ( TerminalSettingId . ShellIntegrationEnabled ) === true ;
0 commit comments