Skip to content
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

Enable Plugin Install Flow #369

Merged
merged 8 commits into from
Jan 27, 2021
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
12 changes: 0 additions & 12 deletions jsconfig.json

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,8 @@
"install-local": "vsce package && code --install-extension kite-*.vsix && rm kite-*.vsix"
},
"dependencies": {
"kite-api": "=3.19.0",
"kite-connector": "=3.12.0",
"kite-api": "=3.20.0",
"kite-connector": "=3.14.0",
"md5": "^2.2.0",
"mixpanel": "^0.5.0",
"open": "^7.3.0",
Expand Down
36 changes: 29 additions & 7 deletions src/kite.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ export const Kite = {
vscode.workspace.getConfiguration("kite").loggingLevel.toUpperCase()
];

KiteAPI
.isKiteInstalled()
.catch(NotificationsManager.showKiteInstallNotification);

this.setMaxFileSize();

this.disposables.push(
Expand Down Expand Up @@ -427,6 +423,7 @@ export const Kite = {
this.shown = {};
this.disposables = [];
this.attemptedToStartKite = false;
this.installing = false;
this.notifications = new NotificationsManager();
delete this.lastState;
delete this.lastStatus;
Expand Down Expand Up @@ -522,12 +519,32 @@ export const Kite = {
return state;
}
this.shown[state] = true;
if (KiteAPI.hasKiteRun()) {
NotificationsManager.showKiteInstallNotification();
} else {
NotificationsManager.showKiteDownloadingNotification();
this.installing = true;
KiteAPI.downloadKiteRelease({
install: true,
launchCopilot: true,
channel: 'vscode',
onRemove: () => { this.installing = false; },
})
.catch(e => {
console.error(e);
NotificationsManager.showKiteInstallErrorNotification();
});
}
break;
case KiteAPI.STATES.INSTALLED:
if (
!this.attemptedToStartKite &&
vscode.workspace.getConfiguration("kite").startKiteEngineOnStartup
) {
if (this.installing) {
// Guard against running Kite before installation fully completes.
break;
}
KiteAPI.runKiteAndWait(RUN_KITE_ATTEMPTS, RUN_KITE_INTERVAL).then(() => this.checkState(src));
this.attemptedToStartKite = true;
}
Expand Down Expand Up @@ -586,14 +603,19 @@ export const Kite = {
this.statusBarItem.show();
switch (state) {
case KiteAPI.STATES.UNSUPPORTED:
this.statusBarItem.text = "𝕜𝕚𝕥𝕖: not supported";
this.statusBarItem.tooltip =
"Kite engine is currently not supported on your platform";
this.statusBarItem.color = ERROR_COLOR();
this.statusBarItem.text = "𝕜𝕚𝕥𝕖: not supported";
break;
case KiteAPI.STATES.UNINSTALLED:
this.statusBarItem.text = "𝕜𝕚𝕥𝕖: not installed";
this.statusBarItem.tooltip = "Kite engine is not installed";
if (this.installing) {
this.statusBarItem.text = "𝕜𝕚𝕥𝕖: installing components";
this.statusBarItem.tooltip = "Installing components. Kite will launch automatically when ready.";
} else {
this.statusBarItem.text = "𝕜𝕚𝕥𝕖: not installed";
this.statusBarItem.tooltip = "Kite engine is not installed";
}
this.statusBarItem.color = ERROR_COLOR();
break;
case KiteAPI.STATES.INSTALLED:
Expand Down
69 changes: 51 additions & 18 deletions src/notifications.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import vscode from "vscode";
import open from "open";
import path from "path";

import metrics from "./metrics";

Expand Down Expand Up @@ -78,22 +77,56 @@ export default class NotificationsManager {
.then(hasDone => !hasDone && openKiteTutorial('python'));
}

static showKiteInstallNotification(err) {
if (typeof err.data !== 'undefined' && err.data.state === KiteAPI.STATES.UNINSTALLED) {
metrics.track("vscode_kite_installer_notification_shown");
vscode.window
.showInformationMessage(
"Kite requires the Kite Engine backend to provide completions and documentation. Please install it to use Kite.",
"Install"
)
.then(item => {
switch (item) {
case "Install":
open("https://www.kite.com/install/?utm_medium=editor&utm_source=vscode");
metrics.track("vscode_kite_installer_github_link_clicked");
break;
}
});
}
static showKiteInstallNotification() {
metrics.track("vscode_kite_installer_notification_shown");
vscode.window
.showInformationMessage(
"Kite requires the Kite Engine backend to provide completions and documentation. Please install it to use Kite.",
"Install"
)
.then(item => {
switch (item) {
case "Install":
open("https://www.kite.com/install/?utm_medium=editor&utm_source=vscode");
metrics.track("vscode_kite_installer_github_link_clicked");
break;
}
});
}

static showKiteDownloadingNotification() {
metrics.track("vscode_kite_downloading_notification_shown");
vscode.window
.showInformationMessage(
"Kite ships with a standalone application called the Copilot that can show you documentation while you code. The Copilot will launch automatically after Kite is finished installing.",
"OK",
"Learn More"
)
.then(item => {
switch (item) {
case "OK":
break;
case "Learn More":
open("https://www.kite.com/copilot/");
break;
}
});
}

static showKiteInstallErrorNotification() {
metrics.track("vscode_kite_downloading_failed_notification_shown");
vscode.window
.showErrorMessage(
"There was an error installing the Kite Engine, which is required for Kite to provide completions and documentation. Please install it to use Kite.",
"Install"
)
.then(item => {
switch (item) {
case "Install":
open("https://www.kite.com/install/?utm_medium=editor&utm_source=vscode");
metrics.track("vscode_kite_installer_github_link_clicked");
break;
}
});
}
}