Merge pull request #2185 from continuedev/pe/toast
feat: consolidate toast logic into "showToast"
This commit is contained in:
commit
2f8fff35e1
17 changed files with 92 additions and 73 deletions
|
|
@ -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]);
|
||||
|
||||
|
|
|
|||
11
core/core.ts
11
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 [];
|
||||
}
|
||||
});
|
||||
|
|
|
|||
11
core/index.d.ts
vendored
11
core/index.d.ts
vendored
|
|
@ -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<string>;
|
||||
getTags(artifactId: string): Promise<IndexTag[]>;
|
||||
getRepoName(dir: string): Promise<string | undefined>;
|
||||
errorPopup(message: string): Promise<void>;
|
||||
infoPopup(message: string): Promise<void>;
|
||||
|
||||
showToast(
|
||||
type: ToastType,
|
||||
message: string,
|
||||
...otherParams: any[]
|
||||
): Promise<any>;
|
||||
getGitRootPath(dir: string): Promise<string | undefined>;
|
||||
listDir(dir: string): Promise<[string, FileType][]>;
|
||||
getLastModified(files: string[]): Promise<{ [path: string]: number }>;
|
||||
|
|
|
|||
|
|
@ -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: " +
|
||||
|
|
|
|||
|
|
@ -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<IDE["showToast"]>,
|
||||
Awaited<ReturnType<IDE["showToast"]>>,
|
||||
];
|
||||
getGitRootPath: [{ dir: string }, string | undefined];
|
||||
listDir: [{ dir: string }, [string, FileType][]];
|
||||
getLastModified: [{ files: string[] }, { [path: string]: number }];
|
||||
|
|
|
|||
|
|
@ -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<void> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
pathSep(): Promise<string> {
|
||||
return Promise.resolve(path.sep);
|
||||
}
|
||||
|
|
@ -73,23 +81,20 @@ class FileSystemIde implements IDE {
|
|||
]);
|
||||
return Promise.resolve(all);
|
||||
}
|
||||
infoPopup(message: string): Promise<void> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
errorPopup(message: string): Promise<void> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
getRepoName(dir: string): Promise<string | undefined> {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
async getTags(artifactId: string): Promise<IndexTag[]> {
|
||||
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<IdeInfo> {
|
||||
|
|
|
|||
|
|
@ -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<string> {
|
||||
return this.request("pathSep", undefined);
|
||||
}
|
||||
|
|
@ -54,12 +56,8 @@ export class MessageIde implements IDE {
|
|||
return this.request("listDir", { dir });
|
||||
}
|
||||
|
||||
infoPopup(message: string): Promise<void> {
|
||||
return this.request("infoPopup", { message });
|
||||
}
|
||||
|
||||
errorPopup(message: string): Promise<void> {
|
||||
return this.request("errorPopup", { message });
|
||||
showToast: IDE["showToast"] = (...params) => {
|
||||
return this.request("showToast", params);
|
||||
}
|
||||
|
||||
getRepoName(dir: string): Promise<string | undefined> {
|
||||
|
|
|
|||
|
|
@ -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) => {
|
||||
|
|
|
|||
|
|
@ -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<string> {
|
||||
return Promise.resolve(this.ideUtils.path.sep);
|
||||
}
|
||||
|
|
@ -191,13 +193,24 @@ class VsCodeIde implements IDE {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
async infoPopup(message: string): Promise<void> {
|
||||
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<void> {
|
||||
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<string | undefined> {
|
||||
const repo = await this.getRepo(vscode.Uri.file(dir));
|
||||
|
|
@ -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<number, boolean> = new Map();
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue