Merge branch 'preview' of https://github.com/continuedev/continue into preview
This commit is contained in:
commit
7136d8aed1
11 changed files with 69 additions and 35 deletions
9
.vscode/settings.json
vendored
9
.vscode/settings.json
vendored
|
|
@ -5,5 +5,12 @@
|
|||
"python.autoComplete.extraPaths": [],
|
||||
"python.testing.pytestArgs": ["server"],
|
||||
"python.testing.unittestEnabled": false,
|
||||
"python.testing.pytestEnabled": true
|
||||
"python.testing.pytestEnabled": true,
|
||||
"terminal.integrated.defaultProfile.linux": "bash",
|
||||
"terminal.integrated.profiles.linux": {
|
||||
"bash": {
|
||||
"path": "bash",
|
||||
"args": ["-l"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
4
.vscode/tasks.json
vendored
4
.vscode/tasks.json
vendored
|
|
@ -121,7 +121,7 @@
|
|||
"type": "shell",
|
||||
"command": "npm",
|
||||
"options": {
|
||||
"cwd": "gui"
|
||||
"cwd": "${workspaceFolder}/gui"
|
||||
},
|
||||
"args": ["run", "dev"],
|
||||
"isBackground": true,
|
||||
|
|
@ -142,7 +142,7 @@
|
|||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
},
|
||||
//
|
||||
// esbuild for the core binary
|
||||
{
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ const autocompleteCache = AutocompleteLruCache.get();
|
|||
function formatExternalSnippet(
|
||||
filepath: string,
|
||||
snippet: string,
|
||||
language: AutocompleteLanguageInfo,
|
||||
language: AutocompleteLanguageInfo
|
||||
) {
|
||||
const comment = language.comment;
|
||||
const lines = [
|
||||
|
|
@ -78,8 +78,8 @@ export async function getTabCompletion(
|
|||
filepath: string,
|
||||
contents: string,
|
||||
cursorIndex: number,
|
||||
ide: IDE,
|
||||
) => Promise<AutocompleteSnippet[]>,
|
||||
ide: IDE
|
||||
) => Promise<AutocompleteSnippet[]>
|
||||
): Promise<AutocompleteOutcome | undefined> {
|
||||
const startTime = Date.now();
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ export async function getTabCompletion(
|
|||
filepath,
|
||||
fullPrefix + fullSuffix,
|
||||
fullPrefix.length,
|
||||
ide,
|
||||
ide
|
||||
),
|
||||
new Promise((resolve) => {
|
||||
setTimeout(() => resolve([]), 100);
|
||||
|
|
@ -155,7 +155,7 @@ export async function getTabCompletion(
|
|||
recentlyEditedRanges,
|
||||
recentlyEditedFiles,
|
||||
llm.model,
|
||||
extrasSnippets,
|
||||
extrasSnippets
|
||||
);
|
||||
|
||||
// Template prompt
|
||||
|
|
@ -172,7 +172,7 @@ export async function getTabCompletion(
|
|||
// Format snippets as comments and prepend to prefix
|
||||
const formattedSnippets = snippets
|
||||
.map((snippet) =>
|
||||
formatExternalSnippet(snippet.filepath, snippet.contents, lang),
|
||||
formatExternalSnippet(snippet.filepath, snippet.contents, lang)
|
||||
)
|
||||
.join("\n");
|
||||
if (formattedSnippets.length > 0) {
|
||||
|
|
@ -224,7 +224,7 @@ export async function getTabCompletion(
|
|||
raw: true,
|
||||
stop,
|
||||
}),
|
||||
multiline,
|
||||
multiline
|
||||
);
|
||||
|
||||
// LLM
|
||||
|
|
@ -241,13 +241,13 @@ export async function getTabCompletion(
|
|||
let chars = generatorWithCancellation();
|
||||
const gen2 = onlyWhitespaceAfterEndOfLine(
|
||||
noFirstCharNewline(chars),
|
||||
lang.endOfLine,
|
||||
lang.endOfLine
|
||||
);
|
||||
const lineGenerator = streamWithNewLines(
|
||||
avoidPathLine(
|
||||
stopAtRepeatingLines(stopAtLines(streamLines(gen2))),
|
||||
lang.comment,
|
||||
),
|
||||
lang.comment
|
||||
)
|
||||
);
|
||||
const finalGenerator = stopAtSimilarLine(lineGenerator, lineBelowCursor);
|
||||
for await (const update of finalGenerator) {
|
||||
|
|
@ -293,11 +293,11 @@ export class CompletionProvider {
|
|||
filepath: string,
|
||||
contents: string,
|
||||
cursorIndex: number,
|
||||
ide: IDE,
|
||||
) => Promise<AutocompleteSnippet[]>,
|
||||
ide: IDE
|
||||
) => Promise<AutocompleteSnippet[]>
|
||||
) {
|
||||
this.generatorReuseManager = new GeneratorReuseManager(
|
||||
this.onError.bind(this),
|
||||
this.onError.bind(this)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -347,7 +347,7 @@ export class CompletionProvider {
|
|||
|
||||
public async provideInlineCompletionItems(
|
||||
input: AutocompleteInput,
|
||||
token: AbortSignal | undefined,
|
||||
token: AbortSignal | undefined
|
||||
): Promise<AutocompleteOutcome | undefined> {
|
||||
// Create abort signal if not given
|
||||
if (!token) {
|
||||
|
|
@ -372,7 +372,7 @@ export class CompletionProvider {
|
|||
const lastUUID = await new Promise((resolve) =>
|
||||
setTimeout(() => {
|
||||
resolve(CompletionProvider.lastUUID);
|
||||
}, options.debounceDelay),
|
||||
}, options.debounceDelay)
|
||||
);
|
||||
if (uuid !== lastUUID) {
|
||||
return undefined;
|
||||
|
|
@ -402,7 +402,7 @@ export class CompletionProvider {
|
|||
this.ide,
|
||||
this.generatorReuseManager,
|
||||
input,
|
||||
this.getDefinitionsFromLsp,
|
||||
this.getDefinitionsFromLsp
|
||||
);
|
||||
const completion = outcome?.completion;
|
||||
|
||||
|
|
@ -434,6 +434,8 @@ export class CompletionProvider {
|
|||
this._logRejectionTimeouts.set(input.completionId, logRejectionTimeout);
|
||||
|
||||
return outcome;
|
||||
} catch (e: any) {
|
||||
this.onError(e);
|
||||
} finally {
|
||||
this._abortControllers.delete(input.completionId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,4 +137,7 @@ export const defaultConfigJetBrains: SerializedContinueConfig = {
|
|||
params: {},
|
||||
},
|
||||
],
|
||||
ui: {
|
||||
codeBlockToolbarPosition: "top",
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -319,6 +319,7 @@ function finalToBrowserConfig(
|
|||
disableSessionTitles: final.disableSessionTitles,
|
||||
userToken: final.userToken,
|
||||
embeddingsProvider: final.embeddingsProvider?.id,
|
||||
ui: final.ui,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
9
core/index.d.ts
vendored
9
core/index.d.ts
vendored
|
|
@ -624,6 +624,10 @@ export interface TabAutocompleteOptions {
|
|||
useOtherFiles: boolean;
|
||||
}
|
||||
|
||||
export interface ContinueUIConfig {
|
||||
codeBlockToolbarPosition?: "top" | "bottom";
|
||||
}
|
||||
|
||||
export interface SerializedContinueConfig {
|
||||
env?: string[];
|
||||
allowAnonymousTelemetry?: boolean;
|
||||
|
|
@ -639,6 +643,7 @@ export interface SerializedContinueConfig {
|
|||
embeddingsProvider?: EmbeddingsProviderDescription;
|
||||
tabAutocompleteModel?: ModelDescription;
|
||||
tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
|
||||
ui?: ContinueUIConfig;
|
||||
}
|
||||
|
||||
export type ConfigMergeType = "merge" | "overwrite";
|
||||
|
|
@ -677,6 +682,8 @@ export interface Config {
|
|||
tabAutocompleteModel?: CustomLLM | ModelDescription;
|
||||
/** Options for tab autocomplete */
|
||||
tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
|
||||
/** UI styles customization */
|
||||
ui?: ContinueUIConfig;
|
||||
}
|
||||
|
||||
export interface ContinueConfig {
|
||||
|
|
@ -692,6 +699,7 @@ export interface ContinueConfig {
|
|||
embeddingsProvider: EmbeddingsProvider;
|
||||
tabAutocompleteModel?: ILLM;
|
||||
tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
|
||||
ui?: ContinueUIConfig;
|
||||
}
|
||||
|
||||
export interface BrowserSerializedContinueConfig {
|
||||
|
|
@ -705,4 +713,5 @@ export interface BrowserSerializedContinueConfig {
|
|||
disableSessionTitles?: boolean;
|
||||
userToken?: string;
|
||||
embeddingsProvider?: string;
|
||||
ui?: ContinueUIConfig;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ export class ContinueCompletionProvider
|
|||
if (val === "Documentation") {
|
||||
vscode.env.openExternal(
|
||||
vscode.Uri.parse(
|
||||
"https://continue.dev/docs/walkthroughs/tab-autocomplete",
|
||||
),
|
||||
"https://continue.dev/docs/walkthroughs/tab-autocomplete"
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
@ -32,14 +32,14 @@ export class ContinueCompletionProvider
|
|||
constructor(
|
||||
private readonly configHandler: ConfigHandler,
|
||||
private readonly ide: IDE,
|
||||
private readonly tabAutocompleteModel: TabAutocompleteModel,
|
||||
private readonly tabAutocompleteModel: TabAutocompleteModel
|
||||
) {
|
||||
this.completionProvider = new CompletionProvider(
|
||||
this.configHandler,
|
||||
this.ide,
|
||||
this.tabAutocompleteModel.get.bind(this.tabAutocompleteModel),
|
||||
this.onError.bind(this),
|
||||
getDefinitionsFromLsp,
|
||||
getDefinitionsFromLsp
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ export class ContinueCompletionProvider
|
|||
document: vscode.TextDocument,
|
||||
position: vscode.Position,
|
||||
context: vscode.InlineCompletionContext,
|
||||
token: vscode.CancellationToken,
|
||||
token: vscode.CancellationToken
|
||||
//@ts-ignore
|
||||
): ProviderResult<InlineCompletionItem[] | InlineCompletionList> {
|
||||
const enableTabAutocomplete =
|
||||
|
|
@ -75,7 +75,7 @@ export class ContinueCompletionProvider
|
|||
const outcome =
|
||||
await this.completionProvider.provideInlineCompletionItems(
|
||||
input,
|
||||
signal,
|
||||
signal
|
||||
);
|
||||
|
||||
if (!outcome || !outcome.completion) {
|
||||
|
|
@ -100,17 +100,15 @@ export class ContinueCompletionProvider
|
|||
outcome.completion,
|
||||
new vscode.Range(
|
||||
position,
|
||||
position.translate(0, outcome.completion.length),
|
||||
position.translate(0, outcome.completion.length)
|
||||
),
|
||||
{
|
||||
title: "Log Autocomplete Outcome",
|
||||
command: "continue.logAutocompleteOutcome",
|
||||
arguments: [outcome, logRejectionTimeout],
|
||||
},
|
||||
}
|
||||
),
|
||||
];
|
||||
} catch (e: any) {
|
||||
this.onError(e);
|
||||
} finally {
|
||||
stopStatusBarLoading();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { FileEdit, RangeInFile, Thread } from "core";
|
||||
import path from "path";
|
||||
import * as vscode from "vscode";
|
||||
import { threadStopped } from "../debug/debug";
|
||||
import { VsCodeExtension } from "../extension/vscodeExtension";
|
||||
import {
|
||||
SuggestionRanges,
|
||||
|
|
@ -15,7 +16,6 @@ import {
|
|||
openEditorAndRevealRange,
|
||||
uriFromFilePath,
|
||||
} from "./vscode";
|
||||
import { threadStopped } from "../debug/debug";
|
||||
|
||||
const util = require("util");
|
||||
const asyncExec = util.promisify(require("child_process").exec);
|
||||
|
|
@ -298,7 +298,7 @@ export class VsCodeIdeUtils {
|
|||
|
||||
// Check first whether it's an open document
|
||||
const openTextDocument = vscode.workspace.textDocuments.find(
|
||||
(doc) => doc.uri.toString() === uri.toString(),
|
||||
(doc) => doc.uri.fsPath === uri.fsPath,
|
||||
);
|
||||
if (openTextDocument !== undefined) {
|
||||
return openTextDocument.getText();
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ const TopDiv = styled.div`
|
|||
z-index: 100;
|
||||
`;
|
||||
|
||||
const SecondDiv = styled.div`
|
||||
const SecondDiv = styled.div<{ bottom: boolean; }>`
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
${(props) => props.bottom ? "bottom: 1.2rem;" : "top: 4px;"}
|
||||
right: 4px;
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
|
|
@ -30,6 +30,7 @@ const SecondDiv = styled.div`
|
|||
|
||||
interface CodeBlockToolBarProps {
|
||||
text: string;
|
||||
bottom: boolean;
|
||||
}
|
||||
|
||||
function CodeBlockToolBar(props: CodeBlockToolBarProps) {
|
||||
|
|
@ -38,7 +39,7 @@ function CodeBlockToolBar(props: CodeBlockToolBarProps) {
|
|||
|
||||
return (
|
||||
<TopDiv>
|
||||
<SecondDiv>
|
||||
<SecondDiv bottom={props.bottom || false}>
|
||||
{isJetBrains() || (
|
||||
<HeaderButtonWithText
|
||||
text={applying ? "Applying..." : "Apply to current file"}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { debounce } from "lodash";
|
||||
import { useEffect, useState } from "react";
|
||||
import useUIConfig from "../../hooks/useUIConfig";
|
||||
import CodeBlockToolBar from "./CodeBlockToolbar";
|
||||
|
||||
function childToText(child: any) {
|
||||
|
|
@ -19,6 +20,9 @@ function childrenToText(children: any) {
|
|||
}
|
||||
|
||||
function PreWithToolbar(props: { children: any }) {
|
||||
const uiConfig = useUIConfig()
|
||||
const toolbarBottom = uiConfig?.codeBlockToolbarPosition == 'bottom';
|
||||
|
||||
const [hovering, setHovering] = useState(false);
|
||||
|
||||
const [copyValue, setCopyValue] = useState("");
|
||||
|
|
@ -42,8 +46,9 @@ function PreWithToolbar(props: { children: any }) {
|
|||
onMouseEnter={() => setHovering(true)}
|
||||
onMouseLeave={() => setHovering(false)}
|
||||
>
|
||||
{hovering && <CodeBlockToolBar text={copyValue}></CodeBlockToolBar>}
|
||||
{!toolbarBottom && hovering && <CodeBlockToolBar text={copyValue} bottom={toolbarBottom}></CodeBlockToolBar>}
|
||||
{props.children}
|
||||
{toolbarBottom && hovering && <CodeBlockToolBar text={copyValue} bottom={toolbarBottom}></CodeBlockToolBar>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
8
gui/src/hooks/useUIConfig.ts
Normal file
8
gui/src/hooks/useUIConfig.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import { useSelector } from 'react-redux';
|
||||
import { RootState } from '../redux/store';
|
||||
|
||||
function useUIConfig() {
|
||||
return useSelector((store: RootState) => store.state.config.ui);
|
||||
}
|
||||
|
||||
export default useUIConfig;
|
||||
Loading…
Add table
Reference in a new issue