@@ -715,23 +715,13 @@ class SessionsViewPane extends ViewPane {
715
715
}
716
716
}
717
717
718
- private async getProviderDisplayName ( ) : Promise < string > {
719
- // For local provider, return default name
720
- if ( this . provider . chatSessionType === 'local' ) {
721
- return 'Local' ;
718
+ private getProviderDisplayName ( ) : string {
719
+ const contributions = this . chatSessionsService . getChatSessionContributions ( ) ;
720
+ const contribution = contributions . find ( c => c . type === this . provider . chatSessionType ) ;
721
+ if ( contribution ) {
722
+ return contribution . displayName ;
722
723
}
723
-
724
- // For other providers, try to get a friendly name from the extension contributions
725
- try {
726
- const contributions = await this . chatSessionsService . getChatSessionContributions ( ) ;
727
- const contribution = contributions . find ( c => c . type === this . provider . chatSessionType ) ;
728
- if ( contribution ) {
729
- return contribution . displayName ;
730
- }
731
- } catch ( error ) {
732
- // Fall back to the provider type if we can't get the display name
733
- }
734
- return this . provider . chatSessionType ;
724
+ return '' ;
735
725
}
736
726
737
727
private showEmptyMessage ( ) : void {
@@ -745,30 +735,29 @@ class SessionsViewPane extends ViewPane {
745
735
return ;
746
736
}
747
737
748
- this . getProviderDisplayName ( ) . then ( providerName => {
749
- if ( ! this . messageElement ) {
750
- return ;
751
- }
738
+ const providerName = this . getProviderDisplayName ( ) ;
739
+ if ( ! providerName ) {
740
+ return ;
741
+ }
752
742
753
- const messageText = nls . localize ( 'chatSessions.noResults' , "No sessions found from {0}" , providerName ) ;
743
+ const messageText = nls . localize ( 'chatSessions.noResults' , "No sessions found from {0}" , providerName ) ;
754
744
755
- // Clear the message element using DOM utility
756
- clearNode ( this . messageElement ) ;
745
+ // Clear the message element using DOM utility
746
+ clearNode ( this . messageElement ) ;
757
747
758
- const messageContainer = append ( this . messageElement , $ ( '.no-sessions-message' ) ) ;
748
+ const messageContainer = append ( this . messageElement , $ ( '.no-sessions-message' ) ) ;
759
749
760
- append ( messageContainer , $ ( '.codicon.codicon-info' ) ) ;
761
- const textElement = append ( messageContainer , $ ( 'span' ) ) ;
762
- textElement . textContent = messageText ;
750
+ append ( messageContainer , $ ( '.codicon.codicon-info' ) ) ;
751
+ const textElement = append ( messageContainer , $ ( 'span' ) ) ;
752
+ textElement . textContent = messageText ;
763
753
764
- // Show the message element
765
- this . messageElement . style . display = 'block' ;
754
+ // Show the message element
755
+ this . messageElement . style . display = 'block' ;
766
756
767
- // Hide the tree
768
- if ( this . treeContainer ) {
769
- this . treeContainer . style . display = 'none' ;
770
- }
771
- } ) ;
757
+ // Hide the tree
758
+ if ( this . treeContainer ) {
759
+ this . treeContainer . style . display = 'none' ;
760
+ }
772
761
}
773
762
774
763
private hideMessage ( ) : void {
@@ -782,6 +771,28 @@ class SessionsViewPane extends ViewPane {
782
771
}
783
772
}
784
773
774
+ /**
775
+ * Updates the empty state message based on current tree data.
776
+ * Uses the tree's existing data to avoid redundant provider calls.
777
+ */
778
+ private updateEmptyStateMessage ( ) : void {
779
+ try {
780
+ // Check if the tree has the provider node and get its children count
781
+ if ( this . tree ?. hasNode ( this . provider ) ) {
782
+ const providerNode = this . tree . getNode ( this . provider ) ;
783
+ const childCount = providerNode . children ?. length || 0 ;
784
+
785
+ if ( childCount === 0 ) {
786
+ this . showEmptyMessage ( ) ;
787
+ } else {
788
+ this . hideMessage ( ) ;
789
+ }
790
+ }
791
+ } catch ( error ) {
792
+ this . logService . error ( 'Error checking tree data for empty state:' , error ) ;
793
+ }
794
+ }
795
+
785
796
/**
786
797
* Refreshes the tree data with progress indication.
787
798
* Shows a progress indicator while the tree updates its children from the provider.
@@ -799,23 +810,11 @@ class SessionsViewPane extends ViewPane {
799
810
} ,
800
811
async ( ) => {
801
812
await this . tree ! . updateChildren ( this . provider ) ;
802
-
803
- // Check if we have any items and show/hide message accordingly
804
- try {
805
- const items = await this . provider . provideChatSessionItems ( CancellationToken . None ) ;
806
- if ( items . length === 0 ) {
807
- this . showEmptyMessage ( ) ;
808
- } else {
809
- this . hideMessage ( ) ;
810
- }
811
- } catch ( error ) {
812
- // On error, also show the empty message for non-local providers
813
- if ( this . provider . chatSessionType !== 'local' ) {
814
- this . showEmptyMessage ( ) ;
815
- }
816
- }
817
813
}
818
814
) ;
815
+
816
+ // Check for empty state after refresh using tree data
817
+ this . updateEmptyStateMessage ( ) ;
819
818
} catch ( error ) {
820
819
// Log error but don't throw to avoid breaking the UI
821
820
this . logService . error ( 'Error refreshing chat sessions tree:' , error ) ;
@@ -839,23 +838,11 @@ class SessionsViewPane extends ViewPane {
839
838
} ,
840
839
async ( ) => {
841
840
await this . tree ! . setInput ( this . provider ) ;
842
-
843
- // Check if we have any items and show/hide message accordingly
844
- try {
845
- const items = await this . provider . provideChatSessionItems ( CancellationToken . None ) ;
846
- if ( items . length === 0 ) {
847
- this . showEmptyMessage ( ) ;
848
- } else {
849
- this . hideMessage ( ) ;
850
- }
851
- } catch ( error ) {
852
- // On error, also show the empty message for non-local providers
853
- if ( this . provider . chatSessionType !== 'local' ) {
854
- this . showEmptyMessage ( ) ;
855
- }
856
- }
857
841
}
858
842
) ;
843
+
844
+ // Check for empty state after loading using tree data
845
+ this . updateEmptyStateMessage ( ) ;
859
846
} catch ( error ) {
860
847
// Log error but don't throw to avoid breaking the UI
861
848
this . logService . error ( 'Error loading chat sessions data:' , error ) ;
0 commit comments