@@ -27,17 +27,21 @@ export class WorkspaceMonitor implements vscode.Disposable {
27
27
readonly onChange = new vscode . EventEmitter < Workspace > ( )
28
28
private readonly updateStatusBarItem : vscode . StatusBarItem
29
29
30
+ // For logging.
31
+ private readonly name : String
32
+
30
33
constructor (
31
34
workspace : Workspace ,
32
35
private readonly restClient : Api ,
33
36
private readonly storage : Storage ,
34
37
) {
38
+ this . name = `${ workspace . owner_name } /${ workspace . name } `
35
39
const url = this . restClient . getAxiosInstance ( ) . defaults . baseURL
36
40
const token = this . restClient . getAxiosInstance ( ) . defaults . headers . common [ "Coder-Session-Token" ] as
37
41
| string
38
42
| undefined
39
43
const watchUrl = new URL ( `${ url } /api/v2/workspaces/${ workspace . id } /watch` )
40
- this . storage . writeToCoderOutputChannel ( `Monitoring ${ watchUrl } ` )
44
+ this . storage . writeToCoderOutputChannel ( `Monitoring ${ this . name } ... ` )
41
45
42
46
const eventSource = new EventSource ( watchUrl . toString ( ) , {
43
47
headers : {
@@ -77,6 +81,7 @@ export class WorkspaceMonitor implements vscode.Disposable {
77
81
*/
78
82
dispose ( ) {
79
83
if ( ! this . disposed ) {
84
+ this . storage . writeToCoderOutputChannel ( `Unmonitoring ${ this . name } ...` )
80
85
this . updateStatusBarItem . dispose ( )
81
86
this . eventSource . close ( )
82
87
this . disposed = true
@@ -103,7 +108,7 @@ export class WorkspaceMonitor implements vscode.Disposable {
103
108
this . isImpending ( workspace . latest_build . deadline , this . autostopNotifyTime )
104
109
) {
105
110
const toAutostopTime = formatDistanceToNowStrict ( new Date ( workspace . latest_build . deadline ) )
106
- vscode . window . showInformationMessage ( `${ workspace . name } is scheduled to shut down in ${ toAutostopTime } .` )
111
+ vscode . window . showInformationMessage ( `${ this . name } is scheduled to shut down in ${ toAutostopTime } .` )
107
112
this . notifiedAutostop = true
108
113
}
109
114
}
@@ -115,7 +120,7 @@ export class WorkspaceMonitor implements vscode.Disposable {
115
120
this . isImpending ( workspace . deleting_at , this . deletionNotifyTime )
116
121
) {
117
122
const toShutdownTime = formatDistanceToNowStrict ( new Date ( workspace . deleting_at ) )
118
- vscode . window . showInformationMessage ( `${ workspace . name } is scheduled for deletion in ${ toShutdownTime } .` )
123
+ vscode . window . showInformationMessage ( `${ this . name } is scheduled for deletion in ${ toShutdownTime } .` )
119
124
this . notifiedDeletion = true
120
125
}
121
126
}
0 commit comments