11import {
22 type Workspace ,
33 type WorkspaceAgent ,
4- type WorkspaceApp ,
54} from "coder/site/src/api/typesGenerated" ;
6- import * as path from "path" ;
5+ import * as path from "node: path" ;
76import * as vscode from "vscode" ;
87
98import {
@@ -132,7 +131,7 @@ export class WorkspaceProvider
132131 const showMetadata = this . getWorkspacesQuery === WorkspaceQuery . Mine ;
133132 if ( showMetadata ) {
134133 const agents = extractAllAgents ( resp . workspaces ) ;
135- agents . forEach ( async ( agent ) => {
134+ for ( const agent of agents ) {
136135 // If we have an existing watcher, re-use it.
137136 const oldWatcher = this . agentWatchers . get ( agent . id ) ;
138137 if ( oldWatcher ) {
@@ -146,16 +145,16 @@ export class WorkspaceProvider
146145 watcher . onChange ( ( ) => this . refresh ( ) ) ;
147146 this . agentWatchers . set ( agent . id , watcher ) ;
148147 }
149- } ) ;
148+ }
150149 }
151150
152151 // Dispose of watchers we ended up not reusing.
153- oldWatcherIds . forEach ( ( id ) => {
152+ for ( const id of oldWatcherIds ) {
154153 if ( ! reusedWatcherIds . includes ( id ) ) {
155154 this . agentWatchers . get ( id ) ?. dispose ( ) ;
156155 this . agentWatchers . delete ( id ) ;
157156 }
158- } ) ;
157+ }
159158
160159 // Create tree items for each workspace
161160 const workspaceTreeItems = resp . workspaces . map ( ( workspace : Workspace ) => {
@@ -165,22 +164,6 @@ export class WorkspaceProvider
165164 showMetadata ,
166165 ) ;
167166
168- // Get app status from the workspace agents
169- const agents = extractAgents ( workspace . latest_build . resources ) ;
170- agents . forEach ( ( agent ) => {
171- // Check if agent has apps property with status reporting
172- if ( agent . apps && Array . isArray ( agent . apps ) ) {
173- workspaceTreeItem . appStatus = agent . apps . map ( ( app : WorkspaceApp ) => ( {
174- name : app . display_name ,
175- url : app . url ,
176- agent_id : agent . id ,
177- agent_name : agent . name ,
178- command : app . command ,
179- workspace_name : workspace . name ,
180- } ) ) ;
181- }
182- } ) ;
183-
184167 return workspaceTreeItem ;
185168 } ) ;
186169
@@ -196,10 +179,10 @@ export class WorkspaceProvider
196179 this . visible = visible ;
197180 if ( ! visible ) {
198181 this . cancelPendingRefresh ( ) ;
199- } else if ( ! this . workspaces ) {
200- this . fetchAndRefresh ( ) ;
201- } else {
182+ } else if ( this . workspaces ) {
202183 this . maybeScheduleRefresh ( ) ;
184+ } else {
185+ this . fetchAndRefresh ( ) ;
203186 }
204187 }
205188
@@ -222,15 +205,15 @@ export class WorkspaceProvider
222205 }
223206 }
224207
225- private _onDidChangeTreeData : vscode . EventEmitter <
226- vscode . TreeItem | undefined | null | void
227- > = new vscode . EventEmitter < vscode . TreeItem | undefined | null | void > ( ) ;
208+ private readonly _onDidChangeTreeData : vscode . EventEmitter <
209+ vscode . TreeItem | undefined
210+ > = new vscode . EventEmitter < vscode . TreeItem | undefined > ( ) ;
228211 readonly onDidChangeTreeData : vscode . Event <
229212 vscode . TreeItem | undefined | null | void
230213 > = this . _onDidChangeTreeData . event ;
231214
232- // refresh causes the tree to re-render. It does not fetch fresh workspaces.
233- refresh ( item : vscode . TreeItem | undefined | null | void ) : void {
215+ // refresh causes the tree to re-render. It does not fetch fresh workspaces.
216+ refresh ( item ? : vscode . TreeItem ) : void {
234217 this . _onDidChangeTreeData . fire ( item ) ;
235218 }
236219
@@ -279,9 +262,10 @@ export class WorkspaceProvider
279262
280263 // Show the section if it has any items
281264 if ( appStatuses . length > 0 ) {
265+ appStatuses . reverse ( ) ;
282266 const appStatusSection = new SectionTreeItem (
283267 "App Statuses" ,
284- appStatuses . reverse ( ) ,
268+ appStatuses ,
285269 ) ;
286270 items . push ( appStatusSection ) ;
287271 }
@@ -430,15 +414,6 @@ export class AgentTreeItem extends OpenableTreeItem {
430414}
431415
432416export class WorkspaceTreeItem extends OpenableTreeItem {
433- public appStatus : {
434- name : string ;
435- url ?: string ;
436- agent_id ?: string ;
437- agent_name ?: string ;
438- command ?: string ;
439- workspace_name ?: string ;
440- } [ ] = [ ] ;
441-
442417 constructor (
443418 workspace : Workspace ,
444419 public readonly showOwner : boolean ,
0 commit comments