Merge branch 'main' of https://github.com/continuedev/continue into dallin/model-toggles

This commit is contained in:
Dallin Romney 2025-02-21 12:19:54 -08:00
commit 7ca7e324ee
26 changed files with 159 additions and 68 deletions

View file

@ -4,7 +4,7 @@ description: Generate unit tests for core utilities
Write jest tests for the provided code.
Use jest version ^29 (e.g. jest 29.7.0)
Use best practices. Be clear and consise.
Use best practices. Be clear and concise.
Aim for 100% code coverage where reasonable.
Multiple tests can be written, split up tests for best clarity and readability.
Only use typescript, and if the file/code is not typescript, warn the user.
@ -15,7 +15,7 @@ Use double quotes (or backticks if needed) for strings
The code being tested is used in IDE extensions, and it:
- accesses code workspaces through the IDE ("workspace directories")
- persists extension-related data to the the local machine of the user ("global directory"), and
- uses configuration via a `ConfigHandler`, which is stored in either the global directory (default) or accesed via a remote "control plane" using the `ControlPlaneClient`
- uses configuration via a `ConfigHandler`, which is stored in either the global directory (default) or accessed via a remote "control plane" using the `ControlPlaneClient`
Jest testing setup includes
- @core/test/jest.global-setup.ts initializes a temporary global directory, which is where files that store persisted extension data live.
@ -31,7 +31,7 @@ Jest testing setup includes
Do NOT write tests for any files in `core/test`, only use them as helpers for testing other files. If no other files are provided, warn the user and write no tests.
IMPORTANT: Do NOT mock the fixtures above other than using `jest.spyOn`. DO mock 3rd party modules, etc. when sensible.
IMPORTANT: Do NOT mock the fixtures above other than using `jest.spyOn`. DO mock 3rd party modules, etc. when sensible.
Instead, generate actual mock files and data for operations
Pure mocks should only be used to emulate specific network responses/error or hard-to-duplicate errors, or to prevent long-duration tests

22
.vscode/tasks.json vendored
View file

