diff --git a/extensions/vscode/src/debugPanel.ts b/extensions/vscode/src/debugPanel.ts index b0dab2424..bdc235cd3 100644 --- a/extensions/vscode/src/debugPanel.ts +++ b/extensions/vscode/src/debugPanel.ts @@ -519,9 +519,16 @@ export function getSidebarContent( } } } catch (e) { - vscode.window.showErrorMessage( - `Error handling message from Continue side panel: ${e}` - ); + vscode.window + .showErrorMessage( + `Error handling message from Continue side panel: ${e}`, + "Show Logs" + ) + .then((selection) => { + if (selection === "Show Logs") { + vscode.commands.executeCommand("workbench.action.toggleDevTools"); + } + }); respond({ done: true }); } }); diff --git a/extensions/vscode/src/history.ts b/extensions/vscode/src/history.ts index d1126db01..87ed290d9 100644 --- a/extensions/vscode/src/history.ts +++ b/extensions/vscode/src/history.ts @@ -76,7 +76,18 @@ class HistoryManager { const sessionsListFilePath = getSessionsListPath(); try { const rawSessionsList = fs.readFileSync(sessionsListFilePath, "utf-8"); - const sessionsList: SessionInfo[] = JSON.parse(rawSessionsList); + + let sessionsList: SessionInfo[]; + try { + sessionsList = JSON.parse(rawSessionsList); + } catch (e) { + if (rawSessionsList.trim() === "") { + fs.writeFileSync(sessionsListFilePath, JSON.stringify([])); + sessionsList = []; + } else { + throw e; + } + } let found = false; for (const sessionInfo of sessionsList) { diff --git a/extensions/vscode/src/loadConfig.ts b/extensions/vscode/src/loadConfig.ts index e49e53312..bba0347a1 100644 --- a/extensions/vscode/src/loadConfig.ts +++ b/extensions/vscode/src/loadConfig.ts @@ -23,6 +23,8 @@ class VsCodeConfigHandler { export const configHandler = new VsCodeConfigHandler(); +const TIMEOUT = 7200e3; // 7200 seconds = 2 hours + export async function llmFromTitle(title?: string): Promise { let config = await configHandler.loadConfig(new VsCodeIde()); @@ -46,41 +48,44 @@ export async function llmFromTitle(title?: string): Promise { } } - if (llm.requestOptions) { - // Since we know this is happening in Node.js, we can add requestOptions through a custom agent - const ca = [...tls.rootCertificates]; - const customCerts = - typeof llm.requestOptions?.caBundlePath === "string" - ? [llm.requestOptions?.caBundlePath] - : llm.requestOptions?.caBundlePath; - if (customCerts) { - ca.push( - ...customCerts.map((customCert) => fs.readFileSync(customCert, "utf8")) - ); + // Since we know this is happening in Node.js, we can add requestOptions through a custom agent + const ca = [...tls.rootCertificates]; + const customCerts = + typeof llm.requestOptions?.caBundlePath === "string" + ? [llm.requestOptions?.caBundlePath] + : llm.requestOptions?.caBundlePath; + if (customCerts) { + ca.push( + ...customCerts.map((customCert) => fs.readFileSync(customCert, "utf8")) + ); + } + + let timeout = llm.requestOptions?.timeout || TIMEOUT; + + const agent = new Agent({ + connect: { + ca, + rejectUnauthorized: llm.requestOptions?.verifySsl, + timeout, + }, + bodyTimeout: timeout, + connectTimeout: timeout, + headersTimeout: timeout, + }); + + llm._fetch = (input, init) => { + const headers: { [key: string]: string } = + llm!.requestOptions?.headers || {}; + for (const [key, value] of Object.entries(init?.headers || {})) { + headers[key] = value as string; } - const agent = new Agent({ - connect: { - ca, - rejectUnauthorized: llm.requestOptions?.verifySsl, - timeout: llm.requestOptions?.timeout, - }, + return fetch(input, { + ...init, + dispatcher: agent, + headers, }); - - llm._fetch = (input, init) => { - const headers: { [key: string]: string } = - llm!.requestOptions?.headers || {}; - for (const [key, value] of Object.entries(init?.headers || {})) { - headers[key] = value as string; - } - - return fetch(input, { - ...init, - dispatcher: agent, - headers, - }); - }; - } + }; return llm; }