@@ -655,23 +655,37 @@ export class SessionManager implements Middleware {
655655 }
656656
657657 private setSessionStatus ( statusText : string , status : SessionStatus ) : void {
658- // Set color and icon for 'Running' by default
659- let statusIconText = ( semver . gte ( vscode . version , "1.56.0" ) )
660- ? "$(terminal-powershell) "
661- : "$(terminal) " ;
662- let statusColor = "#affc74" ;
663-
664- if ( status === SessionStatus . Initializing ) {
665- statusIconText = "$(sync) " ;
666- statusColor = "#f3fc74" ;
667- } else if ( status === SessionStatus . Failed ) {
668- statusIconText = "$(alert) " ;
669- statusColor = "#fcc174" ;
670- }
671-
672658 this . sessionStatus = status ;
673- this . statusBarItem . color = statusColor ;
674- this . statusBarItem . text = statusIconText + statusText ;
659+ switch ( status ) {
660+ case SessionStatus . Running :
661+ case SessionStatus . NeverStarted :
662+ case SessionStatus . NotStarted :
663+ // This icon is available since 1.56, now our current engine version.
664+ this . statusBarItem . text = "$(terminal-powershell)" ;
665+ // These have to be reset because this function mutates state.
666+ this . statusBarItem . color = undefined ;
667+ this . statusBarItem . backgroundColor = undefined ;
668+ break ;
669+ case SessionStatus . Initializing :
670+ case SessionStatus . Stopping :
671+ this . statusBarItem . text = "$(sync)" ;
672+ // The warning colors were added later than our current engine version.
673+ // https://code.visualstudio.com/api/references/theme-color#status-bar-colors
674+ this . statusBarItem . color = ( semver . gte ( vscode . version , "1.59.0" ) )
675+ ? new vscode . ThemeColor ( "statusBarItem.warningForeground" )
676+ : new vscode . ThemeColor ( "statusBarItem.errorForeground" ) ;
677+ this . statusBarItem . backgroundColor = ( semver . gte ( vscode . version , "1.59.0" ) )
678+ ? new vscode . ThemeColor ( "statusBarItem.warningBackground" )
679+ : new vscode . ThemeColor ( "statusBarItem.errorBackground" ) ;
680+ break ;
681+ case SessionStatus . Failed :
682+ this . statusBarItem . text = "$(alert)" ;
683+ // The error colors have been available since 1.53.
684+ this . statusBarItem . color = new vscode . ThemeColor ( "statusBarItem.errorForeground" ) ;
685+ this . statusBarItem . backgroundColor = new vscode . ThemeColor ( "statusBarItem.errorBackground" ) ;
686+ break ;
687+ }
688+ this . statusBarItem . text += " " + statusText ;
675689 }
676690
677691 private setSessionFailure ( message : string , ...additionalMessages : string [ ] ) {
0 commit comments