Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9e578dd

Browse files
committed
Make reload notification a modal again
After experimentation, I think this is better. The idea with the notification was that it would not be in the way, but I think this is really something you need to be aware of and ideally you should immediately reload. Also, only show it once.
1 parent 699324c commit 9e578dd

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

src/remote.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ export class Remote {
373373
}
374374

375375
// Watch the workspace for changes.
376-
const monitor = new WorkspaceMonitor(workspace, workspaceRestClient, this.storage)
376+
const monitor = new WorkspaceMonitor(workspace, workspaceRestClient, this.storage, this.vscodeProposed)
377377
disposables.push(monitor)
378378
disposables.push(monitor.onChange.event((w) => (this.commands.workspace = w)))
379379

src/workspaceMonitor.ts

+22-14
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,20 @@ export class WorkspaceMonitor implements vscode.Disposable {
2323
private notifiedAutostop = false
2424
private notifiedDeletion = false
2525
private notifiedOutdated = false
26+
private notifiedNotRunning = false
2627

2728
readonly onChange = new vscode.EventEmitter<Workspace>()
2829
private readonly statusBarItem: vscode.StatusBarItem
2930

3031
// For logging.
31-
private readonly name: String
32+
private readonly name: string
3233

3334
constructor(
3435
workspace: Workspace,
3536
private readonly restClient: Api,
3637
private readonly storage: Storage,
38+
// We use the proposed API to get access to useCustom in dialogs.
39+
private readonly vscodeProposed: typeof vscode,
3740
) {
3841
this.name = `${workspace.owner_name}/${workspace.name}`
3942
const url = this.restClient.getAxiosInstance().defaults.baseURL
@@ -129,19 +132,24 @@ export class WorkspaceMonitor implements vscode.Disposable {
129132
}
130133

131134
private maybeNotifyNotRunning(workspace: Workspace) {
132-
if (workspace.latest_build.status !== "running") {
133-
vscode.window.showInformationMessage(
134-
"Your workspace is no longer running!",
135-
{
136-
detail: "Reloading the window to reconnect.",
137-
},
138-
"Reload Window",
139-
).then((action) => {
140-
if (!action) {
141-
return
142-
}
143-
vscode.commands.executeCommand("workbench.action.reloadWindow")
144-
})
135+
if (!this.notifiedNotRunning && workspace.latest_build.status !== "running") {
136+
this.notifiedNotRunning = true
137+
this.vscodeProposed.window
138+
.showInformationMessage(
139+
`${this.name} is no longer running!`,
140+
{
141+
detail: `The workspace status is "${workspace.latest_build.status}". Reload the window to reconnect.`,
142+
modal: true,
143+
useCustom: true,
144+
},
145+
"Reload Window",
146+
)
147+
.then((action) => {
148+
if (!action) {
149+
return
150+
}
151+
vscode.commands.executeCommand("workbench.action.reloadWindow")
152+
})
145153
}
146154
}
147155

0 commit comments

Comments
 (0)