@@ -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,26 @@ 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' : '' ;
8896 let remove = '' ;
8997 if ( this . parent . kind === EnvTreeItemKind . environmentGroup ) {
9098 remove = this . parent . parent . manager . supportsRemove ? 'remove' : '' ;
9199 } else if ( this . parent . kind === EnvTreeItemKind . manager ) {
92100 remove = this . parent . manager . supportsRemove ? 'remove' : '' ;
93101 }
94- const parts = [ 'pythonEnvironment' , remove , activatable ] . filter ( Boolean ) ;
102+ // Use different base context for broken environments so normal actions don't show
103+ const baseContext = isBroken ? 'pythonBrokenEnvironment' : 'pythonEnvironment' ;
104+ const parts = [ baseContext , remove , activatable ] . filter ( Boolean ) ;
95105 return parts . join ( ';' ) + ';' ;
96106 }
97107}
@@ -240,16 +250,22 @@ export class ProjectEnvironment implements ProjectTreeItem {
240250 public readonly kind = ProjectTreeItemKind . environment ;
241251 public readonly id : string ;
242252 public readonly treeItem : TreeItem ;
243- constructor ( public readonly parent : ProjectItem , public readonly environment : PythonEnvironment ) {
253+ constructor (
254+ public readonly parent : ProjectItem ,
255+ public readonly environment : PythonEnvironment ,
256+ ) {
244257 this . id = this . getId ( parent , environment ) ;
258+ const isBroken = ! ! environment . error ;
245259 const item = new TreeItem (
246260 this . environment . displayName ?? this . environment . name ,
247261 TreeItemCollapsibleState . Collapsed ,
248262 ) ;
249- item . contextValue = 'python-env' ;
250- item . description = this . environment . description ;
251- item . tooltip = this . environment . tooltip ;
252- item . iconPath = this . environment . iconPath ;
263+ item . contextValue = isBroken ? 'python-env;broken;' : 'python-env' ;
264+ // Show error message for broken environments
265+ item . description = isBroken ? this . environment . error : this . environment . description ;
266+ item . tooltip = isBroken ? this . environment . error : this . environment . tooltip ;
267+ // Show warning icon for broken environments
268+ item . iconPath = isBroken ? new ThemeIcon ( 'warning' ) : this . environment . iconPath ;
253269 this . treeItem = item ;
254270 }
255271
0 commit comments