@ -71,7 +71,27 @@
}
]
},
// Build the React app. It gets bundled into the extension as a file resource and has a seprate build step
{
"label": "vscode-extension:package",
"dependsOn": ["vscode-extension:esbuild"],
"type": "npm",
"script": "package",
"path": "extensions/vscode",
"problemMatcher": [
{
"pattern": [
{
"regexp": "> (.*?):([0-9]+):([0-9]+): (warning|error): (.+)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
]
}
]
},
{
"label": "vscode-extension:continue-ui:build",
"type": "shell",

View file

@ -128,7 +128,7 @@ nvm use
1. The new VS Code window with the extension is referred to as the _Host VS Code_
2. The window you started debugging from is referred to as the _Main VS Code_
3. To package the extension, run `npm run package` in the `extensions/vscode` directory. This will generate `extensions/vscode/build/continue-{VERSION}.vsix`, which you can install by right-clicking and selecting "Install Extension VSIX".
3. To package the extension, run `npm run package` in the `extensions/vscode` directory, select `Tasks: Run Task` and then select `vscode-extension:package`. This will generate `extensions/vscode/build/continue-{VERSION}.vsix`, which you can install by right-clicking and selecting "Install Extension VSIX".
##### Debugging

View file

@ -240,6 +240,14 @@ export const Solidity = {
endOfLine: [";"],
};
// Lua
export const Lua = {
name: "Lua",
topLevelKeywords: ["function"],
singleLineComment: "--",
endOfLine: [],
};
// YAML
export const YAML: AutocompleteLanguageInfo = {
name: "YAML",
@ -367,6 +375,8 @@ export const LANGUAGES: { [extension: string]: AutocompleteLanguageInfo } = {
yaml: YAML,
yml: YAML,
md: Markdown,
lua: Lua,
luau: Lua,
};
export function languageForFilepath(fileUri: string): AutocompleteLanguageInfo {

View file

@ -399,7 +399,8 @@ export function getTemplateForModel(model: string): AutocompleteTemplate {
lowerCaseModel.includes("gpt") ||
lowerCaseModel.includes("davinci-002") ||
lowerCaseModel.includes("claude") ||
lowerCaseModel.includes("granite3")
lowerCaseModel.includes("granite3") ||
lowerCaseModel.includes("granite-3")
) {
return holeFillerTemplate;
}

View file

@ -92,6 +92,17 @@ export class ConfigHandler {
});
}
/**
* Retrieves the titles of additional context providers that are of type "submenu".
*
* @returns {string[]} An array of titles of the additional context providers that have a description type of "submenu".
*/
getAdditionalSubmenuContextProviders(): string[] {
return this.additionalContextProviders
.filter(provider => provider.description.type === "submenu")
.map(provider => provider.description.title);
}
private async init() {
try {
await this.fetchControlPlaneProfiles();

View file

@ -128,6 +128,14 @@ export class Core {
profileId:
this.configHandler.currentProfile?.profileDescription.id ?? null,
});
// update additional submenu context providers registered via VSCode API
const additionalProviders = this.configHandler.getAdditionalSubmenuContextProviders();
if (additionalProviders.length > 0) {
this.messenger.send("refreshSubmenuItems", {
providers: additionalProviders,
});
}
});
this.configHandler.onDidChangeAvailableProfiles(

View file

@ -139,24 +139,35 @@ export async function htmlPageToArticleWithChunks(
return undefined;
}
const title = readability.title || subpath;
const titles = Array.from(dom.window.document.querySelectorAll("h2"));
const article_components = titles.map((titleElement) => {
const title = titleElement.textContent || "";
let body = "";
let nextSibling = titleElement.nextElementSibling;
while (nextSibling && nextSibling.tagName !== "H2") {
body += nextSibling.textContent || "";
nextSibling = nextSibling.nextElementSibling;
}
const article_components =
titles.length > 0
? titles.map((titleElement) => {
const title = titleElement.textContent || "";
let body = "";
let nextSibling = titleElement.nextElementSibling;
return { title, body };
});
while (nextSibling && nextSibling.tagName !== "H2") {
body += nextSibling.textContent || "";
nextSibling = nextSibling.nextElementSibling;
}
return { title, body };
})
: [
{
title: title,
body: readability.textContent,
},
];
const article = {
url,
subpath,
title: readability.title,
title: title,
article_components,
};
return {

View file

@ -358,6 +358,11 @@ const preIndexedDocs: Record<
startUrl: "https://angular.dev/",
rootUrl: "https://angular.dev/",
},
"https://docs.djangoproject.com/": {
title: "Django",
startUrl: "https://docs.djangoproject.com/",
rootUrl: "https://docs.djangoproject.com/",
}
};
export default preIndexedDocs;

View file

@ -445,7 +445,7 @@ class VertexAI extends BaseLLM {
}
const resp = await this.fetch(
new URL(this.apiBase + `/publishers/google/models/${this.model}:predict`),
new URL(`publishers/google/models/${this.model}:predict`, this.apiBase),
{
method: "POST",
body: JSON.stringify({

View file

@ -93,6 +93,7 @@ export const supportedLanguages: { [key: string]: LanguageName } = {
htm: LanguageName.HTML,
java: LanguageName.JAVA,
lua: LanguageName.LUA,
luau: LanguageName.LUA,
ocaml: LanguageName.OCAML,
ml: LanguageName.OCAML,
mli: LanguageName.OCAML,

View file

@ -1,5 +1,6 @@
package com.github.continuedev.continueintellijextension.autocomplete
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
@ -27,4 +28,8 @@ class CancelAutocompleteAction : AnAction() {
val editor: Editor? = e.getData(CommonDataKeys.EDITOR)
return project != null && editor != null && editor.contentComponent.hasFocus()
}
override fun getActionUpdateThread(): ActionUpdateThread {
return ActionUpdateThread.BGT
}
}

View file

@ -137,7 +137,10 @@ fun openInlineEdit(project: Project?, editor: Editor) {
modelTitles.addAll(models.map { it["title"] as String })
}
val maxWaitTime = 200
// This is a hacky way to not complicate getting model titles with coroutines
// 1500 feels like way upper limit of "would be weird if panel showed up after that long"
// And should always allow enough time to load config
val maxWaitTime = 1500
val startTime = System.currentTimeMillis()
while (modelTitles.isEmpty() && System.currentTimeMillis() - startTime < maxWaitTime) {
Thread.sleep(20)

View file

@ -192,10 +192,12 @@ class VerticalDiffBlock(
private fun revertDiff() {
WriteCommandAction.runWriteCommandAction(project) {
// Delete the added lines
val startOffset = editor.document.getLineStartOffset(startLine)
val endOffset = editor.document.getLineEndOffset(startLine + addedLines.size - 1) + 1
editor.document.deleteString(startOffset, endOffset)
// Delete the added lines
if (addedLines.isNotEmpty()) {
val endOffset = editor.document.getLineEndOffset(startLine + addedLines.size - 1) + 1
editor.document.deleteString(startOffset, endOffset)
}
// Add the deleted lines back
if (deletedLines.isNotEmpty()) {

View file

@ -504,21 +504,11 @@ async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) {
async function copyScripts() {
process.chdir(path.join(continueDir, "extensions", "vscode"));
console.log("[info] Copying scripts from core");
await new Promise((resolve, reject) => {
ncp(
path.join(__dirname, "../../../core/scripts"),
path.join(__dirname, "../out"),
{ dereference: true },
(error) => {
if (error) {
console.warn("[error] Error copying script files", error);
reject(error);
} else {
resolve();
}
},
);
});
fs.copyFileSync(
path.join(__dirname, "../../../core/util/start_ollama.sh"),
path.join(__dirname, "../out/start_ollama.sh"),
);
console.log("[info] Copied script files");
}
module.exports = {

View file

@ -1054,7 +1054,7 @@ export function registerAllCommands(
core: Core,
editDecorationManager: EditDecorationManager,
) {
// registerCopyBufferSpy(context, core);
registerCopyBufferSpy(context, core);
for (const [command, callback] of Object.entries(
getCommandsMap(

View file

@ -109,7 +109,6 @@ function ContinueInputBox(props: ContinueInputBoxProps) {
hideImageUpload: false,
hideUseCodebase: true,
hideSelectModel: false,
hideTools: true,
enterText: editModeState.editStatus === "accepting" ? "Retry" : "Edit",
}
: {};

View file

@ -67,7 +67,6 @@ export interface ToolbarOptions {
hideAddContext?: boolean;
enterText?: string;
hideSelectModel?: boolean;
hideTools?: boolean;
}
interface InputToolbarProps {
@ -91,10 +90,7 @@ function InputToolbar(props: InputToolbarProps) {
const hasCodeToEdit = useAppSelector(selectHasCodeToEdit);
const isEditModeAndNoCodeToEdit = isInEditMode && !hasCodeToEdit;
const isEnterDisabled = props.disabled || isEditModeAndNoCodeToEdit;
const toolsSupported =
defaultModel &&
modelSupportsTools(defaultModel) &&
!props.toolbarOptions?.hideTools;
const toolsSupported = defaultModel && modelSupportsTools(defaultModel);
const supportsImages =
defaultModel &&
@ -110,7 +106,6 @@ function InputToolbar(props: InputToolbarProps) {
<StyledDiv
isHidden={props.hidden}
onClick={props.onClick}
id="input-toolbar"
className="find-widget-skip flex"
>
<div className="flex items-center justify-start gap-2 whitespace-nowrap">

View file

@ -14,6 +14,7 @@ import InfoHover from "../../InfoHover";
import HoverItem from "./HoverItem";
import PopoverTransition from "./PopoverTransition";
import ToolDropdownItem from "./ToolDropdownItem";
import { selectIsInEditMode } from "../../../redux/slices/sessionSlice";
interface ToolDropdownProps {
disabled: boolean;
@ -28,6 +29,7 @@ export default function ToolDropdown(props: ToolDropdownProps) {
const useTools = useAppSelector((state) => state.ui.useTools);
const availableTools = useAppSelector((state) => state.config.config.tools);
const [showAbove, setShowAbove] = useState(false);
const isInEditMode = useAppSelector(selectIsInEditMode);
const ToolsIcon = useTools
? WrenchScrewdriverIconSolid
@ -48,33 +50,37 @@ export default function ToolDropdown(props: ToolDropdownProps) {
}
}, [isDropdownOpen]);
const isDisabled = props.disabled || isInEditMode;
return (
<HoverItem onClick={() => !props.disabled && dispatch(toggleUseTools())}>
<HoverItem onClick={() => !isDisabled && dispatch(toggleUseTools())}>
<div
data-tooltip-id="tools-tooltip"
className={`-ml-1 -mt-1 flex flex-row items-center gap-1.5 rounded-md px-1 py-0.5 text-xs ${
(useTools || isHovered) && !props.disabled ? "bg-lightgray/30" : ""
} ${props.disabled ? "cursor-not-allowed opacity-50" : ""}`}
(useTools || isHovered) && !isDisabled ? "bg-lightgray/30" : ""
} ${isDisabled ? "cursor-not-allowed opacity-50" : ""}`}
>
<ToolsIcon
className={`h-4 w-4 text-gray-400 ${
props.disabled ? "cursor-not-allowed" : ""
isDisabled ? "cursor-not-allowed" : ""
}`}
onMouseEnter={() => !props.disabled && setIsHovered(true)}
onMouseLeave={() => !props.disabled && setIsHovered(false)}
onMouseEnter={() => !isDisabled && setIsHovered(true)}
onMouseLeave={() => !isDisabled && setIsHovered(false)}
/>
{props.disabled && (
{isDisabled && (
<ToolTip id="tools-tooltip" place="top-middle">
This model does not support tool use
{isInEditMode
? "Tool use not supported in edit mode"
: "This model does not support tool use"}
</ToolTip>
)}
{!useTools && !props.disabled && (
{!useTools && !isDisabled && (
<ToolTip id="tools-tooltip" place="top-middle">
Enable tool usage
</ToolTip>
)}
{useTools && !props.disabled && (
{useTools && !isDisabled && (
<>
<span className="hidden align-top sm:flex">Tools</span>
@ -84,7 +90,7 @@ export default function ToolDropdown(props: ToolDropdownProps) {
onChange={() => {}}
as="div"
onClick={(e) => e.stopPropagation()}
disabled={props.disabled}
disabled={isDisabled}
>
{({ open }) => (
<>
@ -95,7 +101,7 @@ export default function ToolDropdown(props: ToolDropdownProps) {
setDropdownOpen(!isDropdownOpen);
}}
className="text-lightgray flex cursor-pointer items-center border-none bg-transparent px-0 outline-none"
aria-disabled={props.disabled}
aria-disabled={isDisabled}
>
<EllipsisHorizontalIcon className="h-3 w-3 cursor-pointer hover:brightness-125" />
</Listbox.Button>
@ -147,7 +153,7 @@ export default function ToolDropdown(props: ToolDropdownProps) {
/>
</div>
</div>
<div className="max-h-48 overflow-y-auto overflow-x-hidden">
<div className="max-h-48 overflow-y-auto overflow-x-hidden pr-2">
{availableTools.map((tool: any) => (
<Listbox.Option
key={tool.function.name}

View file

@ -257,7 +257,7 @@ const MentionList = forwardRef((props: MentionListProps, ref) => {
if (queryInputRef.current) {
queryInputRef.current.focus();
}
}, [querySubmenuItem]);
}, [querySubmenuItem, queryInputRef]);
const selectItem = (index: number) => {
const item = allItems[index];
@ -378,6 +378,9 @@ const MentionList = forwardRef((props: MentionListProps, ref) => {
<ItemsDiv>
{querySubmenuItem ? (
<QueryInput
onClick={(e) => {
e.stopPropagation();
}}
rows={1}
ref={queryInputRef}
placeholder={querySubmenuItem.description}
@ -436,7 +439,10 @@ const MentionList = forwardRef((props: MentionListProps, ref) => {
ref={(el) => (itemRefs.current[index] = el)}
className={`item cursor-pointer ${isSelected ? "is-selected" : ""}`}
key={index}
onClick={() => selectItem(index)}
onClick={(e) => {
e.stopPropagation();
selectItem(index);
}}
onMouseEnter={() => setSelectedIndex(index)}
data-testid="context-provider-dropdown-item"
>

View file

@ -591,11 +591,12 @@ function TipTapEditor(props: TipTapEditorProps) {
useEffect(() => {
if (editor) {
const handleFocus = () => {
debouncedShouldHideToolbar(false);
setShouldHideToolbar(false);
};
const handleBlur = () => {
debouncedShouldHideToolbar(true);
// TODO - make toolbar auto-hiding work without breaking tool dropdown focus
// debouncedShouldHideToolbar(true);
};
editor.on("focus", handleFocus);

View file

@ -53,7 +53,6 @@ type SessionState = {
streamAborter: AbortController;
codeToEdit: CodeToEdit[];
curCheckpointIndex: number;
currentMainEditorContent?: JSONContent;
mainEditorContentTrigger?: JSONContent | undefined;
symbols: FileSymbolMap;
mode: MessageModes;

View file

@ -33,9 +33,24 @@ const rootReducer = combineReducers({
const saveSubsetFilters = [
createFilter("session", [
"history",
"sessionId",
"selectedOrganizationId",
"selectedProfile",
"id",
"lastSessionId",
"title",
// Persist edit mode in case closes in middle
"mode",
"codeToEdit",
// TODO consider removing persisted profiles/orgs
"availableProfiles",
"organizations",
// higher risk to persist
// codeBlockApplyStates
// symbols
// curCheckpointIndex
]),
// Don't persist any of the edit state for now
createFilter("editModeState", []),

View file

@ -27,7 +27,10 @@ export const streamNormalInput = createAsyncThunk<
throw new Error("Default model not defined");
}
const includeTools = useTools && modelSupportsTools(defaultModel);
const includeTools =
useTools &&
modelSupportsTools(defaultModel) &&
state.session.mode === "chat";
// Send request
const gen = extra.ideMessenger.llmStreamChat(

View file

@ -1,6 +1,6 @@
{
"name": "@continuedev/config-yaml",
"version": "1.0.34",
"version": "1.0.35",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",

View file

@ -76,7 +76,7 @@ export function getLocationsToLook(
return locationsToLook;
}
export async function listAvailableSecrets(
export function listAvailableSecrets(
userSecretNames: string[],
orgSecretNames: string[],
assistantSecretNames: string[],
@ -84,7 +84,7 @@ export async function listAvailableSecrets(
assistantSlug: PackageSlug,
blockSlug: PackageSlug | undefined,
currentUserSlug: string,
): Promise<SecretLocation[]> {
): SecretLocation[] {
// Create a set of all secret names
const allSecretNames = new Set([
...userSecretNames,