From 087a82e69ca4a96f94fb4db6fa722539abd001ba Mon Sep 17 00:00:00 2001 From: Ansible-lightspeed-Bot Date: Fri, 20 Oct 2023 16:01:42 +0530 Subject: [PATCH] Fix reading copilot settings within the extension and other updates If the copilot extension is not installed the setting section will return undefined, add a check to handle the scenario. Update authentication logs Trim the model ID value to remove starting and trailig whitespaces --- src/features/lightspeed/base.ts | 2 +- src/features/lightspeed/lightSpeedOAuthProvider.ts | 9 +++++++++ src/settings.ts | 4 +++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/features/lightspeed/base.ts b/src/features/lightspeed/base.ts index 51c54f777..1ff8fb7e5 100644 --- a/src/features/lightspeed/base.ts +++ b/src/features/lightspeed/base.ts @@ -102,7 +102,7 @@ export class LightSpeedManager { )) as { copilot: { enable?: { ansible?: boolean } }; }; - const copilotEnableForAnsible = githubConfig.copilot.enable?.ansible; + const copilotEnableForAnsible = githubConfig?.copilot?.enable?.ansible; if (copilotEnableForAnsible) { vscode.window.showInformationMessage( "Please disable GitHub Copilot for Ansible Lightspeed file types to use Ansible Lightspeed." diff --git a/src/features/lightspeed/lightSpeedOAuthProvider.ts b/src/features/lightspeed/lightSpeedOAuthProvider.ts index e3db6ce4d..b59f5f7fc 100644 --- a/src/features/lightspeed/lightSpeedOAuthProvider.ts +++ b/src/features/lightspeed/lightSpeedOAuthProvider.ts @@ -587,10 +587,19 @@ export class LightSpeedAuthenticationProvider public async rhUserHasSeat(): Promise { const authSession = await this.getLightSpeedAuthSession(); if (authSession === undefined) { + console.log( + "[ansible-lightspeed-oauth] User authentication session not found." + ); return undefined; } else if (authSession?.rhUserHasSeat) { + console.log( + `[ansible-lightspeed-oauth] User "${authSession?.account?.label}" has a seat.` + ); return true; } else { + console.log( + `[ansible-lightspeed-oauth] User "${authSession?.account?.label}" does not have a seat.` + ); return false; } } diff --git a/src/settings.ts b/src/settings.ts index 151966bfc..e2c91f046 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -40,7 +40,9 @@ export class SettingsManager { suggestions: { enabled: lightSpeedSettings.get("suggestions.enabled", false), }, - model: lightSpeedSettings.get("modelIdOverride", undefined), + model: ( + lightSpeedSettings.get("modelIdOverride")?.trim() + ), }, }; return;