diff --git a/jsconfig.json b/jsconfig.json deleted file mode 100644 index b7caa7d0..00000000 --- a/jsconfig.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "target": "es6", - "lib": [ - "es6" - ] - }, - "exclude": [ - "node_modules" - ] -} \ No newline at end of file diff --git a/package.json b/package.json index b5879595..ec3202dc 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/kite.js b/src/kite.js index 5ca751c7..db57ad72 100644 --- a/src/kite.js +++ b/src/kite.js @@ -86,10 +86,6 @@ export const Kite = { vscode.workspace.getConfiguration("kite").loggingLevel.toUpperCase() ]; - KiteAPI - .isKiteInstalled() - .catch(NotificationsManager.showKiteInstallNotification); - this.setMaxFileSize(); this.disposables.push( @@ -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; @@ -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; } @@ -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: diff --git a/src/notifications.js b/src/notifications.js index eb77d4cd..fd822d37 100644 --- a/src/notifications.js +++ b/src/notifications.js @@ -1,6 +1,5 @@ import vscode from "vscode"; import open from "open"; -import path from "path"; import metrics from "./metrics"; @@ -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; + } + }); } }