From be88863c914d529959f599ba23f04c876f581181 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 14 Nov 2024 10:01:24 -0800 Subject: [PATCH 01/15] bunch of logs --- extensions/vscode/package-lock.json | 4 ++-- gui/src/redux/slices/stateSlice.ts | 28 ++++++++++++++++++++++++++++ gui/src/redux/slices/uiStateSlice.ts | 1 + 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 3f4123969..24930d980 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.228", + "version": "0.9.229", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.228", + "version": "0.9.229", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", diff --git a/gui/src/redux/slices/stateSlice.ts b/gui/src/redux/slices/stateSlice.ts index e3ce22eb6..f2cbe8dc9 100644 --- a/gui/src/redux/slices/stateSlice.ts +++ b/gui/src/redux/slices/stateSlice.ts @@ -83,6 +83,8 @@ export const stateSlice = createSlice({ state, { payload: config }: PayloadAction, ) => { + console.log("setConfig"); + const defaultModelTitle = config.models.find((model) => model.title === state.defaultModelTitle) ?.title || @@ -101,6 +103,8 @@ export const stateSlice = createSlice({ state, { payload }: PayloadAction, ) => { + console.log("addPromptCompletionPair"); + if (!state.history.length) { return; } @@ -139,11 +143,14 @@ export const stateSlice = createSlice({ contextItems: ChatHistoryItem["contextItems"]; }>, ) => { + console.log("setContextItemsAtIndex"); if (state.history[index]) { state.history[index].contextItems = contextItems; } }, addContextItems: (state, action: PayloadAction) => { + console.log("addContextItems"); + state.contextItems = state.contextItems.concat(action.payload); }, resubmitAtIndex: ( @@ -155,6 +162,8 @@ export const stateSlice = createSlice({ editorState: JSONContent; }>, ) => { + console.log("resubmitAtIndex"); + const historyItem = state.history[payload.index]; if (!historyItem) { return; @@ -188,6 +197,8 @@ export const stateSlice = createSlice({ editorState: JSONContent; }>, ) => { + console.log("initNewActiveMessage"); + state.history.push({ message: { role: "user", content: "", id: uuidv4() }, contextItems: state.contextItems, @@ -215,6 +226,7 @@ export const stateSlice = createSlice({ contextItems?: ContextItemWithId[]; }>, ) => { + console.log("setMessageAtIndex"); if (payload.index >= state.history.length) { state.history.push({ message: { ...payload.message, id: uuidv4() }, @@ -246,6 +258,8 @@ export const stateSlice = createSlice({ contextItems: ContextItemWithId[]; }>, ) => { + console.log("addContextItemsAtIndex"); + const historyItem = state.history[payload.index]; if (!historyItem) { return; @@ -257,6 +271,8 @@ export const stateSlice = createSlice({ state.active = false; }, streamUpdate: (state, action: PayloadAction) => { + console.log("streamUpdate"); + if (state.history.length) { state.history[state.history.length - 1].message.content += action.payload; @@ -267,6 +283,8 @@ export const stateSlice = createSlice({ { payload }: PayloadAction, ) => { if (payload) { + console.log("newSession"); + state.history = payload.history as any; state.title = payload.title; state.sessionId = payload.sessionId; @@ -285,6 +303,8 @@ export const stateSlice = createSlice({ payload, }: PayloadAction<{ ids: ContextItemId[]; index: number | undefined }>, ) => { + console.log("deleteContextWithIds"); + const getKey = (id: ContextItemId) => `${id.providerTitle}-${id.itemId}`; const ids = new Set(payload.ids.map(getKey)); @@ -304,6 +324,8 @@ export const stateSlice = createSlice({ payload, }: PayloadAction<{ rangeInFileWithContents: any; edit: boolean }>, ) => { + console.log("addHighlightedCode"); + let contextItems = [...state.contextItems].map((item) => { return { ...item, editing: false }; }); @@ -367,6 +389,8 @@ export const stateSlice = createSlice({ payload, }: PayloadAction<{ ids: ContextItemId[]; index: number | undefined }>, ) => { + console.log("setEditingAtIds"); + const ids = payload.ids.map((id) => id.itemId); if (typeof payload.index === "undefined") { @@ -403,6 +427,8 @@ export const stateSlice = createSlice({ state, { payload }: PayloadAction<{ title: string; force?: boolean }>, ) => { + console.log("setDefaultModel"); + const model = state.config.models.find( (model) => model.title === payload.title, ); @@ -413,6 +439,8 @@ export const stateSlice = createSlice({ }; }, setSelectedProfileId: (state, { payload }: PayloadAction) => { + console.log("setSelectedProfileId"); + return { ...state, selectedProfileId: payload, diff --git a/gui/src/redux/slices/uiStateSlice.ts b/gui/src/redux/slices/uiStateSlice.ts index 24c4fc194..385964881 100644 --- a/gui/src/redux/slices/uiStateSlice.ts +++ b/gui/src/redux/slices/uiStateSlice.ts @@ -58,6 +58,7 @@ export const uiStateSlice = createSlice({ state.nextCodeBlockToApplyIndex++; }, updateApplyState: (state, { payload }: PayloadAction) => { + console.log("updateApplyState"); const index = state.applyStates.findIndex( (applyState) => applyState.streamId === payload.streamId, ); From b614c43f8dc791e5a1358dfa77c0de0cc9d845bf Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 14 Nov 2024 11:44:41 -0800 Subject: [PATCH 02/15] warn users when maxTokens too close to contextLength --- core/config/validation.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/config/validation.ts b/core/config/validation.ts index ebcbb623d..062c0eaed 100644 --- a/core/config/validation.ts +++ b/core/config/validation.ts @@ -34,6 +34,18 @@ export function validateConfig(config: SerializedContinueConfig) { message: `Model at index ${index} has an invalid 'provider'.`, }); } + + if (model.contextLength && model.completionOptions?.maxTokens) { + const difference = + model.contextLength - model.completionOptions.maxTokens; + + if (difference < 1000) { + errors.push({ + fatal: false, + message: `Model "${model.title}" has a contextLength of ${model.contextLength} and a maxTokens of ${model.completionOptions.maxTokens}. This leaves only ${difference} tokens for input context and will likely result in your inputs being truncated.`, + }); + } + } }); } From 9b529c99341db92c60a52cb7cd724288cacded2f Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 14 Nov 2024 12:12:51 -0800 Subject: [PATCH 03/15] remove state.contextItems - items per history item --- .../mainInput/CodeBlockComponent.tsx | 7 +- .../components/mainInput/ContextItemsPeek.tsx | 1 - .../components/mainInput/ContinueInputBox.tsx | 1 + gui/src/components/mainInput/TipTapEditor.tsx | 19 +-- gui/src/components/mainInput/resolveInput.ts | 2 + .../markdown/StyledMarkdownPreview.tsx | 8 +- gui/src/hooks/useChatHandler.ts | 46 ++++--- gui/src/hooks/useSetup.ts | 23 ++-- gui/src/pages/gui/Chat.tsx | 2 +- gui/src/redux/slices/stateSlice.ts | 129 +----------------- gui/src/redux/store.ts | 7 +- 11 files changed, 56 insertions(+), 189 deletions(-) diff --git a/gui/src/components/mainInput/CodeBlockComponent.tsx b/gui/src/components/mainInput/CodeBlockComponent.tsx index 217fcc293..5d62c6d91 100644 --- a/gui/src/components/mainInput/CodeBlockComponent.tsx +++ b/gui/src/components/mainInput/CodeBlockComponent.tsx @@ -12,12 +12,11 @@ export const CodeBlockComponent = ({ editor, updateAttributes, }: any) => { - const dispatch = useDispatch(); const item: ContextItemWithId = node.attrs.item; - const contextItems = useSelector( - (state: RootState) => state.state.contextItems, - ); + // const contextItems = useSelector( + // (state: RootState) => state.state.history[0]?.contextItems[0]?.id, + // ); return ( diff --git a/gui/src/components/mainInput/TipTapEditor.tsx b/gui/src/components/mainInput/TipTapEditor.tsx index c2646415e..3353d4462 100644 --- a/gui/src/components/mainInput/TipTapEditor.tsx +++ b/gui/src/components/mainInput/TipTapEditor.tsx @@ -159,6 +159,7 @@ interface TipTapEditorProps { placeholder?: string; header?: React.ReactNode; historyKey: string; + contextItems?: ContextItemWithId[]; } function TipTapEditor(props: TipTapEditorProps) { @@ -222,10 +223,6 @@ function TipTapEditor(props: TipTapEditorProps) { inDropdownRef.current = true; }; - const contextItems = useSelector( - (store: RootState) => store.state.contextItems, - ); - const defaultModel = useSelector(defaultModelSelector); const defaultModelRef = useUpdatingRef(defaultModel); @@ -495,19 +492,7 @@ function TipTapEditor(props: TipTapEditorProps) { content: props.editorState || mainEditorContent || "", onFocus: () => setIsEditorFocused(true), onBlur: () => setIsEditorFocused(false), - onUpdate: ({ editor, transaction }) => { - // If /edit is typed and no context items are selected, select the first - - if (contextItems.length > 0) { - return; - } - - const json = editor.getJSON(); - let codeBlock = json.content?.find((el) => el.type === "codeBlock"); - if (!codeBlock) { - return; - } - }, + // onUpdate editable: !active || props.isMainInput, }); diff --git a/gui/src/components/mainInput/resolveInput.ts b/gui/src/components/mainInput/resolveInput.ts index 64acba85a..27df6e4aa 100644 --- a/gui/src/components/mainInput/resolveInput.ts +++ b/gui/src/components/mainInput/resolveInput.ts @@ -30,6 +30,7 @@ async function resolveEditorContent( ideMessenger: IIdeMessenger, defaultContextProviders: DefaultContextProvider[], ): Promise<[ContextItemWithId[], RangeInFile[], MessageContent]> { + console.log("resolve editor content start"); let parts: MessagePart[] = []; let contextItemAttrs: MentionAttrs[] = []; const selectedCode: RangeInFile[] = []; @@ -171,6 +172,7 @@ async function resolveEditorContent( parts = [{ type: "text", text: lastPart }]; } } + console.log("resolve editor content end"); return [contextItems, selectedCode, parts]; } diff --git a/gui/src/components/markdown/StyledMarkdownPreview.tsx b/gui/src/components/markdown/StyledMarkdownPreview.tsx index a86a295c9..64bcecd04 100644 --- a/gui/src/components/markdown/StyledMarkdownPreview.tsx +++ b/gui/src/components/markdown/StyledMarkdownPreview.tsx @@ -15,12 +15,13 @@ import { getFontSize, isJetBrains } from "../../util"; import "./katex.css"; import "./markdown.css"; import { useSelector } from "react-redux"; -import { memoizedContextItemsSelector } from "../../redux/slices/stateSlice"; import { ctxItemToRifWithContents } from "core/commands/util"; import FilenameLink from "./FilenameLink"; import StepContainerPreToolbar from "./StepContainerPreToolbar"; import { SyntaxHighlightedPre } from "./SyntaxHighlightedPre"; import StepContainerPreActionButtons from "./StepContainerPreActionButtons"; +import { RootState } from "../../redux/store"; +import { ContextItemWithId } from "core"; const StyledMarkdown = styled.div<{ fontSize?: number; @@ -93,6 +94,7 @@ interface StyledMarkdownPreviewProps { className?: string; isRenderingInStepContainer?: boolean; // Currently only used to control the rendering of codeblocks scrollLocked?: boolean; + contextItems?: ContextItemWithId[]; } const HLJS_LANGUAGE_CLASSNAME_PREFIX = "language-"; @@ -152,8 +154,6 @@ function processCodeBlocks(tree: any) { const StyledMarkdownPreview = memo(function StyledMarkdownPreview( props: StyledMarkdownPreviewProps, ) { - const contextItems = useSelector(memoizedContextItemsSelector); - const [reactContent, setMarkdownSource] = useRemark({ remarkPlugins: [remarkMath, () => processCodeBlocks], rehypePlugins: [ @@ -236,7 +236,7 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview( code: ({ node, ...codeProps }) => { const content = getCodeChildrenContent(codeProps.children); - const ctxItem = contextItems.find((ctxItem) => + const ctxItem = props.contextItems?.find((ctxItem) => ctxItem.uri?.value.includes(content), ); diff --git a/gui/src/hooks/useChatHandler.ts b/gui/src/hooks/useChatHandler.ts index 2e35acc53..229c03ebc 100644 --- a/gui/src/hooks/useChatHandler.ts +++ b/gui/src/hooks/useChatHandler.ts @@ -23,7 +23,6 @@ import resolveEditorContent, { import { IIdeMessenger } from "../context/IdeMessenger"; import { defaultModelSelector } from "../redux/selectors/modelSelectors"; import { - addContextItems, addPromptCompletionPair, clearLastResponse, initNewActiveMessage, @@ -50,10 +49,6 @@ function useChatHandler(dispatch: Dispatch, ideMessenger: IIdeMessenger) { (store: RootState) => store.state.config.slashCommands || [], ); - const contextItems = useSelector( - (state: RootState) => state.state.contextItems, - ); - const history = useSelector((store: RootState) => store.state.history); const active = useSelector((store: RootState) => store.state.active); const activeRef = useRef(active); @@ -226,26 +221,33 @@ function useChatHandler(dispatch: Dispatch, ideMessenger: IIdeMessenger) { .slice(0, 1000) .join("\n"); } - selectedContextItems.unshift({ - content: `The following file is currently open. Don't reference it if it's not relevant to the user's message.\n\n\`\`\`${getRelativePath( - currentFile.path, - await ideMessenger.ide.getWorkspaceDirs(), - )}\n${currentFileContents}\n\`\`\``, - name: `Active file: ${getBasename(currentFile.path)}`, - description: currentFile.path, - id: { - itemId: currentFile.path, - providerTitle: "file", - }, - uri: { - type: "file", - value: currentFile.path, - }, - }); + if ( + !selectedContextItems.find( + (item) => item.uri?.value === currentFile.path, + ) + ) { + // don't add the file if it's already in the context items + selectedContextItems.unshift({ + content: `The following file is currently open. Don't reference it if it's not relevant to the user's message.\n\n\`\`\`${getRelativePath( + currentFile.path, + await ideMessenger.ide.getWorkspaceDirs(), + )}\n${currentFileContents}\n\`\`\``, + name: `Active file: ${getBasename(currentFile.path)}`, + description: currentFile.path, + id: { + itemId: currentFile.path, + providerTitle: "file", + }, + uri: { + type: "file", + value: currentFile.path, + }, + }); + } } } - dispatch(addContextItems(contextItems)); + // dispatch(addContextItems(contextItems)); const message: ChatMessage = { role: "user", diff --git a/gui/src/hooks/useSetup.ts b/gui/src/hooks/useSetup.ts index 2fed805da..c7f2a2598 100644 --- a/gui/src/hooks/useSetup.ts +++ b/gui/src/hooks/useSetup.ts @@ -21,7 +21,7 @@ import useChatHandler from "./useChatHandler"; import { useWebviewListener } from "./useWebviewListener"; function useSetup(dispatch: Dispatch) { - const [configLoaded, setConfigLoaded] = useState(false); + // const [configLoaded, setConfigLoaded] = useState(false); const ideMessenger = useContext(IdeMessengerContext); @@ -36,7 +36,7 @@ function useSetup(dispatch: Dispatch) { const { config, profileId } = result.content; dispatch(setConfig(config)); dispatch(setSelectedProfileId(profileId)); - setConfigLoaded(true); + // setConfigLoaded(true); setLocalStorage("disableIndexing", config.disableIndexing || false); // Perform any actions needed with the config @@ -49,16 +49,16 @@ function useSetup(dispatch: Dispatch) { // Load config from the IDE useEffect(() => { loadConfig(); - const interval = setInterval(() => { - if (configLoaded) { - clearInterval(interval); - return; - } - loadConfig(); - }, 2_000); + // const interval = setInterval(() => { + // if (configLoaded) { + // clearInterval(interval); + // return; + // } + // loadConfig(); + // }, 2_000); - return () => clearInterval(interval); - }, [configLoaded]); + // return () => clearInterval(interval); + }, []); useEffect(() => { // Override persisted state @@ -116,6 +116,7 @@ function useSetup(dispatch: Dispatch) { }, 1000); useWebviewListener("configUpdate", async () => { + console.log("config update"); await loadConfig(); if (!isJetBrains && !getLocalStorage("disableIndexing")) { diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index 78bbcd262..6aaf38092 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -290,7 +290,7 @@ export function Chat() { setLocalStorage("mainTextEntryCounter", 1); } }, - [state.history, state.contextItems, defaultModel, state, streamResponse], + [state.history, defaultModel, state, streamResponse], ); useWebviewListener( diff --git a/gui/src/redux/slices/stateSlice.ts b/gui/src/redux/slices/stateSlice.ts index f2cbe8dc9..e1b22f8f7 100644 --- a/gui/src/redux/slices/stateSlice.ts +++ b/gui/src/redux/slices/stateSlice.ts @@ -15,16 +15,6 @@ import { createSelector } from "reselect"; import { v4 as uuidv4, v4 } from "uuid"; import { RootState } from "../store"; -export const memoizedContextItemsSelector = createSelector( - [(state: RootState) => state.state.history], - (history) => { - return history.reduce((acc, item) => { - acc.push(...item.contextItems); - return acc; - }, []); - }, -); - // We need this to handle reorderings (e.g. a mid-array deletion) of the messages array. // The proper fix is adding a UUID to all chat messages, but this is the temp workaround. type ChatHistoryItemWithMessageId = ChatHistoryItem & { @@ -33,7 +23,6 @@ type ChatHistoryItemWithMessageId = ChatHistoryItem & { type State = { history: ChatHistoryItemWithMessageId[]; - contextItems: ContextItemWithId[]; ttsActive: boolean; active: boolean; isGatheringContext: boolean; @@ -49,7 +38,6 @@ type State = { const initialState: State = { history: [], - contextItems: [], ttsActive: false, active: false, isGatheringContext: false, @@ -148,11 +136,6 @@ export const stateSlice = createSlice({ state.history[index].contextItems = contextItems; } }, - addContextItems: (state, action: PayloadAction) => { - console.log("addContextItems"); - - state.contextItems = state.contextItems.concat(action.payload); - }, resubmitAtIndex: ( state, { @@ -182,7 +165,6 @@ export const stateSlice = createSlice({ }); // https://github.com/continuedev/continue/pull/1021 - // state.contextItems = []; state.active = true; }, deleteMessage: (state, action: PayloadAction) => { @@ -201,7 +183,7 @@ export const stateSlice = createSlice({ state.history.push({ message: { role: "user", content: "", id: uuidv4() }, - contextItems: state.contextItems, + contextItems: [], editorState: payload.editorState, }); state.history.push({ @@ -212,8 +194,7 @@ export const stateSlice = createSlice({ }, contextItems: [], }); - // https://github.com/continuedev/continue/pull/1021 - // state.contextItems = []; + state.active = true; }, setMessageAtIndex: ( @@ -290,34 +271,12 @@ export const stateSlice = createSlice({ state.sessionId = payload.sessionId; } else { state.history = []; - state.contextItems = []; state.active = false; state.title = "New Session"; state.sessionId = v4(); state.isInMultifileEdit = false; } }, - deleteContextWithIds: ( - state, - { - payload, - }: PayloadAction<{ ids: ContextItemId[]; index: number | undefined }>, - ) => { - console.log("deleteContextWithIds"); - - const getKey = (id: ContextItemId) => `${id.providerTitle}-${id.itemId}`; - const ids = new Set(payload.ids.map(getKey)); - - if (payload.index === undefined) { - state.contextItems = state.contextItems.filter( - (item) => !ids.has(getKey(item.id)), - ); - } else { - state.history[payload.index].contextItems = state.history[ - payload.index - ].contextItems.filter((item) => !ids.has(getKey(item.id))); - } - }, addHighlightedCode: ( state, { @@ -325,47 +284,15 @@ export const stateSlice = createSlice({ }: PayloadAction<{ rangeInFileWithContents: any; edit: boolean }>, ) => { console.log("addHighlightedCode"); - - let contextItems = [...state.contextItems].map((item) => { + let contextItems = + state.history[state.history.length - 1].contextItems ?? []; + contextItems = contextItems.map((item) => { return { ...item, editing: false }; }); const base = payload.rangeInFileWithContents.filepath .split(/[\\/]/) .pop(); - // Merge if there is overlap - for (let i = 0; i < contextItems.length; i++) { - const item = contextItems[i]; - if (item.description === payload.rangeInFileWithContents.filepath) { - let newStart = payload.rangeInFileWithContents.range.start.line; - let newEnd = payload.rangeInFileWithContents.range.end.line; - let [oldStart, oldEnd] = item.name - .split("(")[1] - .split(")")[0] - .split("-") - .map((x: string) => parseInt(x) - 1); - if (newStart > oldEnd || newEnd < oldStart) { - continue; - } - const startLine = Math.min(newStart, oldStart); - const endLine = Math.max(newEnd, oldEnd); - - // const oldContents = item.content.split("\n"); - // const newContents = - // payload.rangeInFileWithContents.contents.split("\n"); - // const finalContents = []; - - contextItems[i] = { - ...item, - name: `${base} (${startLine + 1}-${endLine + 1})`, - content: payload.rangeInFileWithContents.contents, - editing: true, - editable: true, - }; - return { ...state, contextItems }; - } - } - const lineNums = `(${ payload.rangeInFileWithContents.range.start.line + 1 }-${payload.rangeInFileWithContents.range.end.line + 1})`; @@ -380,48 +307,7 @@ export const stateSlice = createSlice({ editing: true, editable: true, }); - - return { ...state, contextItems }; - }, - setEditingAtIds: ( - state, - { - payload, - }: PayloadAction<{ ids: ContextItemId[]; index: number | undefined }>, - ) => { - console.log("setEditingAtIds"); - - const ids = payload.ids.map((id) => id.itemId); - - if (typeof payload.index === "undefined") { - return { - ...state, - contextItems: state.contextItems.map((item) => { - return { - ...item, - editing: ids.includes(item.id.itemId), - }; - }), - }; - } else { - return { - ...state, - history: state.history.map((step, i) => { - if (i === payload.index) { - return { - ...step, - contextItems: step.contextItems.map((item) => { - return { - ...item, - editing: ids.includes(item.id.itemId), - }; - }), - }; - } - return step; - }), - }; - } + state.history[state.history.length - 1].contextItems = contextItems; }, setDefaultModel: ( state, @@ -454,15 +340,12 @@ export const stateSlice = createSlice({ export const { setContextItemsAtIndex, - addContextItems, addContextItemsAtIndex, setInactive, streamUpdate, newSession, - deleteContextWithIds, resubmitAtIndex, addHighlightedCode, - setEditingAtIds, setDefaultModel, setConfig, setConfigError, diff --git a/gui/src/redux/store.ts b/gui/src/redux/store.ts index a5d0313f4..221d275c9 100644 --- a/gui/src/redux/store.ts +++ b/gui/src/redux/store.ts @@ -40,12 +40,7 @@ const windowIDTransform = (windowID: string) => ); const saveSubsetFilters = [ - createFilter("state", [ - "history", - "contextItems", - "sessionId", - "defaultModelTitle", - ]), + createFilter("state", ["history", "sessionId", "defaultModelTitle"]), ]; const persistConfig = { From 14b406075cc0db5101c71e7ab42be896eb38428a Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 14 Nov 2024 12:20:37 -0800 Subject: [PATCH 04/15] enable images with azure provider --- core/llm/autodetect.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/llm/autodetect.ts b/core/llm/autodetect.ts index 17f104a52..bebb8ead1 100644 --- a/core/llm/autodetect.ts +++ b/core/llm/autodetect.ts @@ -49,7 +49,7 @@ const PROVIDER_HANDLES_TEMPLATING: ModelProvider[] = [ "mistral", "sambanova", "vertexai", - "watsonx" + "watsonx", ]; const PROVIDER_SUPPORTS_IMAGES: ModelProvider[] = [ @@ -63,7 +63,8 @@ const PROVIDER_SUPPORTS_IMAGES: ModelProvider[] = [ "sagemaker", "continue-proxy", "openrouter", - "vertexai" + "vertexai", + "azure", ]; const MODEL_SUPPORTS_IMAGES: string[] = [ @@ -121,7 +122,7 @@ const PARALLEL_PROVIDERS: ModelProvider[] = [ "together", "sambanova", "nebius", - "vertexai" + "vertexai", ]; function llmCanGenerateInParallel( From 00aaba64798ab33a2e4f2407b31fafe49ae62564 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 14 Nov 2024 12:25:33 -0800 Subject: [PATCH 05/15] pass contextItems around a bit more --- gui/src/components/gui/StepContainer.tsx | 1 + .../components/mainInput/CodeBlockComponent.tsx | 14 ++++++++------ .../components/markdown/CodeSnippetPreview.tsx | 1 + .../components/markdown/StyledMarkdownPreview.tsx | 15 ++++++++------- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/gui/src/components/gui/StepContainer.tsx b/gui/src/components/gui/StepContainer.tsx index 1eba7ee91..22523cfb2 100644 --- a/gui/src/components/gui/StepContainer.tsx +++ b/gui/src/components/gui/StepContainer.tsx @@ -105,6 +105,7 @@ function StepContainer(props: StepContainerProps) { )} diff --git a/gui/src/components/mainInput/CodeBlockComponent.tsx b/gui/src/components/mainInput/CodeBlockComponent.tsx index 5d62c6d91..80c1cec78 100644 --- a/gui/src/components/mainInput/CodeBlockComponent.tsx +++ b/gui/src/components/mainInput/CodeBlockComponent.tsx @@ -1,9 +1,9 @@ import { NodeViewWrapper } from "@tiptap/react"; import { ContextItemWithId } from "core"; -import { useDispatch, useSelector } from "react-redux"; import { vscBadgeBackground } from ".."; -import { RootState } from "../../redux/store"; import CodeSnippetPreview from "../markdown/CodeSnippetPreview"; +import { useSelector } from "react-redux"; +import { RootState } from "../../redux/store"; export const CodeBlockComponent = ({ node, @@ -13,15 +13,17 @@ export const CodeBlockComponent = ({ updateAttributes, }: any) => { const item: ContextItemWithId = node.attrs.item; + const contextItems = useSelector( + (store: RootState) => + store.state.history[store.state.history.length - 1].contextItems, + ); + const isFirstContextItem = item.id === contextItems[0].id; - // const contextItems = useSelector( - // (state: RootState) => state.state.history[0]?.contextItems[0]?.id, - // ); return ( diff --git a/gui/src/components/markdown/StyledMarkdownPreview.tsx b/gui/src/components/markdown/StyledMarkdownPreview.tsx index 64bcecd04..a3da04eb9 100644 --- a/gui/src/components/markdown/StyledMarkdownPreview.tsx +++ b/gui/src/components/markdown/StyledMarkdownPreview.tsx @@ -236,13 +236,14 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview( code: ({ node, ...codeProps }) => { const content = getCodeChildrenContent(codeProps.children); - const ctxItem = props.contextItems?.find((ctxItem) => - ctxItem.uri?.value.includes(content), - ); - - if (ctxItem) { - const rif = ctxItemToRifWithContents(ctxItem); - return ; + if (props.contextItems) { + const ctxItem = props.contextItems.find((ctxItem) => + ctxItem.uri?.value.includes(content), + ); + if (ctxItem) { + const rif = ctxItemToRifWithContents(ctxItem); + return ; + } } return {codeProps.children}; From 3e4580d9f9a2dfaf200abfb1b8cdbc99cad60a11 Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 14 Nov 2024 12:37:45 -0800 Subject: [PATCH 06/15] fix empty messages bug for all providers --- core/llm/countTokens.ts | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/core/llm/countTokens.ts b/core/llm/countTokens.ts index 7ae3da1b7..9b30ad4bc 100644 --- a/core/llm/countTokens.ts +++ b/core/llm/countTokens.ts @@ -323,6 +323,27 @@ function pruneChatHistory( return chatHistory; } +function messageIsEmpty(message: ChatMessage): boolean { + if (typeof message.content === "string") { + return message.content.trim() === ""; + } + if (Array.isArray(message.content)) { + return message.content.every( + (item) => !item.imageUrl && item.text?.trim() === "", + ); + } + return false; +} + +function addSpaceToAnyEmptyMessages(messages: ChatMessage[]): ChatMessage[] { + return messages.map((message) => { + if (messageIsEmpty(message)) { + message.content = " "; + } + return message; + }); +} + function compileChatMessages( modelName: string, msgs: ChatMessage[] | undefined, @@ -333,12 +354,14 @@ function compileChatMessages( functions: any[] | undefined = undefined, systemMessage: string | undefined = undefined, ): ChatMessage[] { - const msgsCopy = msgs + let msgsCopy = msgs ? msgs .map((msg) => ({ ...msg })) .filter((msg) => msg.content !== "" && msg.role !== "system") : []; + msgsCopy = addSpaceToAnyEmptyMessages(msgsCopy); + if (prompt) { const promptMsg: ChatMessage = { role: "user", From e595235584629ed214139dc328818e168200ce32 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 14 Nov 2024 13:30:20 -0800 Subject: [PATCH 07/15] state.contextItems --- .../mainInput/CodeBlockComponent.tsx | 12 +++----- gui/src/hooks/useSetup.ts | 29 ++++++++++--------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/gui/src/components/mainInput/CodeBlockComponent.tsx b/gui/src/components/mainInput/CodeBlockComponent.tsx index 80c1cec78..1ece03733 100644 --- a/gui/src/components/mainInput/CodeBlockComponent.tsx +++ b/gui/src/components/mainInput/CodeBlockComponent.tsx @@ -5,19 +5,15 @@ import CodeSnippetPreview from "../markdown/CodeSnippetPreview"; import { useSelector } from "react-redux"; import { RootState } from "../../redux/store"; -export const CodeBlockComponent = ({ - node, - deleteNode, - selected, - editor, - updateAttributes, -}: any) => { +export const CodeBlockComponent = (props: any) => { + const { node, deleteNode, selected, editor, updateAttributes } = props; const item: ContextItemWithId = node.attrs.item; const contextItems = useSelector( (store: RootState) => store.state.history[store.state.history.length - 1].contextItems, ); - const isFirstContextItem = item.id === contextItems[0].id; + const isFirstContextItem = item.id === contextItems[0]?.id; + // const isFirstContextItem = false; return ( diff --git a/gui/src/hooks/useSetup.ts b/gui/src/hooks/useSetup.ts index c7f2a2598..9bdc4d713 100644 --- a/gui/src/hooks/useSetup.ts +++ b/gui/src/hooks/useSetup.ts @@ -1,5 +1,5 @@ import { Dispatch } from "@reduxjs/toolkit"; -import { useContext, useEffect, useState } from "react"; +import { useCallback, useContext, useEffect, useRef, useState } from "react"; import { useSelector } from "react-redux"; import { VSC_THEME_COLOR_VARS } from "../components"; import { IdeMessengerContext } from "../context/IdeMessenger"; @@ -14,7 +14,7 @@ import { } from "../redux/slices/stateSlice"; import { RootState } from "../redux/store"; -import { debounce } from "lodash"; +import { debounce, initial } from "lodash"; import { isJetBrains } from "../util"; import { getLocalStorage, setLocalStorage } from "../util/localStorage"; import useChatHandler from "./useChatHandler"; @@ -25,7 +25,8 @@ function useSetup(dispatch: Dispatch) { const ideMessenger = useContext(IdeMessengerContext); - const loadConfig = async () => { + const initialConfigLoad = useRef(false); + const loadConfig = useCallback(async () => { const result = await ideMessenger.request( "config/getSerializedProfileInfo", undefined, @@ -36,7 +37,7 @@ function useSetup(dispatch: Dispatch) { const { config, profileId } = result.content; dispatch(setConfig(config)); dispatch(setSelectedProfileId(profileId)); - // setConfigLoaded(true); + initialConfigLoad.current = true; setLocalStorage("disableIndexing", config.disableIndexing || false); // Perform any actions needed with the config @@ -44,21 +45,21 @@ function useSetup(dispatch: Dispatch) { setLocalStorage("fontSize", config.ui.fontSize); document.body.style.fontSize = `${config.ui.fontSize}px`; } - }; + }, [dispatch, ideMessenger, initialConfigLoad]); // Load config from the IDE useEffect(() => { loadConfig(); - // const interval = setInterval(() => { - // if (configLoaded) { - // clearInterval(interval); - // return; - // } - // loadConfig(); - // }, 2_000); + const interval = setInterval(() => { + if (initialConfigLoad.current) { + clearInterval(interval); + return; + } + loadConfig(); + }, 2_000); - // return () => clearInterval(interval); - }, []); + return () => clearInterval(interval); + }, [initialConfigLoad]); useEffect(() => { // Override persisted state From 5bc757f783fd54cb14842bba665a7bbc8e11cb10 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 14 Nov 2024 13:57:01 -0800 Subject: [PATCH 08/15] minisearch --- gui/src/components/History/index.tsx | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/gui/src/components/History/index.tsx b/gui/src/components/History/index.tsx index 7ed525626..4aee636bd 100644 --- a/gui/src/components/History/index.tsx +++ b/gui/src/components/History/index.tsx @@ -46,13 +46,20 @@ export function History() { const fetchSessions = async () => { const sessions = await getHistory(); setSessions(sessions); - minisearch.addAll( - sessions.map((session) => ({ - title: session.title, - sessionId: session.sessionId, - id: session.sessionId, - })), - ); + + try { + // Consider adding just last session to existing instead of clearing/adding all + minisearch.removeAll(); + minisearch.addAll( + sessions.map((session) => ({ + title: session.title, + sessionId: session.sessionId, + id: session.sessionId, + })), + ); + } catch (e) { + console.log("error adding sessions to minisearch", e); + } }; fetchSessions(); }, [lastSessionId]); From fbbee8980ae2583e06255f2642122f647abc9ffa Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 14 Nov 2024 14:27:55 -0800 Subject: [PATCH 09/15] files --- .../mainInput/CodeBlockComponent.tsx | 12 +++++------ .../components/mainInput/ContinueInputBox.tsx | 1 - gui/src/components/mainInput/TipTapEditor.tsx | 1 - gui/src/components/mainInput/resolveInput.ts | 2 -- .../markdown/StyledMarkdownPreview.tsx | 2 -- gui/src/hooks/useSetup.ts | 3 +-- gui/src/redux/slices/stateSlice.ts | 21 ------------------- 7 files changed, 7 insertions(+), 35 deletions(-) diff --git a/gui/src/components/mainInput/CodeBlockComponent.tsx b/gui/src/components/mainInput/CodeBlockComponent.tsx index 1ece03733..20d700c63 100644 --- a/gui/src/components/mainInput/CodeBlockComponent.tsx +++ b/gui/src/components/mainInput/CodeBlockComponent.tsx @@ -8,12 +8,12 @@ import { RootState } from "../../redux/store"; export const CodeBlockComponent = (props: any) => { const { node, deleteNode, selected, editor, updateAttributes } = props; const item: ContextItemWithId = node.attrs.item; - const contextItems = useSelector( - (store: RootState) => - store.state.history[store.state.history.length - 1].contextItems, - ); - const isFirstContextItem = item.id === contextItems[0]?.id; - // const isFirstContextItem = false; + // const contextItems = useSelector( + // (store: RootState) => + // store.state.history[store.state.history.length - 1].contextItems, + // ); + // const isFirstContextItem = item.id === contextItems[0]?.id; + const isFirstContextItem = false; return ( diff --git a/gui/src/components/mainInput/ContinueInputBox.tsx b/gui/src/components/mainInput/ContinueInputBox.tsx index d4aedf0b1..c98a69403 100644 --- a/gui/src/components/mainInput/ContinueInputBox.tsx +++ b/gui/src/components/mainInput/ContinueInputBox.tsx @@ -140,7 +140,6 @@ function ContinueInputBox(props: ContinueInputBoxProps) { availableContextProviders={availableContextProviders ?? []} availableSlashCommands={availableSlashCommands} historyKey="chat" - contextItems={props.contextItems} /> diff --git a/gui/src/components/mainInput/TipTapEditor.tsx b/gui/src/components/mainInput/TipTapEditor.tsx index 3353d4462..e3e0feb2e 100644 --- a/gui/src/components/mainInput/TipTapEditor.tsx +++ b/gui/src/components/mainInput/TipTapEditor.tsx @@ -159,7 +159,6 @@ interface TipTapEditorProps { placeholder?: string; header?: React.ReactNode; historyKey: string; - contextItems?: ContextItemWithId[]; } function TipTapEditor(props: TipTapEditorProps) { diff --git a/gui/src/components/mainInput/resolveInput.ts b/gui/src/components/mainInput/resolveInput.ts index 27df6e4aa..64acba85a 100644 --- a/gui/src/components/mainInput/resolveInput.ts +++ b/gui/src/components/mainInput/resolveInput.ts @@ -30,7 +30,6 @@ async function resolveEditorContent( ideMessenger: IIdeMessenger, defaultContextProviders: DefaultContextProvider[], ): Promise<[ContextItemWithId[], RangeInFile[], MessageContent]> { - console.log("resolve editor content start"); let parts: MessagePart[] = []; let contextItemAttrs: MentionAttrs[] = []; const selectedCode: RangeInFile[] = []; @@ -172,7 +171,6 @@ async function resolveEditorContent( parts = [{ type: "text", text: lastPart }]; } } - console.log("resolve editor content end"); return [contextItems, selectedCode, parts]; } diff --git a/gui/src/components/markdown/StyledMarkdownPreview.tsx b/gui/src/components/markdown/StyledMarkdownPreview.tsx index a3da04eb9..cd87cb2cd 100644 --- a/gui/src/components/markdown/StyledMarkdownPreview.tsx +++ b/gui/src/components/markdown/StyledMarkdownPreview.tsx @@ -14,13 +14,11 @@ import { import { getFontSize, isJetBrains } from "../../util"; import "./katex.css"; import "./markdown.css"; -import { useSelector } from "react-redux"; import { ctxItemToRifWithContents } from "core/commands/util"; import FilenameLink from "./FilenameLink"; import StepContainerPreToolbar from "./StepContainerPreToolbar"; import { SyntaxHighlightedPre } from "./SyntaxHighlightedPre"; import StepContainerPreActionButtons from "./StepContainerPreActionButtons"; -import { RootState } from "../../redux/store"; import { ContextItemWithId } from "core"; const StyledMarkdown = styled.div<{ diff --git a/gui/src/hooks/useSetup.ts b/gui/src/hooks/useSetup.ts index 9bdc4d713..effe838dc 100644 --- a/gui/src/hooks/useSetup.ts +++ b/gui/src/hooks/useSetup.ts @@ -59,7 +59,7 @@ function useSetup(dispatch: Dispatch) { }, 2_000); return () => clearInterval(interval); - }, [initialConfigLoad]); + }, [initialConfigLoad, loadConfig]); useEffect(() => { // Override persisted state @@ -117,7 +117,6 @@ function useSetup(dispatch: Dispatch) { }, 1000); useWebviewListener("configUpdate", async () => { - console.log("config update"); await loadConfig(); if (!isJetBrains && !getLocalStorage("disableIndexing")) { diff --git a/gui/src/redux/slices/stateSlice.ts b/gui/src/redux/slices/stateSlice.ts index e1b22f8f7..4222b4693 100644 --- a/gui/src/redux/slices/stateSlice.ts +++ b/gui/src/redux/slices/stateSlice.ts @@ -71,8 +71,6 @@ export const stateSlice = createSlice({ state, { payload: config }: PayloadAction, ) => { - console.log("setConfig"); - const defaultModelTitle = config.models.find((model) => model.title === state.defaultModelTitle) ?.title || @@ -91,8 +89,6 @@ export const stateSlice = createSlice({ state, { payload }: PayloadAction, ) => { - console.log("addPromptCompletionPair"); - if (!state.history.length) { return; } @@ -131,7 +127,6 @@ export const stateSlice = createSlice({ contextItems: ChatHistoryItem["contextItems"]; }>, ) => { - console.log("setContextItemsAtIndex"); if (state.history[index]) { state.history[index].contextItems = contextItems; } @@ -145,8 +140,6 @@ export const stateSlice = createSlice({ editorState: JSONContent; }>, ) => { - console.log("resubmitAtIndex"); - const historyItem = state.history[payload.index]; if (!historyItem) { return; @@ -179,8 +172,6 @@ export const stateSlice = createSlice({ editorState: JSONContent; }>, ) => { - console.log("initNewActiveMessage"); - state.history.push({ message: { role: "user", content: "", id: uuidv4() }, contextItems: [], @@ -207,7 +198,6 @@ export const stateSlice = createSlice({ contextItems?: ContextItemWithId[]; }>, ) => { - console.log("setMessageAtIndex"); if (payload.index >= state.history.length) { state.history.push({ message: { ...payload.message, id: uuidv4() }, @@ -239,8 +229,6 @@ export const stateSlice = createSlice({ contextItems: ContextItemWithId[]; }>, ) => { - console.log("addContextItemsAtIndex"); - const historyItem = state.history[payload.index]; if (!historyItem) { return; @@ -252,8 +240,6 @@ export const stateSlice = createSlice({ state.active = false; }, streamUpdate: (state, action: PayloadAction) => { - console.log("streamUpdate"); - if (state.history.length) { state.history[state.history.length - 1].message.content += action.payload; @@ -264,8 +250,6 @@ export const stateSlice = createSlice({ { payload }: PayloadAction, ) => { if (payload) { - console.log("newSession"); - state.history = payload.history as any; state.title = payload.title; state.sessionId = payload.sessionId; @@ -283,7 +267,6 @@ export const stateSlice = createSlice({ payload, }: PayloadAction<{ rangeInFileWithContents: any; edit: boolean }>, ) => { - console.log("addHighlightedCode"); let contextItems = state.history[state.history.length - 1].contextItems ?? []; contextItems = contextItems.map((item) => { @@ -313,8 +296,6 @@ export const stateSlice = createSlice({ state, { payload }: PayloadAction<{ title: string; force?: boolean }>, ) => { - console.log("setDefaultModel"); - const model = state.config.models.find( (model) => model.title === payload.title, ); @@ -325,8 +306,6 @@ export const stateSlice = createSlice({ }; }, setSelectedProfileId: (state, { payload }: PayloadAction) => { - console.log("setSelectedProfileId"); - return { ...state, selectedProfileId: payload, From ef715a8e4def60037776b55a9acaf2f1dcc4b736 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 14 Nov 2024 14:46:30 -0800 Subject: [PATCH 10/15] remove state.contextItems cleanup --- gui/src/hooks/useSetup.ts | 4 +--- gui/src/redux/slices/uiStateSlice.ts | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/gui/src/hooks/useSetup.ts b/gui/src/hooks/useSetup.ts index effe838dc..b96c48ed2 100644 --- a/gui/src/hooks/useSetup.ts +++ b/gui/src/hooks/useSetup.ts @@ -14,15 +14,13 @@ import { } from "../redux/slices/stateSlice"; import { RootState } from "../redux/store"; -import { debounce, initial } from "lodash"; +import { debounce } from "lodash"; import { isJetBrains } from "../util"; import { getLocalStorage, setLocalStorage } from "../util/localStorage"; import useChatHandler from "./useChatHandler"; import { useWebviewListener } from "./useWebviewListener"; function useSetup(dispatch: Dispatch) { - // const [configLoaded, setConfigLoaded] = useState(false); - const ideMessenger = useContext(IdeMessengerContext); const initialConfigLoad = useRef(false); diff --git a/gui/src/redux/slices/uiStateSlice.ts b/gui/src/redux/slices/uiStateSlice.ts index 385964881..24c4fc194 100644 --- a/gui/src/redux/slices/uiStateSlice.ts +++ b/gui/src/redux/slices/uiStateSlice.ts @@ -58,7 +58,6 @@ export const uiStateSlice = createSlice({ state.nextCodeBlockToApplyIndex++; }, updateApplyState: (state, { payload }: PayloadAction) => { - console.log("updateApplyState"); const index = state.applyStates.findIndex( (applyState) => applyState.streamId === payload.streamId, ); From ffd2214ec18082ab88d3d07065448351d83a716f Mon Sep 17 00:00:00 2001 From: Test Date: Thu, 14 Nov 2024 17:03:01 -0800 Subject: [PATCH 11/15] Update handler.ts --- .../vscode/src/diff/vertical/handler.ts | 41 +++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/extensions/vscode/src/diff/vertical/handler.ts b/extensions/vscode/src/diff/vertical/handler.ts index 1ec5a60b6..f2bf20ef6 100644 --- a/extensions/vscode/src/diff/vertical/handler.ts +++ b/extensions/vscode/src/diff/vertical/handler.ts @@ -25,9 +25,12 @@ export class VerticalDiffHandler implements vscode.Disposable { private currentLineIndex: number; private cancelled = false; private newLinesAdded = 0; - private get diffBlocks() { - return this.editorToVerticalDiffCodeLens.get(this.filepath) || []; + private deletionBuffer: string[] = []; + private redDecorationManager: DecorationTypeRangeManager; + private get filepath() { + return this.editor.document.uri.fsPath; } + public insertedInCurrentBlock = 0; public get range(): vscode.Range { const startLine = Math.min(this.startLine, this.endLine); const endLine = Math.max(this.startLine, this.endLine); @@ -77,14 +80,6 @@ export class VerticalDiffHandler implements vscode.Disposable { this.disposables.push(disposable); } - private get filepath() { - return this.editor.document.uri.fsPath; - } - - private deletionBuffer: string[] = []; - private redDecorationManager: DecorationTypeRangeManager; - insertedInCurrentBlock = 0; - private async insertDeletionBuffer() { // Don't remove trailing whitespace line const totalDeletedContent = this.deletionBuffer.join("\n"); @@ -98,13 +93,15 @@ export class VerticalDiffHandler implements vscode.Disposable { } if (this.deletionBuffer.length || this.insertedInCurrentBlock > 0) { - this.diffBlocks.push({ + const blocks = this.editorToVerticalDiffCodeLens.get(this.filepath) || []; + + blocks.push({ start: this.currentLineIndex - this.insertedInCurrentBlock, numRed: this.deletionBuffer.length, numGreen: this.insertedInCurrentBlock, }); - this.editorToVerticalDiffCodeLens.set(this.filepath, this.diffBlocks); + this.editorToVerticalDiffCodeLens.set(this.filepath, blocks); } if (this.deletionBuffer.length === 0) { @@ -271,7 +268,10 @@ export class VerticalDiffHandler implements vscode.Disposable { }, ); - this.options.onStatusUpdate("closed", this.diffBlocks.length); + this.options.onStatusUpdate( + "closed", + this.editorToVerticalDiffCodeLens.get(this.filepath)?.length ?? 0, + ); this.cancelled = true; this.refreshCodeLens(); @@ -359,7 +359,10 @@ export class VerticalDiffHandler implements vscode.Disposable { this.refreshCodeLens(); - this.options.onStatusUpdate("done", this.diffBlocks.length); + this.options.onStatusUpdate( + "done", + this.editorToVerticalDiffCodeLens.get(this.filepath)?.length ?? 0, + ); // Reject on user typing // const listener = vscode.workspace.onDidChangeTextDocument((e) => { @@ -409,8 +412,11 @@ export class VerticalDiffHandler implements vscode.Disposable { // Shift the codelens objects this.shiftCodeLensObjects(startLine, offset); - const status = this.diffBlocks.length === 0 ? "closed" : undefined; - this.options.onStatusUpdate(status, this.diffBlocks.length); + const numDiffs = + this.editorToVerticalDiffCodeLens.get(this.filepath)?.length ?? 0; + + const status = numDiffs === 0 ? "closed" : undefined; + this.options.onStatusUpdate(status, numDiffs); } private shiftCodeLensObjects(startLine: number, offset: number) { @@ -450,6 +456,7 @@ export class VerticalDiffHandler implements vscode.Disposable { } public hasDiffForCurrentFile(): boolean { - return this.diffBlocks.length > 0; + const diffBlocks = this.editorToVerticalDiffCodeLens.get(this.filepath); + return diffBlocks !== undefined && diffBlocks.length > 0; } } From a7a50280833007e8f0a3d908e3dd7544a2557dcb Mon Sep 17 00:00:00 2001 From: Test Date: Thu, 14 Nov 2024 17:03:30 -0800 Subject: [PATCH 12/15] Update StepContainerPreToolbar.tsx --- .../StepContainerPreToolbar.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx index ac13c6d54..0fa57fd08 100644 --- a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx +++ b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx @@ -2,7 +2,7 @@ import { ChevronDownIcon } from "@heroicons/react/24/outline"; import { debounce } from "lodash"; import { useContext, useEffect, useRef, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; -import styled, { keyframes } from "styled-components"; +import styled, { css, keyframes } from "styled-components"; import { v4 as uuidv4 } from "uuid"; import { defaultBorderRadius, lightGray, vscEditorBackground } from "../.."; import { IdeMessengerContext } from "../../../context/IdeMessenger"; @@ -26,13 +26,18 @@ const fadeInAnimation = keyframes` } `; -const TopDiv = styled.div` +const TopDiv = styled.div<{ active?: boolean }>` outline: 1px solid rgba(153, 153, 152); outline-offset: -0.5px; border-radius: ${defaultBorderRadius}; margin-bottom: 8px !important; background-color: ${vscEditorBackground}; - animation: ${fadeInAnimation} 300ms ease-out forwards; + ${(props) => + props.active + ? "animation: none;" + : css` + animation: ${fadeInAnimation} 300ms ease-out forwards; + `} `; const ToolbarDiv = styled.div<{ isExpanded: boolean }>` @@ -67,6 +72,7 @@ export default function StepContainerPreToolbar( const isMultifileEdit = useSelector( (state: RootState) => state.state.isInMultifileEdit, ); + const active = useSelector((state: RootState) => state.state.active); const [isExpanded, setIsExpanded] = useState(isMultifileEdit ? false : true); const [codeBlockContent, setCodeBlockContent] = useState(""); const isChatActive = useSelector((state: RootState) => state.state.active); @@ -168,7 +174,7 @@ export default function StepContainerPreToolbar( } return ( - +
Date: Thu, 14 Nov 2024 20:32:57 -0800 Subject: [PATCH 13/15] docs for prompt files v2 --- .../docs/customize/deep-dives/prompt-files.md | 61 +++++-------------- 1 file changed, 15 insertions(+), 46 deletions(-) diff --git a/docs/docs/customize/deep-dives/prompt-files.md b/docs/docs/customize/deep-dives/prompt-files.md index 928e01543..91f3557ea 100644 --- a/docs/docs/customize/deep-dives/prompt-files.md +++ b/docs/docs/customize/deep-dives/prompt-files.md @@ -6,9 +6,9 @@ Prompt files provide a convenient way to standardize common patterns and share a ## Quick start -:::tip[Prompt library] + Below is a quick example of setting up a prompt file to write unit tests using Jest. @@ -17,31 +17,19 @@ Below is a quick example of setting up a prompt file to write unit tests using J 3. Write the following contents to `test.prompt` and save. ``` -temperature: 0.5 -maxTokens: 4096 +name: Rails Project +description: Information about this project --- - -You are an expert programmer - - -{{{ input }}} - -Write unit tests for the above selected code, following each of these instructions: -- Use `jest` -- Properly set up and tear down -- Include important edge cases -- The tests should be complete and sophisticated -- Give the tests just as chat output, don't edit any file -- Don't explain how to set up `jest` +Attached is a summary of the current Ruby on Rails application, including the @Gemfile and database schema in @db/schema.rb ``` Now to use this prompt, you can highlight code and use cmd/ctrl + L to select it in the Continue sidebar. -Then, type "/" to see the list of slash commands and choose the one called "test". Press enter and the LLM will respond given the instructions from your prompt file. +Then, type "@", select "Prompt files", and choose the one called "Rails Project". You can now ask any question as usual and the LLM will have the information from your .prompt file. ## Format -The format is inspired by [HumanLoops's .prompt file](https://docs.humanloop.com/docs/prompt-file-format), with additional templating to use context providers and built-in variables using [Handlebars syntax](https://handlebarsjs.com/guide/). +The format is inspired by [HumanLoops's .prompt file](https://docs.humanloop.com/docs/prompt-file-format), with additional templating to reference files, URLs, and context providers. :::info The current state of this format is experimental and subject to change @@ -51,38 +39,19 @@ The current state of this format is experimental and subject to change The "preamble" is everything above the `---` separator, and lets you specify model parameters. It uses YAML syntax and currently supports the following parameters: -- `name` -- `temperature` -- `topP` -- `topK` -- `minP` -- `presencePenalty` -- `frequencyPenalty` -- `mirostat` -- `stop` -- `maxTokens` -- `description` +- `name` - The display title +- `description` - The description you will see in the dropdown +- `version` - Can be either "1" (for legacy prompt files) or "2" (this is the default and does not need to be set) If you don't need any of these parameters, you can leave out the preamble and do not need to include the `---` separator. -### System message +### Context -To add a system message, start the body with `` tags like in the example above and place your system message inside. +Many [context provider](../context-providers.md) can be referenced by typing "@" followed by the name of the context provider. -### Built-in variables - -The following built-in variables are currently available: - -- `{{{ input }}}` - The full text from the input box in the sidebar that is sent along with the slash command -- `{{{ currentFile }}}` - The currently open file in your IDE -- `{{{ ./path/to/file.js }}}` - Any file can be directly referenced - -### Context providers - -Any [context provider](../context-providers.md) that you have added to your config can be referenced using the name of the context provider. Context providers that receive an input are also supported. - -- `{{{ terminal }}}` - The contents of the terminal -- `{{{ url "https://github.com/continuedev/continue" }}}` - The contents of a URL +- `@terminal` - The contents of the terminal +- `@https://github.com/continuedev/continue` - The contents of a URL +- `@src/index.ts` - The contents of a file ## Feedback From bfb56dd5dd940aee16f6a34d7eab0710673de5ca Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 15 Nov 2024 11:20:19 -0800 Subject: [PATCH 14/15] comment out scroll for now --- gui/src/pages/gui/Chat.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index 78bbcd262..7b9fda085 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -159,11 +159,11 @@ export function Chat() { if (active) snapToBottom(); }, [active, snapToBottom]); - useEffect(() => { - setTimeout(() => { - smoothScrollToBottom(); - }, 400); - }, [smoothScrollToBottom, state.sessionId]); + // useEffect(() => { + // setTimeout(() => { + // smoothScrollToBottom(); + // }, 400); + // }, [smoothScrollToBottom, state.sessionId]); useEffect(() => { // Cmd + Backspace to delete current step From 651f942e92e7f69acaa8c7385a93181e9cc7c594 Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 15 Nov 2024 12:22:38 -0800 Subject: [PATCH 15/15] throttle JSDOM parsing --- core/indexing/docs/DocsService.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/indexing/docs/DocsService.ts b/core/indexing/docs/DocsService.ts index 46fedf9d0..d97b92974 100644 --- a/core/indexing/docs/DocsService.ts +++ b/core/indexing/docs/DocsService.ts @@ -254,6 +254,8 @@ export default class DocsService { if (processedPages === maxKnownPages) { maxKnownPages *= 2; } + + await new Promise((resolve) => setTimeout(resolve, 50)); } void Telemetry.capture("docs_pages_crawled", {