Skip to content

Commit 46bfa50

Browse files
committed
Notify when workspace stops running
1 parent d5f525f commit 46bfa50

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/workspaceMonitor.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export class WorkspaceMonitor implements vscode.Disposable {
5151
const newWorkspaceData = JSON.parse(event.data) as Workspace
5252
if (JSON.stringify(this.lastData) !== JSON.stringify(newWorkspaceData)) {
5353
this.update(newWorkspaceData)
54+
this.maybeNotify(newWorkspaceData)
5455
this.onChange.fire(newWorkspaceData)
5556
}
5657
} catch (error) {
@@ -85,9 +86,13 @@ export class WorkspaceMonitor implements vscode.Disposable {
8586
this.lastData = workspace
8687
this.updateContext(workspace)
8788
this.updateStatusBar(workspace)
89+
}
90+
91+
private maybeNotify(workspace: Workspace) {
8892
this.maybeNotifyOutdated(workspace)
8993
this.maybeNotifyAutostop(workspace)
9094
this.maybeNotifyDeletion(workspace)
95+
this.maybeNotifyNotRunning(workspace)
9196
}
9297

9398
private maybeNotifyAutostop(workspace: Workspace) {
@@ -115,6 +120,22 @@ export class WorkspaceMonitor implements vscode.Disposable {
115120
}
116121
}
117122

123+
private maybeNotifyNotRunning(workspace: Workspace) {
124+
if (workspace.latest_build.status !== "running") {
125+
const action = vscode.window.showInformationMessage(
126+
"Your workspace is no longer running!",
127+
{
128+
detail: "Reloading the window to reconnect.",
129+
},
130+
"Reload Window",
131+
)
132+
if (!action) {
133+
return
134+
}
135+
vscode.commands.executeCommand("workbench.action.reloadWindow")
136+
}
137+
}
138+
118139
private isImpending(target: string, notifyTime: number): boolean {
119140
const nowTime = new Date().getTime()
120141
const targetTime = new Date(target).getTime()

0 commit comments

Comments
 (0)