Skip to content

feat: show update message if one exists #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions src/remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
getWorkspaceByOwnerAndName,
startWorkspace,
getDeploymentSSHConfig,
getTemplateVersion,
} from "coder/site/src/api/api"
import { ProvisionerJobLog, Workspace, WorkspaceAgent } from "coder/site/src/api/typesGenerated"
import EventSource from "eventsource"
Expand Down Expand Up @@ -303,12 +304,20 @@ export class Remote {
if (newWorkspace.outdated) {
if (!this.storage.workspace?.outdated || !hasShownOutdatedNotification) {
hasShownOutdatedNotification = true
vscode.window
.showInformationMessage("A new version of your workspace is available.", "Update")
.then((action) => {
if (action === "Update") {
vscode.commands.executeCommand("coder.workspace.update", newWorkspace)
getTemplate(newWorkspace.template_id)
.then((template) => {
return getTemplateVersion(template.active_version_id)
})
.then((version) => {
let infoMessage = `A new version of your workspace is available.`
if (version.message) {
infoMessage = `A new version of your workspace is available: ${version.message}`
}
vscode.window.showInformationMessage(infoMessage, "Update").then((action) => {
if (action === "Update") {
vscode.commands.executeCommand("coder.workspace.update", newWorkspace)
}
})
})
}
}
Expand Down Expand Up @@ -507,7 +516,14 @@ export class Remote {
if (this.mode === vscode.ExtensionMode.Production) {
binaryPath = await this.storage.fetchBinary()
} else {
binaryPath = path.join(os.tmpdir(), "coder")
try {
// In development, try to use `/tmp/coder` as the binary path.
// This is useful for debugging with a custom bin!
binaryPath = path.join(os.tmpdir(), "coder")
await fs.stat(binaryPath)
} catch (ex) {
binaryPath = await this.storage.fetchBinary()
}
}
if (!binaryPath) {
throw new Error("Failed to fetch the Coder binary!")
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,7 @@ [email protected]:

"coder@https://github.com/coder/coder#main":
version "0.0.0"
resolved "https://github.com/coder/coder#140683813d794081a0c0dbab70ec7eee16c5f5c4"
resolved "https://github.com/coder/coder#07188b123a6bf925064c3972f581ac7098476839"

collapse-white-space@^1.0.2:
version "1.0.6"
Expand Down