diff --git a/core/context/providers/DocsContextProvider.ts b/core/context/providers/DocsContextProvider.ts index 972c12190..88df47318 100644 --- a/core/context/providers/DocsContextProvider.ts +++ b/core/context/providers/DocsContextProvider.ts @@ -90,7 +90,8 @@ class DocsContextProvider extends BaseContextProvider { await docsService.isJetBrainsAndPreIndexedDocsProvider(); if (isJetBrainsAndPreIndexedDocsProvider) { - extras.ide.errorPopup( + extras.ide.showToast( + "error", `${DocsService.preIndexedDocsEmbeddingsProvider.id} is configured as ` + "the embeddings provider, but it cannot be used with JetBrains. " + "Please select a different embeddings provider to use the '@docs' " + @@ -108,8 +109,9 @@ class DocsContextProvider extends BaseContextProvider { }); } - const embeddingsProvider = - await docsService.getEmbeddingsProvider(!!preIndexedDoc); + const embeddingsProvider = await docsService.getEmbeddingsProvider( + !!preIndexedDoc, + ); const [vector] = await embeddingsProvider.embed([extras.fullInput]); diff --git a/core/core.ts b/core/core.ts index 5de63b5b4..ad72a44ce 100644 --- a/core/core.ts +++ b/core/core.ts @@ -176,7 +176,7 @@ export class Core { message: err.message, stack: err.stack, }); - this.messenger.request("errorPopup", { message: err.message }); + this.ide.showToast("error", err.message); }); // New @@ -272,9 +272,9 @@ export class Core { } if (hasFailed) { - this.ide.infoPopup(`Failed to index ${msg.data.startUrl}`); + this.ide.showToast("info", `Failed to index ${msg.data.startUrl}`); } else { - this.ide.infoPopup(`Successfully indexed ${msg.data.startUrl}`); + this.ide.showToast("info", `Successfully indexed ${msg.data.startUrl}`); this.messenger.send("refreshSubmenuItems", undefined); } }); @@ -344,7 +344,10 @@ export class Core { id, })); } catch (e) { - this.ide.errorPopup(`Error getting context items from ${name}: ${e}`); + this.ide.showToast( + "error", + `Error getting context items from ${name}: ${e}`, + ); return []; } }); diff --git a/core/index.d.ts b/core/index.d.ts index eec22f18d..02dfa1a52 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -317,6 +317,9 @@ export interface LLMFullCompletionOptions extends BaseCompletionOptions { model?: string; } + +export type ToastType = "info" | "error" | "warning"; + export interface LLMOptions { model: string; @@ -497,9 +500,11 @@ export interface IDE { getBranch(dir: string): Promise; getTags(artifactId: string): Promise; getRepoName(dir: string): Promise; - errorPopup(message: string): Promise; - infoPopup(message: string): Promise; - + showToast( + type: ToastType, + message: string, + ...otherParams: any[] + ): Promise; getGitRootPath(dir: string): Promise; listDir(dir: string): Promise<[string, FileType][]>; getLastModified(files: string[]): Promise<{ [path: string]: number }>; diff --git a/core/indexing/docs/DocsService.ts b/core/indexing/docs/DocsService.ts index 8859806ab..ef3513b44 100644 --- a/core/indexing/docs/DocsService.ts +++ b/core/indexing/docs/DocsService.ts @@ -141,7 +141,8 @@ export default class DocsService { async indexAllDocs(reIndex: boolean = false) { if (!this.hasDocsContextProvider()) { - this.ide.infoPopup( + this.ide.showToast( + "info", "No 'docs' provider configured under 'contextProviders' in config.json", ); return; @@ -154,7 +155,7 @@ export default class DocsService { while (!(await generator.next()).done) {} } - this.ide.infoPopup("Docs indexing completed"); + this.ide.showToast("info", "Docs indexing completed"); } async list() { @@ -711,7 +712,8 @@ export default class DocsService { if (isJetBrainsAndPreIndexedDocsProvider) { // A bit noisy for teams users whom have no choice if their admin is the one who didn't setup an embeddingsProvider - // this.ide.errorPopup( + // this.ide.showToast( + // "error", // "The 'transformers.js' embeddings provider currently cannot be used to index " + // "documentation in JetBrains. To enable documentation indexing, you can use " + // "any of the other providers described in the docs: " + diff --git a/core/protocol/ide.ts b/core/protocol/ide.ts index bb5f59810..d27945c3f 100644 --- a/core/protocol/ide.ts +++ b/core/protocol/ide.ts @@ -1,4 +1,4 @@ -import { ControlPlaneSessionInfo } from "../control-plane/client.js"; +import { ControlPlaneSessionInfo } from "../control-plane/client"; import type { ContinueRcJson, DiffLine, @@ -11,7 +11,8 @@ import type { Range, RangeInFile, Thread, -} from "../index.js"; + IDE, +} from "../"; export type ToIdeFromWebviewOrCoreProtocol = { // Methods from IDE type @@ -67,8 +68,10 @@ export type ToIdeFromWebviewOrCoreProtocol = { getBranch: [{ dir: string }, string]; getRepoName: [{ dir: string }, string | undefined]; - errorPopup: [{ message: string }, void]; - infoPopup: [{ message: string }, void]; + showToast: [ + Parameters, + Awaited>, + ]; getGitRootPath: [{ dir: string }, string | undefined]; listDir: [{ dir: string }, [string, FileType][]]; getLastModified: [{ files: string[] }, { [path: string]: number }]; diff --git a/core/util/filesystem.ts b/core/util/filesystem.ts index 06209a474..35e1ea71c 100644 --- a/core/util/filesystem.ts +++ b/core/util/filesystem.ts @@ -12,12 +12,20 @@ import { Range, RangeInFile, Thread, + ToastType, } from "../index.d.js"; import { getContinueGlobalPath } from "./paths.js"; class FileSystemIde implements IDE { constructor(private readonly workspaceDir: string) {} + showToast( + type: ToastType, + message: string, + ...otherParams: any[] + ): Promise { + return Promise.resolve(); + } pathSep(): Promise { return Promise.resolve(path.sep); } @@ -73,23 +81,20 @@ class FileSystemIde implements IDE { ]); return Promise.resolve(all); } - infoPopup(message: string): Promise { - return Promise.resolve(); - } - errorPopup(message: string): Promise { - return Promise.resolve(); - } + getRepoName(dir: string): Promise { return Promise.resolve(undefined); } async getTags(artifactId: string): Promise { - const directory =(await this.getWorkspaceDirs())[0]; - return [{ - artifactId, - branch: await this.getBranch(directory), - directory - }]; + const directory = (await this.getWorkspaceDirs())[0]; + return [ + { + artifactId, + branch: await this.getBranch(directory), + directory, + }, + ]; } getIdeInfo(): Promise { diff --git a/core/util/messageIde.ts b/core/util/messageIde.ts index 396df29c7..060c20766 100644 --- a/core/util/messageIde.ts +++ b/core/util/messageIde.ts @@ -10,6 +10,7 @@ import type { Range, RangeInFile, Thread, + ToastType, } from "../index.js"; import { ToIdeFromWebviewOrCoreProtocol } from "../protocol/ide.js"; import { FromIdeProtocol } from "../protocol/index.js"; @@ -25,6 +26,7 @@ export class MessageIde implements IDE { callback: (data: FromIdeProtocol[T][0]) => FromIdeProtocol[T][1], ) => void, ) {} + pathSep(): Promise { return this.request("pathSep", undefined); } @@ -54,12 +56,8 @@ export class MessageIde implements IDE { return this.request("listDir", { dir }); } - infoPopup(message: string): Promise { - return this.request("infoPopup", { message }); - } - - errorPopup(message: string): Promise { - return this.request("errorPopup", { message }); + showToast: IDE["showToast"] = (...params) => { + return this.request("showToast", params); } getRepoName(dir: string): Promise { diff --git a/core/util/reverseMessageIde.ts b/core/util/reverseMessageIde.ts index a65f1f1f2..46b4c2d0e 100644 --- a/core/util/reverseMessageIde.ts +++ b/core/util/reverseMessageIde.ts @@ -49,12 +49,8 @@ export class ReverseMessageIde { return this.ide.listDir(data.dir); }); - this.on("infoPopup", (data) => { - return this.ide.infoPopup(data.message); - }); - - this.on("errorPopup", (data) => { - return this.ide.errorPopup(data.message); + this.on("showToast", (data) => { + return this.ide.showToast(...data); }); this.on("getRepoName", (data) => { diff --git a/extensions/vscode/src/ideProtocol.ts b/extensions/vscode/src/VsCodeIde.ts similarity index 96% rename from extensions/vscode/src/ideProtocol.ts rename to extensions/vscode/src/VsCodeIde.ts index b89e24b43..8ec9bb748 100644 --- a/extensions/vscode/src/ideProtocol.ts +++ b/extensions/vscode/src/VsCodeIde.ts @@ -13,6 +13,7 @@ import type { Problem, RangeInFile, Thread, + ToastType, } from "core"; import { Range } from "core"; import { walkDir } from "core/indexing/walkDir"; @@ -42,6 +43,7 @@ class VsCodeIde implements IDE { ) { this.ideUtils = new VsCodeIdeUtils(); } + pathSep(): Promise { return Promise.resolve(this.ideUtils.path.sep); } @@ -191,13 +193,24 @@ class VsCodeIde implements IDE { return undefined; } - async infoPopup(message: string): Promise { - vscode.window.showInformationMessage(message); - } + showToast: IDE["showToast"] = async (...params) => { + const [type, message, ...otherParams] = params; + const { showErrorMessage, showWarningMessage, showInformationMessage } = + vscode.window; - async errorPopup(message: string): Promise { - vscode.window.showErrorMessage(message); - } + switch (type) { + case "error": + return showErrorMessage(message, "Show logs").then((selection) => { + if (selection === "Show logs") { + vscode.commands.executeCommand("workbench.action.toggleDevTools"); + } + }); + case "info": + return showInformationMessage(message, ...otherParams); + case "warning": + return showWarningMessage(message, ...otherParams); + } + }; async getRepoName(dir: string): Promise { const repo = await this.getRepo(vscode.Uri.file(dir)); diff --git a/extensions/vscode/src/debug/debug.ts b/extensions/vscode/src/debug/debug.ts index d4f12ea5a..0671df7d5 100644 --- a/extensions/vscode/src/debug/debug.ts +++ b/extensions/vscode/src/debug/debug.ts @@ -1,5 +1,5 @@ import * as vscode from "vscode"; -import type { VsCodeIde } from "../ideProtocol"; +import type { VsCodeIde } from "../VsCodeIde"; import type { VsCodeWebviewProtocol } from "../webviewProtocol"; export const threadStopped: Map = new Map(); diff --git a/extensions/vscode/src/extension/VsCodeExtension.ts b/extensions/vscode/src/extension/VsCodeExtension.ts index 8323a0d6f..049d50742 100644 --- a/extensions/vscode/src/extension/VsCodeExtension.ts +++ b/extensions/vscode/src/extension/VsCodeExtension.ts @@ -18,7 +18,7 @@ import { ContinueGUIWebviewViewProvider } from "../ContinueGUIWebviewViewProvide import { registerDebugTracker } from "../debug/debug"; import { DiffManager } from "../diff/horizontal"; import { VerticalPerLineDiffManager } from "../diff/verticalPerLine/manager"; -import { VsCodeIde } from "../ideProtocol"; +import { VsCodeIde } from "../VsCodeIde"; import { registerAllCodeLensProviders } from "../lang-server/codeLens"; import { QuickEdit } from "../quickEdit/QuickEditQuickPick"; import { setupRemoteConfigSync } from "../stubs/activation"; @@ -233,6 +233,7 @@ export class VsCodeExtension { "showConfigUpdateToast", true, ); + if (showToast) { vscode.window .showInformationMessage("Config updated", "Don't show again") diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index a51bd8233..a1bb9e109 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -17,7 +17,7 @@ import * as fs from "node:fs"; import * as path from "node:path"; import * as vscode from "vscode"; import { VerticalPerLineDiffManager } from "../diff/verticalPerLine/manager"; -import { VsCodeIde } from "../ideProtocol"; +import { VsCodeIde } from "../VsCodeIde"; import { getControlPlaneSessionInfo, WorkOsAuthProvider, @@ -282,18 +282,8 @@ export class VsCodeMessenger { const { filepath, startLine, endLine } = msg.data; return ide.showLines(filepath, startLine, endLine); }); - // Other - this.onWebviewOrCore("errorPopup", (msg) => { - vscode.window - .showErrorMessage(msg.data.message, "Show Logs") - .then((selection) => { - if (selection === "Show Logs") { - vscode.commands.executeCommand("workbench.action.toggleDevTools"); - } - }); - }); - this.onWebviewOrCore("infoPopup", (msg) => { - vscode.window.showInformationMessage(msg.data.message); + this.onWebviewOrCore("showToast", (msg) => { + this.ide.showToast(...msg.data); }); this.onWebviewOrCore("getGitHubAuthToken", (msg) => ide.getGitHubAuthToken(), diff --git a/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts b/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts index 58f6696c7..6b8c4d6db 100644 --- a/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts +++ b/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts @@ -312,7 +312,7 @@ export class QuickEdit { const modelTitle = await this.getCurModelTitle(); if (!modelTitle) { - this.ide.infoPopup("Please configure a model to use Quick Edit"); + this.ide.showToast("info", "Please configure a model to use Quick Edit"); return undefined; } diff --git a/extensions/vscode/src/util/ideUtils.ts b/extensions/vscode/src/util/ideUtils.ts index 15f79ddfd..0717ad39f 100644 --- a/extensions/vscode/src/util/ideUtils.ts +++ b/extensions/vscode/src/util/ideUtils.ts @@ -1,4 +1,4 @@ -import type { FileEdit, RangeInFile, Thread } from "core"; +import type { FileEdit, RangeInFile, Thread, ToastType } from "core"; import path from "node:path"; import * as vscode from "vscode"; import { threadStopped } from "../debug/debug"; diff --git a/gui/src/components/ProfileSwitcher.tsx b/gui/src/components/ProfileSwitcher.tsx index 4ffa1f085..44ba57b42 100644 --- a/gui/src/components/ProfileSwitcher.tsx +++ b/gui/src/components/ProfileSwitcher.tsx @@ -146,7 +146,7 @@ function ProfileSwitcher(props: {}) { !lastControlServerBetaEnabledStatus && enableControlServerBeta; if (shouldShowPopup) { - ideMessenger.ide.infoPopup("Continue for Teams enabled"); + ideMessenger.ide.showToast("info", "Continue for Teams enabled"); } setControlServerBetaEnabled(enableControlServerBeta); diff --git a/gui/src/components/mainInput/TipTapEditor.tsx b/gui/src/components/mainInput/TipTapEditor.tsx index 4cb6fb1fa..ef622240d 100644 --- a/gui/src/components/mainInput/TipTapEditor.tsx +++ b/gui/src/components/mainInput/TipTapEditor.tsx @@ -245,10 +245,10 @@ function TipTapEditor(props: TipTapEditorProps) { }; }); } else { - ideMessenger.post("errorPopup", { - message: - "Images need to be in jpg or png format and less than 10MB in size.", - }); + ideMessenger.post("showToast", [ + "error", + "Images need to be in jpg or png format and less than 10MB in size.", + ]); } return undefined; } diff --git a/gui/src/hooks/useChatHandler.ts b/gui/src/hooks/useChatHandler.ts index fa7e01945..34bcdafa5 100644 --- a/gui/src/hooks/useChatHandler.ts +++ b/gui/src/hooks/useChatHandler.ts @@ -282,10 +282,11 @@ function useChatHandler(dispatch: Dispatch, ideMessenger: IIdeMessenger) { ); } } catch (e: any) { - console.log("Continue: error streaming response: ", e); - ideMessenger.post("errorPopup", { - message: `Error streaming response: ${e.message}`, - }); + console.debug("Error streaming response: ", e); + ideMessenger.post("showToast", [ + "error", + `Error streaming response: ${e.message}`, + ]); } finally { dispatch(setInactive()); }