Merge pull request #3450 from continuedev/nate/fixees

Fixes
This commit is contained in:
Nate Sesti 2024-12-20 08:58:37 -08:00 • committed by GitHub
commit 23020fa4a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 104 additions and 111 deletions

View file

@ -1,11 +1,9 @@
import path from "node:path";
import ignore from "ignore";
import { IDE } from "../..";
import { getConfigJsonPath } from "../../util/paths";
import { HelperVars } from "../util/HelperVars";
import { findUriInDirs } from "../../util/uri";
import { HelperVars } from "../util/HelperVars";
async function isDisabledForFile(
currentFilepath: string,
@ -52,9 +50,8 @@ export async function shouldPrefilter(
}
// Check whether autocomplete is disabled for this file
if (
await isDisabledForFile(helper.filepath, helper.options.disableInFiles, ide)
) {
const disableInFiles = [...(helper.options.disableInFiles ?? []), "*.prompt"];
if (await isDisabledForFile(helper.filepath, disableInFiles, ide)) {
return true;
}

View file

@ -71,10 +71,16 @@ function constructSystemPrompt(
provider: string,
useTools: boolean,
): string | null {
if (CUSTOM_SYS_MSG_MODEL_FAMILIES.some((family) => model.includes(family))) {
if (
useTools &&
CUSTOM_SYS_MSG_MODEL_FAMILIES.some((family) => model.includes(family))
) {
return SYSTEM_MESSAGE + "\n\n" + TOOL_USE_RULES;
}
if (useTools && modelSupportsTools(model, provider)) {
} else if (
CUSTOM_SYS_MSG_MODEL_FAMILIES.some((family) => model.includes(family))
) {
return SYSTEM_MESSAGE;
} else if (useTools && modelSupportsTools(model, provider)) {
return TOOL_USE_RULES;
}

View file

@ -445,11 +445,22 @@ export abstract class BaseLLM implements ILLM {
const msgsCopy = messages ? messages.map((msg) => ({ ...msg })) : [];
let formatted = "";
for (const msg of msgsCopy) {
if ("content" in msg && Array.isArray(msg.content)) {
let contentToShow = "";
if (msg.role === "tool") {
contentToShow = msg.content;
} else if (msg.role === "assistant" && msg.toolCalls) {
contentToShow = msg.toolCalls
?.map(
(toolCall) =>
`${toolCall.function?.name}(${toolCall.function?.arguments})`,
)
.join("\n");
} else if ("content" in msg && Array.isArray(msg.content)) {
const content = renderChatMessage(msg);
msg.content = content;
}
formatted += `<${msg.role}>\n${msg.content || ""}\n\n`;
formatted += `<${msg.role}>\n${contentToShow}\n\n`;
}
return formatted;
}

View file

@ -93,9 +93,7 @@ class OpenAI extends BaseLLM {
}
private isO1Model(model?: string): boolean {
return (
!!model && (model.startsWith("o1-preview") || model.startsWith("o1-mini"))
);
return !!model && model.startsWith("o1");
}
protected supportsPrediction(model: string): boolean {

View file

@ -1,6 +1,7 @@
import { ToolImpl } from ".";
import { getUriPathBasename } from "../../util/uri";
import { ToolImpl } from ".";
export const readCurrentlyOpenFileImpl: ToolImpl = async (args, extras) => {
const result = await extras.ide.getCurrentFile();
@ -15,6 +16,10 @@ export const readCurrentlyOpenFileImpl: ToolImpl = async (args, extras) => {
name: "Current file",
description: basename,
content: `\`\`\`${basename}\n${result.contents}\n\`\`\``,
uri: {
type: "file",
value: result.path,
},
},
];
};

View file

@ -1,13 +1,26 @@
import { ToolImpl } from ".";
import { resolveRelativePathInDir } from "../../util/ideUtils";
import { getUriPathBasename } from "../../util/uri";
import { ToolImpl } from ".";
export const readFileImpl: ToolImpl = async (args, extras) => {
const content = await extras.ide.readFile(args.filepath);
const firstUriMatch = await resolveRelativePathInDir(
args.filepath,
extras.ide,
);
if (!firstUriMatch) {
throw new Error(`Could not find file ${args.filepath}`);
}
const content = await extras.ide.readFile(firstUriMatch);
return [
{
name: getUriPathBasename(args.filepath),
description: args.filepath,
content,
uri: {
type: "file",
value: firstUriMatch,
},
},
];
};

View file

@ -1,6 +1,6 @@
import { ChatDescriber } from "./chatDescriber";
import { testLLM } from "../test/fixtures";
import { LLMFullCompletionOptions } from "..";
import { testLLM } from "../test/fixtures";
import { ChatDescriber } from "./chatDescriber";
describe("ChatDescriber", () => {
beforeEach(() => {
@ -30,7 +30,7 @@ describe("ChatDescriber", () => {
expect(result).toBeUndefined();
});
it("should set completionOptions.maxTokens to 6", async () => {
it("should set completionOptions.maxTokens to 12", async () => {
const message = "Test message";
const completionOptions: LLMFullCompletionOptions = { temperature: 0.7 };
@ -38,7 +38,7 @@ describe("ChatDescriber", () => {
await ChatDescriber.describe(testLLM, completionOptions, message);
expect(completionOptions.maxTokens).toBe(6);
expect(completionOptions.maxTokens).toBe(ChatDescriber.maxTokens);
});
it("should call model.chat with correct parameters", async () => {

View file

@ -1,13 +1,14 @@
import { ILLM, LLMFullCompletionOptions } from "..";
import { removeQuotesAndEscapes, removeCodeBlocksAndTrim } from ".";
import { removeCodeBlocksAndTrim, removeQuotesAndEscapes } from ".";
import type { IMessenger } from "../protocol/messenger";
import type { FromCoreProtocol, ToCoreProtocol } from "../protocol";
import type { IMessenger } from "../protocol/messenger";
export class ChatDescriber {
static maxTokens = 12;
static prompt: string | undefined =
"Given the following... please reply with a short summary that is 4-12 words in length, you should summarize what the user is asking for OR what the user is trying to accomplish. You should only respond with the summary, no additional text or explanation, you don't need ending punctuation.\n\n";
"Given the following... please reply with a short summary that is 4-8 words in length, you should summarize what the user is asking for OR what the user is trying to accomplish. You should only respond with the summary, no additional text or explanation, you don't need ending punctuation.\n\n";
static messenger: IMessenger<ToCoreProtocol, FromCoreProtocol>;
static async describe(
@ -26,7 +27,7 @@ export class ChatDescriber {
return;
}
completionOptions.maxTokens = 6;
completionOptions.maxTokens = ChatDescriber.maxTokens;
// Prompt the user's current LLM for the title
const titleResponse = await model.chat(

View file

@ -25,9 +25,9 @@ You can include a specific file in your current workspace as context by typing [
You can include a folder in your current workspace as context by typing [`@Folder`](../customize/context-providers.md#folder) and selecting the directory. It [works like `@Codebase`](../customize/deep-dives/codebase.md) but only includes the files in the selected folder.
## Entire codebase
## Codebase search
You can include your entire codebase as context by typing [`@Codebase`](../customize/context-providers.md#codebase). You can learn about how @Codebase works [here](../customize/deep-dives/codebase.md).
You can automatically include relevant files from your codebase as context by typing [`@Codebase`](../customize/context-providers.md#codebase). You can learn about how @Codebase works [here](../customize/deep-dives/codebase.md).
## Documentation site

View file

@ -127,11 +127,6 @@
"default": false,
"markdownDescription": "Pause Continue's codebase index on start."
},
"continue.enableDebugLogs": {
"type": "boolean",
"default": false,
"markdownDescription": "Enable Continue Debug Logs in the Output panel."
},
"continue.remoteConfigServerUrl": {
"type": "string",
"default": null,

View file

@ -1,5 +1,4 @@
import { ConfigHandler } from "core/config/ConfigHandler";
import { EXTENSION_NAME } from "core/control-plane/env";
import * as vscode from "vscode";
import { getTheme } from "./util/getTheme";
@ -19,42 +18,6 @@ export class ContinueGUIWebviewViewProvider
return !!this.webview;
}
private updateDebugLogsStatus() {
const settings = vscode.workspace.getConfiguration(EXTENSION_NAME);
this.enableDebugLogs = settings.get<boolean>("enableDebugLogs", false);
if (!this.enableDebugLogs) {
this.outputChannel.hide();
}
}
// Show or hide the output channel on enableDebugLogs
private setupDebugLogsListener() {
vscode.workspace.onDidChangeConfiguration((event) => {
if (event.affectsConfiguration("continue.enableDebugLogs")) {
const settings = vscode.workspace.getConfiguration(EXTENSION_NAME);
const enableDebugLogs = settings.get<boolean>("enableDebugLogs", false);
if (!enableDebugLogs) {
this.outputChannel.hide();
}
}
});
}
private async handleWebviewMessage(message: any) {
if (message.messageType === "log") {
const settings = vscode.workspace.getConfiguration(EXTENSION_NAME);
const enableDebugLogs = settings.get<boolean>("enableDebugLogs", false);
if (message.level === "debug" && !enableDebugLogs) {
return; // Skip debug logs if enableDebugLogs is false
}
const timestamp = new Date().toISOString().split(".")[0];
const logMessage = `[${timestamp}] [${message.level.toUpperCase()}] ${message.text}`;
this.outputChannel.appendLine(logMessage);
}
}
resolveWebviewView(
webviewView: vscode.WebviewView,
_context: vscode.WebviewViewResolveContext,
@ -62,9 +25,6 @@ export class ContinueGUIWebviewViewProvider
): void | Thenable<void> {
this._webviewView = webviewView;
this._webview = webviewView.webview;
this._webview.onDidReceiveMessage((message) =>
this.handleWebviewMessage(message),
);
webviewView.webview.html = this.getSidebarContent(
this.extensionContext,
webviewView,
@ -73,8 +33,6 @@ export class ContinueGUIWebviewViewProvider
private _webview?: vscode.Webview;
private _webviewView?: vscode.WebviewView;
private outputChannel: vscode.OutputChannel;
private enableDebugLogs: boolean;
get isVisible() {
return this._webviewView?.visible;
@ -104,11 +62,6 @@ export class ContinueGUIWebviewViewProvider
private readonly windowId: string,
private readonly extensionContext: vscode.ExtensionContext,
) {
this.outputChannel = vscode.window.createOutputChannel("Continue");
this.enableDebugLogs = false;
this.updateDebugLogsStatus();
this.setupDebugLogsListener();
this.webviewProtocol = new VsCodeWebviewProtocol(
(async () => {
const configHandler = await this.configHandlerPromise;

View file

@ -602,7 +602,7 @@ class VsCodeIde implements IDE {
"pauseCodebaseIndexOnStart",
false,
),
enableDebugLogs: settings.get<boolean>("enableDebugLogs", false),
enableDebugLogs: false,
// settings.get<boolean>(
// "enableControlServerBeta",
// false,

View file

@ -4,12 +4,12 @@ import { useEffect, useState } from "react";
import { useDispatch } from "react-redux";
import styled from "styled-components";
import { vscBackground } from "..";
import { getFontSize } from "../../util";
import StyledMarkdownPreview from "../markdown/StyledMarkdownPreview";
import ResponseActions from "./ResponseActions";
import { useAppSelector } from "../../redux/hooks";
import { selectUIConfig } from "../../redux/slices/configSlice";
import { deleteMessage } from "../../redux/slices/sessionSlice";
import { getFontSize } from "../../util";
import StyledMarkdownPreview from "../markdown/StyledMarkdownPreview";
import ResponseActions from "./ResponseActions";
import ThinkingIndicator from "./ThinkingIndicator";
interface StepContainerProps {
@ -49,6 +49,7 @@ export default function StepContainer(props: StepContainerProps) {
// If not ending in punctuation or emoji, we assume the response got truncated
if (
content.trim() !== "" &&
!(
endingPunctuation.some((p) => content.endsWith(p)) ||
/\p{Emoji}/u.test(content.slice(-2))

View file

@ -5,6 +5,7 @@ import {
} from "@heroicons/react/24/outline";
import { ContextItemWithId } from "core";
import { ctxItemToRifWithContents } from "core/commands/util";
import { getUriPathBasename } from "core/util/uri";
import { useContext, useMemo, useState } from "react";
import { AnimatedEllipsis, lightGray, vscBackground } from "..";
import { IdeMessengerContext } from "../../context/IdeMessenger";
@ -13,7 +14,6 @@ import { selectIsGatheringContext } from "../../redux/slices/sessionSlice";
import FileIcon from "../FileIcon";
import SafeImg from "../SafeImg";
import { getIconFromDropdownItem } from "./MentionList";
import { getUriPathBasename } from "core/util/uri";
interface ContextItemsPeekProps {
contextItems?: ContextItemWithId[];
@ -71,7 +71,8 @@ function ContextItemsPeekItem({ contextItem }: ContextItemsPeekItemProps) {
}
// Heuristic to check if it's a file
const shouldShowFileIcon = contextItem.content.includes("```");
const shouldShowFileIcon =
contextItem.content.includes("```") || contextItem.uri?.type === "file";
if (shouldShowFileIcon) {
return (

View file

@ -38,10 +38,10 @@ import {
} from "..";
import { IdeMessengerContext } from "../../context/IdeMessenger";
import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice";
import HeaderButtonWithToolTip from "../gui/HeaderButtonWithToolTip";
import FileIcon from "../FileIcon";
import SafeImg from "../SafeImg";
import AddDocsDialog from "../dialogs/AddDocsDialog";
import HeaderButtonWithToolTip from "../gui/HeaderButtonWithToolTip";
import { ComboBoxItem, ComboBoxItemType } from "./types";
const ICONS_FOR_DROPDOWN: { [key: string]: any } = {
@ -120,7 +120,7 @@ const ItemsDiv = styled.div`
overflow-y: auto;
max-height: 330px;
padding: 0.2rem;
position: relative;
position: relative; // absolute to test tippy.js bug
background-color: ${vscQuickInputBackground};
/* backdrop-filter: blur(12px); */
@ -352,7 +352,7 @@ const MentionList = forwardRef((props: MentionListProps, ref) => {
}, [allItems]);
return (
<ItemsDiv className="items-container">
<ItemsDiv>
{querySubmenuItem ? (
<QueryInput
rows={1}

View file

@ -7,6 +7,7 @@ import Text from "@tiptap/extension-text";
import { Plugin } from "@tiptap/pm/state";
import { Editor, EditorContent, JSONContent, useEditor } from "@tiptap/react";
import { ContextProviderDescription, InputModifiers } from "core";
import { rifWithContentsToContextItem } from "core/commands/util";
import { modelSupportsImages } from "core/llm/autodetect";
import { debounce } from "lodash";
import { usePostHog } from "posthog-js/react";
@ -34,7 +35,22 @@ import { useInputHistory } from "../../hooks/useInputHistory";
import useIsOSREnabled from "../../hooks/useIsOSREnabled";
import useUpdatingRef from "../../hooks/useUpdatingRef";
import { useWebviewListener } from "../../hooks/useWebviewListener";
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
import { selectUseActiveFile } from "../../redux/selectors";
import { selectDefaultModel } from "../../redux/slices/configSlice";
import {
addCodeToEdit,
clearCodeToEdit,
selectHasCodeToEdit,
selectIsInEditMode,
setMainEditorContentTrigger,
} from "../../redux/slices/sessionSlice";
import { exitEditMode } from "../../redux/thunks";
import {
loadLastSession,
loadSession,
saveCurrentSession,
} from "../../redux/thunks/session";
import {
getFontSize,
isJetBrains,
@ -55,22 +71,6 @@ import {
handleVSCMetaKeyIssues,
} from "./handleMetaKeyIssues";
import { ComboBoxItem } from "./types";
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
import { selectDefaultModel } from "../../redux/slices/configSlice";
import {
addCodeToEdit,
clearCodeToEdit,
selectHasCodeToEdit,
selectIsInEditMode,
setMainEditorContentTrigger,
} from "../../redux/slices/sessionSlice";
import { exitEditMode } from "../../redux/thunks";
import {
loadLastSession,
loadSession,
saveCurrentSession,
} from "../../redux/thunks/session";
import { rifWithContentsToContextItem } from "core/commands/util";
const InputBoxDiv = styled.div<{ border?: string }>`
resize: none;
@ -986,6 +986,12 @@ function TipTapEditor(props: TipTapEditorProps) {
<HoverTextDiv>Hold ⇧ to drop image</HoverTextDiv>
</>
)}
<div
id="tippy-js-div"
style={{
position: "fixed",
}}
/>
</InputBoxDiv>
);
}

View file

@ -37,9 +37,15 @@ function getSuggestion(
return;
}
const container = document.getElementById("tippy-js-div");
if (!container) {
console.log("no container");
return;
}
popup = tippy("body", {
getReferenceClientRect: props.clientRect,
appendTo: () => document.body,
appendTo: () => container,
content: component.element,
showOnCreate: true,
interactive: true,

View file

@ -12,14 +12,14 @@ function FunctionSpecificToolCallDiv({
const args = toolCallState.parsedArgs;
switch (toolCall.function.name) {
case "create_new_file":
case "builtin_create_new_file":
return (
<CreateFile
relativeFilepath={args.filepath}
fileContents={args.contents}
/>
);
case "run_terminal_command":
case "builtin_run_terminal_command":
return (
<RunTerminalCommand
command={args.command}

View file

@ -4,14 +4,14 @@ import { useNavigate } from "react-router-dom";
import styled from "styled-components";
import { table } from "table";
import { lightGray, vscBackground, vscInputBackground } from "../components";
import { CopyIconButton } from "../components/gui/CopyIconButton";
import { IdeMessengerContext } from "../context/IdeMessenger";
import { useNavigationListener } from "../hooks/useNavigationListener";
import { CopyIconButton } from "../components/gui/CopyIconButton";
const Th = styled.th`
padding: 0.5rem;
text-align: left;
border: 1px solid ${vscInputBackground};
border: 1px solid ${lightGray};
`;
const Tr = styled.tr`
@ -21,12 +21,12 @@ const Tr = styled.tr`
overflow-wrap: anywhere;
border: 1px solid ${vscInputBackground};
border: 1px solid ${lightGray};
`;
const Td = styled.td`
padding: 0.5rem;
border: 1px solid ${vscInputBackground};
border: 1px solid ${lightGray};
`;
function generateTable(data: unknown[][]) {