@@ -5,8 +5,10 @@ import { parseReports, StReport } from "./stParser";
55
66export function activate ( context : vscode . ExtensionContext ) : void {
77 const provider = new ReportsProvider ( ) ;
8+ const reportsView = vscode . window . createTreeView ( "stacktale.reports" , { treeDataProvider : provider } ) ;
9+ provider . bindView ( reportsView ) ;
810 context . subscriptions . push (
9- vscode . window . createTreeView ( "stacktale.reports" , { treeDataProvider : provider } ) ,
11+ reportsView ,
1012 vscode . commands . registerCommand ( "stacktale.refresh" , ( ) => provider . refresh ( ) ) ,
1113 vscode . commands . registerCommand ( "stacktale.openReport" , ( report : StReport ) => openCulprit ( report ) ) ,
1214 vscode . commands . registerCommand ( "stacktale.copyForAI" , ( item ?: ReportItem ) => copyForAI ( item ) ) ,
@@ -37,8 +39,13 @@ async function locateLogFile(): Promise<string | undefined> {
3739
3840class ReportsProvider implements vscode . TreeDataProvider < ReportItem > {
3941 private readonly changed = new vscode . EventEmitter < void > ( ) ;
42+ private view ?: vscode . TreeView < ReportItem > ;
4043 readonly onDidChangeTreeData = this . changed . event ;
4144
45+ bindView ( view : vscode . TreeView < ReportItem > ) : void {
46+ this . view = view ;
47+ }
48+
4249 refresh ( ) : void {
4350 this . changed . fire ( ) ;
4451 }
@@ -50,8 +57,10 @@ class ReportsProvider implements vscode.TreeDataProvider<ReportItem> {
5057 async getChildren ( ) : Promise < ReportItem [ ] > {
5158 const file = await locateLogFile ( ) ;
5259 if ( ! file || ! fs . existsSync ( file ) ) {
60+ this . setDescription ( undefined ) ;
5361 return [ ReportItem . note ( "No errors-ai.log in this workspace yet." ) ] ;
5462 }
63+ this . setDescription ( vscode . workspace . asRelativePath ( file , false ) ) ;
5564 let content : string ;
5665 try {
5766 content = fs . readFileSync ( file , "utf8" ) ;
@@ -64,6 +73,12 @@ class ReportsProvider implements vscode.TreeDataProvider<ReportItem> {
6473 }
6574 return reports . map ( ( r ) => ReportItem . report ( r ) ) ;
6675 }
76+
77+ private setDescription ( description : string | undefined ) : void {
78+ if ( this . view ) {
79+ this . view . description = description ;
80+ }
81+ }
6782}
6883
6984class ReportItem extends vscode . TreeItem {
@@ -88,13 +103,11 @@ class ReportItem extends vscode.TreeItem {
88103 : `#${ report . id } ` ;
89104 item . contextValue = "report" ;
90105 item . iconPath = new vscode . ThemeIcon ( "bug" ) ;
91- if ( report . culprit ) {
92- item . command = {
93- command : "stacktale.openReport" ,
94- title : "Open culprit" ,
95- arguments : [ report ] ,
96- } ;
97- }
106+ item . command = {
107+ command : "stacktale.openReport" ,
108+ title : "Open report" ,
109+ arguments : [ report ] ,
110+ } ;
98111 return item ;
99112 }
100113}
0 commit comments