@@ -45,7 +45,10 @@ export class EnvManagerTreeItem implements EnvTreeItem {
4545export class PythonGroupEnvTreeItem implements EnvTreeItem {
4646 public readonly kind = EnvTreeItemKind . environmentGroup ;
4747 public readonly treeItem : TreeItem ;
48- constructor ( public readonly parent : EnvManagerTreeItem , public readonly group : string | EnvironmentGroupInfo ) {
48+ constructor (
49+ public readonly parent : EnvManagerTreeItem ,
50+ public readonly group : string | EnvironmentGroupInfo ,
51+ ) {
4952 const label = typeof group === 'string' ? group : group . name ;
5053 const item = new TreeItem ( label , TreeItemCollapsibleState . Collapsed ) ;
5154 item . contextValue = `pythonEnvGroup;${ this . parent . manager . id } :${ label } ;` ;
@@ -69,6 +72,8 @@ export class PythonEnvTreeItem implements EnvTreeItem {
6972 ) {
7073 let name = environment . displayName ?? environment . name ;
7174 let tooltip = environment . tooltip ?? environment . description ;
75+ const isBroken = ! ! environment . error ;
76+
7277 if ( selected ) {
7378 const selectedTooltip =
7479 selected === 'global' ? EnvViewStrings . selectedGlobalTooltip : EnvViewStrings . selectedWorkspaceTooltip ;
@@ -77,21 +82,25 @@ export class PythonEnvTreeItem implements EnvTreeItem {
7782
7883 const item = new TreeItem ( name , TreeItemCollapsibleState . Collapsed ) ;
7984 item . contextValue = this . getContextValue ( ) ;
80- item . description = environment . description ;
81- item . tooltip = tooltip ;
82- item . iconPath = environment . iconPath ;
85+ // Show error message for broken environments
86+ item . description = isBroken ? environment . error : environment . description ;
87+ item . tooltip = isBroken ? environment . error : tooltip ;
88+ // Show warning icon for broken environments
89+ item . iconPath = isBroken ? new ThemeIcon ( 'warning' ) : environment . iconPath ;
8390 this . treeItem = item ;
8491 }
8592
8693 private getContextValue ( ) {
87- const activatable = isActivatableEnvironment ( this . environment ) ? 'activatable' : '' ;
94+ const isBroken = ! ! this . environment . error ;
95+ const activatable = ! isBroken && isActivatableEnvironment ( this . environment ) ? 'activatable' : '' ;
96+ const broken = isBroken ? 'broken' : '' ;
8897 let remove = '' ;
8998 if ( this . parent . kind === EnvTreeItemKind . environmentGroup ) {
9099 remove = this . parent . parent . manager . supportsRemove ? 'remove' : '' ;
91100 } else if ( this . parent . kind === EnvTreeItemKind . manager ) {
92101 remove = this . parent . manager . supportsRemove ? 'remove' : '' ;
93102 }
94- const parts = [ 'pythonEnvironment' , remove , activatable ] . filter ( Boolean ) ;
103+ const parts = [ 'pythonEnvironment' , remove , activatable , broken ] . filter ( Boolean ) ;
95104 return parts . join ( ';' ) + ';' ;
96105 }
97106}
@@ -240,16 +249,22 @@ export class ProjectEnvironment implements ProjectTreeItem {
240249 public readonly kind = ProjectTreeItemKind . environment ;
241250 public readonly id : string ;
242251 public readonly treeItem : TreeItem ;
243- constructor ( public readonly parent : ProjectItem , public readonly environment : PythonEnvironment ) {
252+ constructor (
253+ public readonly parent : ProjectItem ,
254+ public readonly environment : PythonEnvironment ,
255+ ) {
244256 this . id = this . getId ( parent , environment ) ;
257+ const isBroken = ! ! environment . error ;
245258 const item = new TreeItem (
246259 this . environment . displayName ?? this . environment . name ,
247260 TreeItemCollapsibleState . Collapsed ,
248261 ) ;
249- item . contextValue = 'python-env' ;
250- item . description = this . environment . description ;
251- item . tooltip = this . environment . tooltip ;
252- item . iconPath = this . environment . iconPath ;
262+ item . contextValue = isBroken ? 'python-env;broken;' : 'python-env' ;
263+ // Show error message for broken environments
264+ item . description = isBroken ? this . environment . error : this . environment . description ;
265+ item . tooltip = isBroken ? this . environment . error : this . environment . tooltip ;
266+ // Show warning icon for broken environments
267+ item . iconPath = isBroken ? new ThemeIcon ( 'warning' ) : this . environment . iconPath ;
253268 this . treeItem = item ;
254269 }
255270
0 commit comments