@@ -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,73 @@ class SessionsViewPane extends ViewPane {
713
715
}
714
716
}
715
717
718
+ private async getProviderDisplayName ( ) : Promise < string > {
719
+ // For local provider, return default name
720
+ if ( this . provider . chatSessionType === 'local' ) {
721
+ return 'Local' ;
722
+ }
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 ;
735
+ }
736
+
737
+ private showEmptyMessage ( ) : void {
738
+ if ( ! this . messageElement ) {
739
+ return ;
740
+ }
741
+
742
+ // Only show message for non-local providers
743
+ if ( this . provider . chatSessionType === 'local' ) {
744
+ this . hideMessage ( ) ;
745
+ return ;
746
+ }
747
+
748
+ this . getProviderDisplayName ( ) . then ( providerName => {
749
+ if ( ! this . messageElement ) {
750
+ return ;
751
+ }
752
+
753
+ const messageText = nls . localize ( 'chatSessions.noResults' , "No sessions found from {0}" , providerName ) ;
754
+
755
+ // Clear the message element using DOM utility
756
+ clearNode ( this . messageElement ) ;
757
+
758
+ const messageContainer = append ( this . messageElement , $ ( '.no-sessions-message' ) ) ;
759
+
760
+ append ( messageContainer , $ ( '.codicon.codicon-info' ) ) ;
761
+ const textElement = append ( messageContainer , $ ( 'span' ) ) ;
762
+ textElement . textContent = messageText ;
763
+
764
+ // Show the message element
765
+ this . messageElement . style . display = 'block' ;
766
+
767
+ // Hide the tree
768
+ if ( this . treeContainer ) {
769
+ this . treeContainer . style . display = 'none' ;
770
+ }
771
+ } ) ;
772
+ }
773
+
774
+ private hideMessage ( ) : void {
775
+ if ( this . messageElement ) {
776
+ this . messageElement . style . display = 'none' ;
777
+ }
778
+
779
+ // Show the tree
780
+ if ( this . treeContainer ) {
781
+ this . treeContainer . style . display = 'block' ;
782
+ }
783
+ }
784
+
716
785
/**
717
786
* Refreshes the tree data with progress indication.
718
787
* Shows a progress indicator while the tree updates its children from the provider.
@@ -730,6 +799,21 @@ class SessionsViewPane extends ViewPane {
730
799
} ,
731
800
async ( ) => {
732
801
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
+ }
733
817
}
734
818
) ;
735
819
} catch ( error ) {
@@ -755,6 +839,21 @@ class SessionsViewPane extends ViewPane {
755
839
} ,
756
840
async ( ) => {
757
841
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
+ }
758
857
}
759
858
) ;
760
859
} catch ( error ) {
@@ -766,6 +865,10 @@ class SessionsViewPane extends ViewPane {
766
865
protected override renderBody ( container : HTMLElement ) : void {
767
866
super . renderBody ( container ) ;
768
867
868
+ // Create message element for empty state
869
+ this . messageElement = append ( container , $ ( '.chat-sessions-message' ) ) ;
870
+ this . messageElement . style . display = 'none' ;
871
+
769
872
this . treeContainer = append ( container , $ ( '.chat-sessions-tree.show-file-icons' ) ) ;
770
873
this . treeContainer . classList . add ( 'file-icon-themable-tree' ) ;
771
874
@@ -807,6 +910,7 @@ class SessionsViewPane extends ViewPane {
807
910
// Handle double-click and keyboard selection to open editors
808
911
this . _register ( this . tree . onDidOpen ( async e => {
809
912
const element = e . element as IChatSessionItem & { provider : IChatSessionItemProvider } ;
913
+
810
914
if ( element && this . isLocalChatSessionItem ( element ) ) {
811
915
if ( element . sessionType === 'editor' && element . editor && element . group ) {
812
916
// Open the chat editor
0 commit comments