Skip to content

Commit

Permalink
Fix reading copilot settings within the extension and other updates
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Ansible-lightspeed-Bot committed Oct 20, 2023
1 parent f989a31 commit 087a82e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/features/lightspeed/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
9 changes: 9 additions & 0 deletions src/features/lightspeed/lightSpeedOAuthProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,10 +587,19 @@ export class LightSpeedAuthenticationProvider
public async rhUserHasSeat(): Promise<boolean | undefined> {
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;
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ export class SettingsManager {
suggestions: {
enabled: lightSpeedSettings.get("suggestions.enabled", false),
},
model: lightSpeedSettings.get("modelIdOverride", undefined),
model: <string | undefined>(
lightSpeedSettings.get<string | undefined>("modelIdOverride")?.trim()
),
},
};
return;
Expand Down

0 comments on commit 087a82e

Please sign in to comment.