fix: Improve config checks to prevent launch failures
- Added null checks to configuration retrieval to prevent failures - Ensured default configurations are provided for missing settings - Modified activation sequence to prevent errors with uninitiated UI utils
This commit is contained in:
parent
d25b16b6ef
commit
a6cc1b8221
@ -34,13 +34,13 @@ async function isProviderHasSetted() {
|
||||
try {
|
||||
const providerProperty = "Provider.devchat";
|
||||
const providerConfig: any = UiUtilWrapper.getConfiguration("devchat", providerProperty);
|
||||
if (Object.keys(providerConfig).length > 0) {
|
||||
if (providerConfig && Object.keys(providerConfig).length > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const providerPropertyOpenAI = "Provider.openai";
|
||||
const providerConfigOpenAI: any = UiUtilWrapper.getConfiguration("devchat", providerPropertyOpenAI);
|
||||
if (Object.keys(providerConfigOpenAI).length > 0) {
|
||||
if (providerConfigOpenAI && Object.keys(providerConfigOpenAI).length > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ async function configUpdateTo1115() {
|
||||
|
||||
for (const model of supportModels) {
|
||||
const modelConfig1: any = UiUtilWrapper.getConfiguration("devchat", model);
|
||||
if (Object.keys(modelConfig1).length === 0) {
|
||||
if (modelConfig1 && Object.keys(modelConfig1).length === 0) {
|
||||
let modelConfigNew = {};
|
||||
modelConfigNew = {"provider": "devchat"};
|
||||
if (model.startsWith("Model.gpt-")) {
|
||||
@ -138,7 +138,7 @@ async function configUpdateTo0924() {
|
||||
|
||||
for (const model of supportModels) {
|
||||
const modelConfig1: any = UiUtilWrapper.getConfiguration("devchat", model);
|
||||
if (Object.keys(modelConfig1).length === 0) {
|
||||
if (modelConfig1 && Object.keys(modelConfig1).length === 0) {
|
||||
modelConfigNew = {"provider": "devchat"};
|
||||
if (model.startsWith("Model.gpt-")) {
|
||||
modelConfigNew = {"provider": "openai"};
|
||||
@ -168,7 +168,7 @@ async function configUpdate0912To0924() {
|
||||
|
||||
for (const model of oldModels) {
|
||||
const modelConfig: any = UiUtilWrapper.getConfiguration("devchat", model);
|
||||
if (Object.keys(modelConfig).length !== 0) {
|
||||
if (modelConfig && Object.keys(modelConfig).length !== 0) {
|
||||
let modelProperties: any = {};
|
||||
for (const key of Object.keys(modelConfig || {})) {
|
||||
const property = modelConfig![key];
|
||||
@ -217,7 +217,7 @@ async function configUpdateto240205() {
|
||||
|
||||
for (const model of supportModels) {
|
||||
const modelConfig1: any = UiUtilWrapper.getConfiguration("devchat", model);
|
||||
if (Object.keys(modelConfig1).length === 0) {
|
||||
if (modelConfig1 && Object.keys(modelConfig1).length === 0) {
|
||||
let modelConfigNew = {};
|
||||
modelConfigNew = {"provider": "devchat"};
|
||||
await vscode.workspace.getConfiguration("devchat").update(model, modelConfigNew, vscode.ConfigurationTarget.Global);
|
||||
@ -247,7 +247,7 @@ async function updateInvalidSettings() {
|
||||
|
||||
for (const model of oldModels) {
|
||||
const modelConfig: any = UiUtilWrapper.getConfiguration("devchat", model);
|
||||
if (Object.keys(modelConfig).length !== 0) {
|
||||
if (modelConfig && Object.keys(modelConfig).length !== 0) {
|
||||
let modelProperties: any = {};
|
||||
for (const key of Object.keys(modelConfig || {})) {
|
||||
const property = modelConfig![key];
|
||||
@ -326,7 +326,7 @@ async function activate(context: vscode.ExtensionContext) {
|
||||
ExtensionContextHolder.context = context;
|
||||
|
||||
logger.init(LoggerChannelVscode.getInstance());
|
||||
UiUtilWrapper.init(new UiUtilVscode());
|
||||
UiUtilWrapper.init(new UiUtilVscode());
|
||||
|
||||
await configUpdateTo0924();
|
||||
await configUpdate0912To0924();
|
||||
|
Loading…
x
Reference in New Issue
Block a user