@@ -34,7 +34,7 @@ import { FuzzyScore } from '../../../../base/common/filters.js';
34
34
import { ResourceLabels , IResourceLabel } from '../../../browser/labels.js' ;
35
35
import { ActionBar } from '../../../../base/browser/ui/actionbar/actionbar.js' ;
36
36
import { Disposable } from '../../../../base/common/lifecycle.js' ;
37
- import { append , $ , getActiveWindow } from '../../../../base/browser/dom.js' ;
37
+ import { append , $ , getActiveWindow , clearNode } from '../../../../base/browser/dom.js' ;
38
38
import { URI } from '../../../../base/common/uri.js' ;
39
39
import { IEditorGroupsService , IEditorGroup } from '../../../services/editor/common/editorGroupsService.js' ;
40
40
import { GroupModelChangeKind } from '../../../common/editor.js' ;
@@ -673,6 +673,7 @@ class SessionsViewPane extends ViewPane {
673
673
private treeContainer ?: HTMLElement ;
674
674
private dataSource ?: SessionsDataSource ;
675
675
private labels ?: ResourceLabels ;
676
+ private messageElement ?: HTMLElement ;
676
677
677
678
constructor (
678
679
private readonly provider : IChatSessionItemProvider ,
@@ -690,6 +691,7 @@ class SessionsViewPane extends ViewPane {
690
691
@IViewsService private readonly viewsService : IViewsService ,
691
692
@ILogService private readonly logService : ILogService ,
692
693
@IProgressService private readonly progressService : IProgressService ,
694
+ @IChatSessionsService private readonly chatSessionsService : IChatSessionsService ,
693
695
) {
694
696
super ( options , keybindingService , contextMenuService , configurationService , contextKeyService , viewDescriptorService , instantiationService , openerService , themeService , hoverService ) ;
695
697
@@ -713,6 +715,84 @@ class SessionsViewPane extends ViewPane {
713
715
}
714
716
}
715
717
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 ;
723
+ }
724
+ return '' ;
725
+ }
726
+
727
+ private showEmptyMessage ( ) : void {
728
+ if ( ! this . messageElement ) {
729
+ return ;
730
+ }
731
+
732
+ // Only show message for non-local providers
733
+ if ( this . provider . chatSessionType === 'local' ) {
734
+ this . hideMessage ( ) ;
735
+ return ;
736
+ }
737
+
738
+ const providerName = this . getProviderDisplayName ( ) ;
739
+ if ( ! providerName ) {
740
+ return ;
741
+ }
742
+
743
+ const messageText = nls . localize ( 'chatSessions.noResults' , "No sessions found from {0}" , providerName ) ;
744
+
745
+ // Clear the message element using DOM utility
746
+ clearNode ( this . messageElement ) ;
747
+
748
+ const messageContainer = append ( this . messageElement , $ ( '.no-sessions-message' ) ) ;
749
+
750
+ append ( messageContainer , $ ( '.codicon.codicon-info' ) ) ;
751
+ const textElement = append ( messageContainer , $ ( 'span' ) ) ;
752
+ textElement . textContent = messageText ;
753
+
754
+ // Show the message element
755
+ this . messageElement . style . display = 'block' ;
756
+
757
+ // Hide the tree
758
+ if ( this . treeContainer ) {
759
+ this . treeContainer . style . display = 'none' ;
760
+ }
761
+ }
762
+
763
+ private hideMessage ( ) : void {
764
+ if ( this . messageElement ) {
765
+ this . messageElement . style . display = 'none' ;
766
+ }
767
+
768
+ // Show the tree
769
+ if ( this . treeContainer ) {
770
+ this . treeContainer . style . display = 'block' ;
771
+ }
772
+ }
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
+
716
796
/**
717
797
* Refreshes the tree data with progress indication.
718
798
* Shows a progress indicator while the tree updates its children from the provider.
@@ -732,6 +812,9 @@ class SessionsViewPane extends ViewPane {
732
812
await this . tree ! . updateChildren ( this . provider ) ;
733
813
}
734
814
) ;
815
+
816
+ // Check for empty state after refresh using tree data
817
+ this . updateEmptyStateMessage ( ) ;
735
818
} catch ( error ) {
736
819
// Log error but don't throw to avoid breaking the UI
737
820
this . logService . error ( 'Error refreshing chat sessions tree:' , error ) ;
@@ -757,6 +840,9 @@ class SessionsViewPane extends ViewPane {
757
840
await this . tree ! . setInput ( this . provider ) ;
758
841
}
759
842
) ;
843
+
844
+ // Check for empty state after loading using tree data
845
+ this . updateEmptyStateMessage ( ) ;
760
846
} catch ( error ) {
761
847
// Log error but don't throw to avoid breaking the UI
762
848
this . logService . error ( 'Error loading chat sessions data:' , error ) ;
@@ -766,6 +852,10 @@ class SessionsViewPane extends ViewPane {
766
852
protected override renderBody ( container : HTMLElement ) : void {
767
853
super . renderBody ( container ) ;
768
854
855
+ // Create message element for empty state
856
+ this . messageElement = append ( container , $ ( '.chat-sessions-message' ) ) ;
857
+ this . messageElement . style . display = 'none' ;
858
+
769
859
this . treeContainer = append ( container , $ ( '.chat-sessions-tree.show-file-icons' ) ) ;
770
860
this . treeContainer . classList . add ( 'file-icon-themable-tree' ) ;
771
861
@@ -807,6 +897,7 @@ class SessionsViewPane extends ViewPane {
807
897
// Handle double-click and keyboard selection to open editors
808
898
this . _register ( this . tree . onDidOpen ( async e => {
809
899
const element = e . element as IChatSessionItem & { provider : IChatSessionItemProvider } ;
900
+
810
901
if ( element && this . isLocalChatSessionItem ( element ) ) {
811
902
if ( element . sessionType === 'editor' && element . editor && element . group ) {
812
903
// Open the chat editor
0 commit comments