diff --git a/core/config/handler.ts b/core/config/handler.ts index 33712ed60..221a3ae37 100644 --- a/core/config/handler.ts +++ b/core/config/handler.ts @@ -16,15 +16,11 @@ export class ConfigHandler { private savedConfig: ContinueConfig | undefined; private savedBrowserConfig?: BrowserSerializedContinueConfig; - private readonly ide: IDE; - private ideSettingsPromise: Promise; - private readonly writeLog: (text: string) => void; - private readonly onConfigUpdate: () => void; constructor( - ide: IDE, - ideSettingsPromise: Promise, - writeLog: (text: string) => void, - onConfigUpdate: () => void, + private readonly ide: IDE, + private ideSettingsPromise: Promise, + private readonly writeLog: (text: string) => void, + private readonly onConfigUpdate: () => void, ) { this.ide = ide; this.ideSettingsPromise = ideSettingsPromise; @@ -58,50 +54,45 @@ export class ConfigHandler { } async loadConfig(): Promise { - try { - if (this.savedConfig) { - return this.savedConfig; - } - - let workspaceConfigs: ContinueRcJson[] = []; - try { - workspaceConfigs = await this.ide.getWorkspaceConfigs(); - } catch (e) { - console.warn("Failed to load workspace configs"); - } - - const ideInfo = await this.ide.getIdeInfo(); - const ideSettings = await this.ideSettingsPromise; - let remoteConfigServerUrl = undefined; - try { - remoteConfigServerUrl = - typeof ideSettings.remoteConfigServerUrl !== "string" || - ideSettings.remoteConfigServerUrl === "" - ? undefined - : new URL(ideSettings.remoteConfigServerUrl); - } catch (e) {} - - this.savedConfig = await loadFullConfigNode( - this.ide.readFile, - workspaceConfigs, - remoteConfigServerUrl, - ideInfo.ideType, - ); - this.savedConfig.allowAnonymousTelemetry = - this.savedConfig.allowAnonymousTelemetry && - (await this.ide.isTelemetryEnabled()); - - // Setup telemetry only after (and if) we know it is enabled - await Telemetry.setup( - this.savedConfig.allowAnonymousTelemetry ?? true, - await this.ide.getUniqueId(), - ); - + if (this.savedConfig) { return this.savedConfig; - } catch (e: any) { - console.error("Failed to loadConfig: ", e.message); - throw new Error("Failed to loadConfig: " + e.message); } + + let workspaceConfigs: ContinueRcJson[] = []; + try { + workspaceConfigs = await this.ide.getWorkspaceConfigs(); + } catch (e) { + console.warn("Failed to load workspace configs"); + } + + const ideInfo = await this.ide.getIdeInfo(); + const ideSettings = await this.ideSettingsPromise; + let remoteConfigServerUrl = undefined; + try { + remoteConfigServerUrl = + typeof ideSettings.remoteConfigServerUrl !== "string" || + ideSettings.remoteConfigServerUrl === "" + ? undefined + : new URL(ideSettings.remoteConfigServerUrl); + } catch (e) {} + + this.savedConfig = await loadFullConfigNode( + this.ide.readFile, + workspaceConfigs, + remoteConfigServerUrl, + ideInfo.ideType, + ); + this.savedConfig.allowAnonymousTelemetry = + this.savedConfig.allowAnonymousTelemetry && + (await this.ide.isTelemetryEnabled()); + + // Setup telemetry only after (and if) we know it is enabled + await Telemetry.setup( + this.savedConfig.allowAnonymousTelemetry ?? true, + await this.ide.getUniqueId(), + ); + + return this.savedConfig; } setupLlm(llm: ILLM): ILLM { diff --git a/core/config/load.ts b/core/config/load.ts index e30980b4b..6aa876417 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -38,7 +38,6 @@ import { getContinueDotEnv, migrate, } from "../util/paths"; -import { defaultConfig } from "./default"; const { execSync } = require("child_process"); function resolveSerializedConfig(filepath: string): SerializedContinueConfig { @@ -80,8 +79,7 @@ function loadSerializedConfig( try { config = resolveSerializedConfig(configPath); } catch (e) { - console.log("config.json is invalid. Falling back to default."); - config = defaultConfig; + throw new Error(`Failed to parse config.json: ${e}`); } if (config.allowAnonymousTelemetry === undefined) { diff --git a/extensions/vscode/src/webviewProtocol.ts b/extensions/vscode/src/webviewProtocol.ts index 381b543e5..ebca69c18 100644 --- a/extensions/vscode/src/webviewProtocol.ts +++ b/extensions/vscode/src/webviewProtocol.ts @@ -83,7 +83,7 @@ export class VsCodeWebviewProtocol { JSON.stringify({ msg }, null, 2), ); - let message = `Continue error: ${e.message}`; + let message = e.message; if (e.cause) { if (e.cause.name === "ConnectTimeoutError") { message = `Connection timed out. If you expect it to take a long time to connect, you can increase the timeout in config.json by setting "requestOptions": { "timeout": 10000 }. You can find the full config reference here: https://continue.dev/docs/reference/config`; diff --git a/gui/src/redux/slices/stateSlice.ts b/gui/src/redux/slices/stateSlice.ts index a51c85965..86dde5ccf 100644 --- a/gui/src/redux/slices/stateSlice.ts +++ b/gui/src/redux/slices/stateSlice.ts @@ -97,18 +97,7 @@ const initialState: State = { contextItems: [], active: false, config: { - models: [ - { - title: "GPT-4 (Free Trial)", - model: "gpt-4", - provider: "free-trial", - }, - { - title: "GPT-3.5-Turbo (Free Trial)", - model: "gpt-3.5-turbo", - provider: "free-trial", - }, - ], + models: [], slashCommands: [ { name: "edit", @@ -140,7 +129,7 @@ export const stateSlice = createSlice({ reducers: { setConfig: ( state, - { payload: config }: PayloadAction + { payload: config }: PayloadAction, ) => { const defaultModelTitle = config.models.find((model) => model.title === state.defaultModelTitle) @@ -168,7 +157,7 @@ export const stateSlice = createSlice({ }: PayloadAction<{ index: number; contextItems: ChatHistoryItem["contextItems"]; - }> + }>, ) => { if (state.history[index]) { state.history[index].contextItems = contextItems; @@ -178,7 +167,7 @@ export const stateSlice = createSlice({ state, { payload: { index, item }, - }: PayloadAction<{ index?: number; item: ContextItemWithId }> + }: PayloadAction<{ index?: number; item: ContextItemWithId }>, ) => { if (index === undefined) { const isFirstContextItem = @@ -201,7 +190,7 @@ export const stateSlice = createSlice({ }: PayloadAction<{ index: number; editorState: JSONContent; - }> + }>, ) => { const historyItem = state.history[payload.index]; if (!historyItem) { @@ -228,7 +217,7 @@ export const stateSlice = createSlice({ payload, }: PayloadAction<{ editorState: JSONContent; - }> + }>, ) => { state.history.push({ message: { role: "user", content: "" }, @@ -253,7 +242,7 @@ export const stateSlice = createSlice({ message: ChatMessage; index: number; contextItems?: ContextItemWithId[]; - }> + }>, ) => { if (payload.index >= state.history.length) { state.history.push({ @@ -281,7 +270,7 @@ export const stateSlice = createSlice({ }: PayloadAction<{ index: number; contextItems: ContextItemWithId[]; - }> + }>, ) => { const historyItem = state.history[payload.index]; if (!historyItem) { @@ -300,7 +289,7 @@ export const stateSlice = createSlice({ }, newSession: ( state, - { payload }: PayloadAction + { payload }: PayloadAction, ) => { if (payload) { state.history = payload.history; @@ -318,14 +307,14 @@ export const stateSlice = createSlice({ state, { payload, - }: PayloadAction<{ ids: ContextItemId[]; index: number | undefined }> + }: PayloadAction<{ ids: ContextItemId[]; index: number | undefined }>, ) => { const getKey = (id: ContextItemId) => `${id.providerTitle}-${id.itemId}`; const ids = new Set(payload.ids.map(getKey)); if (payload.index === undefined) { state.contextItems = state.contextItems.filter( - (item) => !ids.has(getKey(item.id)) + (item) => !ids.has(getKey(item.id)), ); } else { state.history[payload.index].contextItems = state.history[ @@ -337,7 +326,7 @@ export const stateSlice = createSlice({ state, { payload, - }: PayloadAction<{ rangeInFileWithContents: any; edit: boolean }> + }: PayloadAction<{ rangeInFileWithContents: any; edit: boolean }>, ) => { let contextItems = [...state.contextItems].map((item) => { return { ...item, editing: false }; @@ -400,7 +389,7 @@ export const stateSlice = createSlice({ state, { payload, - }: PayloadAction<{ ids: ContextItemId[]; index: number | undefined }> + }: PayloadAction<{ ids: ContextItemId[]; index: number | undefined }>, ) => { const ids = payload.ids.map((id) => id.itemId); @@ -436,7 +425,7 @@ export const stateSlice = createSlice({ }, setDefaultModel: (state, { payload }: PayloadAction) => { const model = state.config.models.find( - (model) => model.title === payload + (model) => model.title === payload, ); if (!model) return; return {