@@ -10,6 +10,7 @@ import { IContextMenuService } from '../../../../platform/contextview/browser/co
10
10
import { SyncDescriptor } from '../../../../platform/instantiation/common/descriptors.js' ;
11
11
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js' ;
12
12
import { ILogService } from '../../../../platform/log/common/log.js' ;
13
+ import { IProgressService } from '../../../../platform/progress/common/progress.js' ;
13
14
import { Registry } from '../../../../platform/registry/common/platform.js' ;
14
15
import { IStorageService } from '../../../../platform/storage/common/storage.js' ;
15
16
import { ITelemetryService } from '../../../../platform/telemetry/common/telemetry.js' ;
@@ -552,7 +553,8 @@ class SessionsRenderer extends Disposable implements ITreeRenderer<IChatSessionI
552
553
553
554
constructor (
554
555
private readonly labels : ResourceLabels ,
555
- @IThemeService private readonly themeService : IThemeService
556
+ @IThemeService private readonly themeService : IThemeService ,
557
+ @ILogService private readonly logService : ILogService ,
556
558
) {
557
559
super ( ) ;
558
560
@@ -600,7 +602,7 @@ class SessionsRenderer extends Disposable implements ITreeRenderer<IChatSessionI
600
602
601
603
this . appliedIconColorStyles . add ( styleKey ) ;
602
604
} else {
603
- console . log ( 'No color found for colorId:' , colorId ) ;
605
+ this . logService . debug ( 'No color found for colorId:' , colorId ) ;
604
606
}
605
607
}
606
608
@@ -686,14 +688,16 @@ class SessionsViewPane extends ViewPane {
686
688
@IHoverService hoverService : IHoverService ,
687
689
@IEditorService private readonly editorService : IEditorService ,
688
690
@IViewsService private readonly viewsService : IViewsService ,
691
+ @ILogService private readonly logService : ILogService ,
692
+ @IProgressService private readonly progressService : IProgressService ,
689
693
) {
690
694
super ( options , keybindingService , contextMenuService , configurationService , contextKeyService , viewDescriptorService , instantiationService , openerService , themeService , hoverService ) ;
691
695
692
696
// Listen for changes in the provider if it's a LocalChatSessionsProvider
693
697
if ( provider instanceof LocalChatSessionsProvider ) {
694
698
this . _register ( provider . onDidChange ( ( ) => {
695
699
if ( this . tree && this . isBodyVisible ( ) ) {
696
- this . tree . updateChildren ( this . provider ) ;
700
+ this . refreshTreeWithProgress ( ) ;
697
701
}
698
702
} ) ) ;
699
703
}
@@ -705,7 +709,57 @@ class SessionsViewPane extends ViewPane {
705
709
706
710
public refreshTree ( ) : void {
707
711
if ( this . tree && this . isBodyVisible ( ) ) {
708
- this . tree . updateChildren ( this . provider ) ;
712
+ this . refreshTreeWithProgress ( ) ;
713
+ }
714
+ }
715
+
716
+ /**
717
+ * Refreshes the tree data with progress indication.
718
+ * Shows a progress indicator while the tree updates its children from the provider.
719
+ */
720
+ private async refreshTreeWithProgress ( ) : Promise < void > {
721
+ if ( ! this . tree ) {
722
+ return ;
723
+ }
724
+
725
+ try {
726
+ await this . progressService . withProgress (
727
+ {
728
+ location : this . id , // Use the view ID as the progress location
729
+ title : nls . localize ( 'chatSessions.refreshing' , 'Refreshing chat sessions...' ) ,
730
+ } ,
731
+ async ( ) => {
732
+ await this . tree ! . updateChildren ( this . provider ) ;
733
+ }
734
+ ) ;
735
+ } catch ( error ) {
736
+ // Log error but don't throw to avoid breaking the UI
737
+ this . logService . error ( 'Error refreshing chat sessions tree:' , error ) ;
738
+ }
739
+ }
740
+
741
+ /**
742
+ * Loads initial tree data with progress indication.
743
+ * Shows a progress indicator while the tree loads data from the provider.
744
+ */
745
+ private async loadDataWithProgress ( ) : Promise < void > {
746
+ if ( ! this . tree ) {
747
+ return ;
748
+ }
749
+
750
+ try {
751
+ await this . progressService . withProgress (
752
+ {
753
+ location : this . id , // Use the view ID as the progress location
754
+ title : nls . localize ( 'chatSessions.loading' , 'Loading chat sessions...' ) ,
755
+ } ,
756
+ async ( ) => {
757
+ await this . tree ! . setInput ( this . provider ) ;
758
+ }
759
+ ) ;
760
+ } catch ( error ) {
761
+ // Log error but don't throw to avoid breaking the UI
762
+ this . logService . error ( 'Error loading chat sessions data:' , error ) ;
709
763
}
710
764
}
711
765
@@ -721,7 +775,7 @@ class SessionsViewPane extends ViewPane {
721
775
this . dataSource = new SessionsDataSource ( this . provider ) ;
722
776
723
777
const delegate = new SessionsDelegate ( ) ;
724
- const renderer = new SessionsRenderer ( this . labels , this . themeService ) ;
778
+ const renderer = new SessionsRenderer ( this . labels , this . themeService , this . logService ) ;
725
779
this . _register ( renderer ) ;
726
780
727
781
this . tree = this . instantiationService . createInstance (
@@ -747,6 +801,7 @@ class SessionsViewPane extends ViewPane {
747
801
}
748
802
) as WorkbenchAsyncDataTree < IChatSessionItemProvider , IChatSessionItem , FuzzyScore > ;
749
803
804
+ this . logService . debug ( 'Tree created with hideTwistiesOfChildlessElements: true' ) ;
750
805
this . _register ( this . tree ) ;
751
806
752
807
// Handle double-click and keyboard selection to open editors
@@ -773,13 +828,13 @@ class SessionsViewPane extends ViewPane {
773
828
// Handle visibility changes to load data
774
829
this . _register ( this . onDidChangeBodyVisibility ( async visible => {
775
830
if ( visible && this . tree ) {
776
- await this . tree . setInput ( this . provider ) ;
831
+ await this . loadDataWithProgress ( ) ;
777
832
}
778
833
} ) ) ;
779
834
780
835
// Initially load data if visible
781
836
if ( this . isBodyVisible ( ) && this . tree ) {
782
- this . tree . setInput ( this . provider ) ;
837
+ this . loadDataWithProgress ( ) ;
783
838
}
784
839
}
785
840
0 commit comments