From d6c304c7afa70952ba0a3515dadff08fb1a14272 Mon Sep 17 00:00:00 2001 From: Ofek Ben-Yaish Date: Wed, 6 Dec 2023 12:39:24 +0200 Subject: [PATCH] Add logs and fix notification function name --- src/enterprise/statusBar/StatusBar.ts | 6 ++--- .../statusBar/calculateStatusBarState.ts | 26 +++++++++++++++++++ src/enterprise/statusBar/statusAction.ts | 4 +-- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/enterprise/statusBar/StatusBar.ts b/src/enterprise/statusBar/StatusBar.ts index 373bf6c45e..8d16847f07 100644 --- a/src/enterprise/statusBar/StatusBar.ts +++ b/src/enterprise/statusBar/StatusBar.ts @@ -1,6 +1,6 @@ import { Disposable, ExtensionContext, window } from "vscode"; import { StatusItem } from "./StatusItem"; -import { showLoginNotification } from "./statusAction"; +import { showPleaseLoginNotification } from "./statusAction"; import { CONGRATS_MESSAGE_SHOWN_KEY } from "../../globals/consts"; import StatusBarState from "./StatusBarState"; import { useDerviedState } from "../../state/deriveState"; @@ -30,8 +30,8 @@ export class StatusBar implements Disposable { USER_INFO_STATE, (s) => s.isLoggedIn, (isLoggedIn) => { - if (isLoggedIn) { - showLoginNotification(); + if (!isLoggedIn) { + showPleaseLoginNotification(); } } ) diff --git a/src/enterprise/statusBar/calculateStatusBarState.ts b/src/enterprise/statusBar/calculateStatusBarState.ts index 53280a5fdf..da99d96da9 100644 --- a/src/enterprise/statusBar/calculateStatusBarState.ts +++ b/src/enterprise/statusBar/calculateStatusBarState.ts @@ -22,6 +22,8 @@ export default function calculateStatusBarState( userInfo: UserInfo | null ): StatusBarStateData { if (!processStartedState.resolved) { + Logger.info("Waiting for process to start..."); + return INITIAL_STATE; } @@ -36,12 +38,16 @@ export default function calculateStatusBarState( } if (!serverHealthOnPluginStart.resolved) { + Logger.info("Waiting for Tabnine server to be ready..."); + return { type: "loading", }; } if (serverHealthOnPluginStart.isError || !serverHealthOnPluginStart.data) { + Logger.error("Tabnine server is unhealthy."); + return { type: "error", message: "Please set your Tabnine server URL", @@ -49,7 +55,19 @@ export default function calculateStatusBarState( }; } + if (cloudConnection === undefined || cloudConnection === null) { + Logger.info("Waiting for Tabnine cloud connection..."); + + return { + type: "loading", + }; + } + if (cloudConnection !== "Ok") { + Logger.warn( + `Tabnine is not connected to your cloud. Connection status: ${cloudConnection}` + ); + return { type: "warning", message: "Connectivity issue - Tabnine is unable to reach the server", @@ -58,6 +76,8 @@ export default function calculateStatusBarState( } if (!isCompletionsEnabled) { + Logger.debug("Showing completions disabled status."); + return { type: "warning", command: StatusState.Ready, @@ -65,12 +85,16 @@ export default function calculateStatusBarState( } if (!userInfo) { + Logger.info("Waiting for user info..."); + return { type: "loading", }; } if (!userInfo.isLoggedIn) { + Logger.debug("User is logged out. Showing logged out status."); + return { type: "warning", message: "Please sign in to access Tabnine", @@ -79,6 +103,8 @@ export default function calculateStatusBarState( } if (!userInfo.team) { + Logger.debug("User is not part of a team. Showing logged out status."); + return { type: "warning", message: "You are not part of a team", diff --git a/src/enterprise/statusBar/statusAction.ts b/src/enterprise/statusBar/statusAction.ts index 12f6e2daa3..bad32a8b76 100644 --- a/src/enterprise/statusBar/statusAction.ts +++ b/src/enterprise/statusBar/statusAction.ts @@ -27,7 +27,7 @@ export function action(state: StatusState): void { ); break; case StatusState.LogIn: - showLoginNotification(); + showPleaseLoginNotification(); break; case StatusState.ErrorWaitingForProcess: void window @@ -102,7 +102,7 @@ export function action(state: StatusState): void { } } -export function showLoginNotification() { +export function showPleaseLoginNotification() { void window .showInformationMessage("Please sign in to access Tabnine.", "Sign in") .then((selection) => {