From bd612261f0e49885cd2c13fec4d710450e6ce359 Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 8 Nov 2024 18:34:23 -0800 Subject: [PATCH] remove the edit slash command --- core/commands/slash/index.ts | 6 +- core/config/default.ts | 16 ----- docs/docs/customize/slash-commands.md | 44 +++---------- docs/docs/reference.md | 6 +- .../constants/ServerConstants.kt | 8 --- .../mainInput/CodeBlockComponent.tsx | 63 +------------------ gui/src/components/mainInput/MentionList.tsx | 4 -- gui/src/components/mainInput/TipTapEditor.tsx | 32 ++-------- .../markdown/CodeSnippetPreview.tsx | 34 ++-------- gui/src/hooks/useChatHandler.ts | 15 +---- gui/src/redux/slices/stateSlice.ts | 32 +--------- 11 files changed, 26 insertions(+), 234 deletions(-) diff --git a/core/commands/slash/index.ts b/core/commands/slash/index.ts index f94c6ee05..18008e251 100644 --- a/core/commands/slash/index.ts +++ b/core/commands/slash/index.ts @@ -1,19 +1,15 @@ import GenerateTerminalCommand from "./cmd"; -import CommentSlashCommand from "./comment"; import CommitMessageCommand from "./commit"; import DraftIssueCommand from "./draftIssue"; -import EditSlashCommand from "./edit"; import HttpSlashCommand from "./http"; +import OnboardSlashCommand from "./onboard"; import ReviewMessageCommand from "./review"; import ShareSlashCommand from "./share"; -import OnboardSlashCommand from "./onboard"; export default [ DraftIssueCommand, ShareSlashCommand, GenerateTerminalCommand, - EditSlashCommand, - CommentSlashCommand, HttpSlashCommand, CommitMessageCommand, ReviewMessageCommand, diff --git a/core/config/default.ts b/core/config/default.ts index 814552e75..54f601b53 100644 --- a/core/config/default.ts +++ b/core/config/default.ts @@ -67,14 +67,6 @@ export const defaultContextProvidersJetBrains: ContextProviderWithParams[] = [ ]; export const defaultSlashCommandsVscode: SlashCommandDescription[] = [ - { - name: "edit", - description: "Edit selected code", - }, - { - name: "comment", - description: "Write comments for the selected code", - }, { name: "share", description: "Export the current chat session to markdown", @@ -90,14 +82,6 @@ export const defaultSlashCommandsVscode: SlashCommandDescription[] = [ ]; export const defaultSlashCommandsJetBrains = [ - { - name: "edit", - description: "Edit selected code", - }, - { - name: "comment", - description: "Write comments for the selected code", - }, { name: "share", description: "Export the current chat session to markdown", diff --git a/docs/docs/customize/slash-commands.md b/docs/docs/customize/slash-commands.md index 7c1d05ed9..96988e858 100644 --- a/docs/docs/customize/slash-commands.md +++ b/docs/docs/customize/slash-commands.md @@ -12,37 +12,7 @@ Slash commands are shortcuts that can be activated by typing '/' and selecting f To use any of the built-in slash commands, open `config.json` and add it to the `slashCommands` list. -### `/Edit` - -Select code with `ctrl/cmd + L` (VS Code) or `ctrl/cmd + J` (JetBrains), and then type `/Edit`, followed by instructions for the edit. Continue will stream the changes into a side-by-side diff editor. - -```json title="config.json" -{ - "slashCommands": [ - { - "name": "edit", - "description": "Edit highlighted code" - } - ] -} -``` - -### `/Comment` - -Comment works just like `/Edit`, except it will automatically prompt the LLM to comment the code. - -```json title="config.json" -{ - "slashCommands": [ - { - "name": "comment", - "description": "Write comments for the highlighted code" - } - ] -} -``` - -### `/Share` +### `/share` Generate a shareable markdown transcript of your current chat history. @@ -60,7 +30,7 @@ Generate a shareable markdown transcript of your current chat history. Use the `outputDir` parameter to specify where you want to the markdown file to be saved. -### `/Cmd` +### `/cmd` Generate a shell command from natural language and (only in VS Code) automatically paste it into the terminal. @@ -75,7 +45,7 @@ Generate a shell command from natural language and (only in VS Code) automatical } ``` -### `/Commit` +### `/commit` Shows the LLM your current git diff and asks it to generate a commit message. @@ -90,7 +60,7 @@ Shows the LLM your current git diff and asks it to generate a commit message. } ``` -### `/Http` +### `/http` Write a custom slash command at your own HTTP endpoint. Set 'url' in the params object for the endpoint you have setup. The endpoint should return a sequence of string updates, which will be streamed to the Continue sidebar. See our basic [FastAPI example](https://github.com/continuedev/continue/blob/74002369a5e435735b83278fb965e004ae38a97d/core/context/providers/context_provider_server.py#L34-L45) for reference. @@ -106,7 +76,7 @@ Write a custom slash command at your own HTTP endpoint. Set 'url' in the params } ``` -### `/Issue` +### `/issue` Describe the issue you'd like to generate, and Continue will turn into a well-formatted title and body, then give you a link to the draft so you can submit. Make sure to set the URL of the repository you want to generate issues for. @@ -122,9 +92,9 @@ Describe the issue you'd like to generate, and Continue will turn into a well-fo } ``` -### `/Onboard` +### `/onboard` -The Onboard slash command helps to familiarize yourself with a new project by analyzing the project structure, READMEs, and dependency files. It identifies key folders, explains their purpose, and highlights popular packages used. Additionally, it offers insights into the project's architecture. +The onboard slash command helps to familiarize yourself with a new project by analyzing the project structure, READMEs, and dependency files. It identifies key folders, explains their purpose, and highlights popular packages used. Additionally, it offers insights into the project's architecture. ```json title="config.json" { diff --git a/docs/docs/reference.md b/docs/docs/reference.md index 391273943..a78a9689b 100644 --- a/docs/docs/reference.md +++ b/docs/docs/reference.md @@ -267,7 +267,7 @@ Custom commands initiated by typing "/" in the sidebar. Commands include predefi **Properties:** -- `name`: The command name. Options include "issue", "share", "cmd", "edit", "comment", "http", "commit", and "review". +- `name`: The command name. Options include "issue", "share", "cmd", "http", "commit", and "review". - `description`: Brief description of the command. - `step`: (Deprecated) Used for built-in commands; set the name for pre-configured options. - `params`: Additional parameters to configure command behavior (command-specific - see code for command) @@ -281,10 +281,6 @@ Example: "name": "commit", "description": "Generate a commit message" }, - { - "name": "comment", - "description": "Write comments for the selected code" - }, { "name": "share", "description": "Export this session as markdown" diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/ServerConstants.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/ServerConstants.kt index cdcb58c18..5135dc87a 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/ServerConstants.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/ServerConstants.kt @@ -48,14 +48,6 @@ const val DEFAULT_CONFIG = } ], "slashCommands": [ - { - "name": "edit", - "description": "Edit selected code" - }, - { - "name": "comment", - "description": "Write comments for the selected code" - }, { "name": "share", "description": "Export the current chat session to markdown" diff --git a/gui/src/components/mainInput/CodeBlockComponent.tsx b/gui/src/components/mainInput/CodeBlockComponent.tsx index 3c0ba951f..217fcc293 100644 --- a/gui/src/components/mainInput/CodeBlockComponent.tsx +++ b/gui/src/components/mainInput/CodeBlockComponent.tsx @@ -2,7 +2,6 @@ import { NodeViewWrapper } from "@tiptap/react"; import { ContextItemWithId } from "core"; import { useDispatch, useSelector } from "react-redux"; import { vscBadgeBackground } from ".."; -import { setEditingContextItemAtIndex } from "../../redux/slices/stateSlice"; import { RootState } from "../../redux/store"; import CodeSnippetPreview from "../markdown/CodeSnippetPreview"; @@ -26,71 +25,13 @@ export const CodeBlockComponent = ({ item.id === contextItems[0]?.id ? "#d0d" : selected - ? vscBadgeBackground - : undefined + ? vscBadgeBackground + : undefined } item={item} onDelete={() => { deleteNode(); }} - onEdit={async () => { - dispatch(setEditingContextItemAtIndex({ item })); - if (item.id === contextItems[0]?.id) { - // Find and delete the /edit command - let index = 0; - for (const el of editor.getJSON().content) { - if (el.type === "slashcommand") { - if (el.attrs.id === "/edit") { - editor - .chain() - .deleteRange({ from: index, to: index + 2 }) - .focus("end") - .run(); - break; - } - } - index += 1; - } - - updateAttributes({ - item: { - ...item, - editing: false, - }, - }); - } else { - let index = 0; - for (const el of editor.getJSON().content) { - if (el.type === "codeBlock") { - index += 2; - } else { - break; - } - } - editor - .chain() - .focus("end") - .insertContent([ - { - type: "slashcommand", - attrs: { id: "/edit", label: "/edit" }, - }, - { type: "text", text: " " }, - ]) - .run(); - - updateAttributes({ - item: { - ...item, - editing: true, - }, - }); - - await new Promise((resolve) => setTimeout(resolve, 100)); - editor.commands.focus("end"); - } - }} - editing={item.id === contextItems[0]?.id} /> ); diff --git a/gui/src/components/mainInput/MentionList.tsx b/gui/src/components/mainInput/MentionList.tsx index 62dfdf1de..6416771d9 100644 --- a/gui/src/components/mainInput/MentionList.tsx +++ b/gui/src/components/mainInput/MentionList.tsx @@ -12,9 +12,7 @@ import { FolderIcon, FolderOpenIcon, GlobeAltIcon, - HashtagIcon, MagnifyingGlassIcon, - PencilIcon, PlusIcon, SparklesIcon, TrashIcon, @@ -66,9 +64,7 @@ const ICONS_FOR_DROPDOWN: { [key: string]: any } = { web: GlobeAltIcon, "prompt-files": DocumentTextIcon, "repo-map": FolderIcon, - "/edit": PencilIcon, "/clear": TrashIcon, - "/comment": HashtagIcon, "/share": ArrowUpOnSquareIcon, "/cmd": CommandLineIcon, }; diff --git a/gui/src/components/mainInput/TipTapEditor.tsx b/gui/src/components/mainInput/TipTapEditor.tsx index 2ef4db920..631f59824 100644 --- a/gui/src/components/mainInput/TipTapEditor.tsx +++ b/gui/src/components/mainInput/TipTapEditor.tsx @@ -44,17 +44,12 @@ import useUpdatingRef from "../../hooks/useUpdatingRef"; import { useWebviewListener } from "../../hooks/useWebviewListener"; import { selectUseActiveFile } from "../../redux/selectors"; import { defaultModelSelector } from "../../redux/selectors/modelSelectors"; -import { setEditingContextItemAtIndex } from "../../redux/slices/stateSlice"; import { RootState } from "../../redux/store"; import { getFontSize, isJetBrains, isMetaEquivalentKeyPressed, } from "../../util"; -import { - handleJetBrainsMetaKeyPress, - handleMetaKeyPress, -} from "./handleMetaKeyPress"; import { CodeBlockExtension } from "./CodeBlockExtension"; import { SlashCommand } from "./CommandsExtension"; import InputToolbar, { ToolbarOptions } from "./InputToolbar"; @@ -64,6 +59,10 @@ import { getContextProviderDropdownOptions, getSlashCommandDropdownOptions, } from "./getSuggestion"; +import { + handleJetBrainsMetaKeyPress, + handleMetaKeyPress, +} from "./handleMetaKeyPress"; import { ComboBoxItem } from "./types"; const InputBoxDiv = styled.div<{ border?: string }>` @@ -508,29 +507,6 @@ function TipTapEditor(props: TipTapEditorProps) { if (!codeBlock) { return; } - - // Search for slashcommand type - for (const p of json.content) { - if ( - p.type !== "paragraph" || - !p.content || - typeof p.content === "string" - ) { - continue; - } - for (const node of p.content) { - if ( - node.type === "slashcommand" && - ["/edit", "/comment"].includes(node.attrs.label) - ) { - // Update context items - dispatch( - setEditingContextItemAtIndex({ item: codeBlock.attrs.item }), - ); - return; - } - } - } }, editable: !active, }); diff --git a/gui/src/components/markdown/CodeSnippetPreview.tsx b/gui/src/components/markdown/CodeSnippetPreview.tsx index 2a7b6d970..5794b6781 100644 --- a/gui/src/components/markdown/CodeSnippetPreview.tsx +++ b/gui/src/components/markdown/CodeSnippetPreview.tsx @@ -1,7 +1,6 @@ import { ChevronDownIcon, ChevronUpIcon, - PencilIcon, XMarkIcon, } from "@heroicons/react/24/outline"; import { ContextItemWithId } from "core"; @@ -36,7 +35,7 @@ const PreviewMarkdownHeader = styled.div` padding: 2px 6px; border-bottom: 0.5px solid ${lightGray}; word-break: break-all; - font-size: ${getFontSize() - 2}px; + font-size: ${getFontSize() - 3}px; display: flex; align-items: center; `; @@ -44,17 +43,9 @@ const PreviewMarkdownHeader = styled.div` interface CodeSnippetPreviewProps { item: ContextItemWithId; onDelete?: () => void; - onEdit?: () => void; borderColor?: string; - editing?: boolean; } -const StyledHeaderButtonWithText = styled(ButtonWithTooltip)<{ - color?: string; -}>` - ${(props) => props.color && `background-color: ${props.color};`} -`; - const MAX_PREVIEW_HEIGHT = 300; // Pre-compile the regular expression outside of the function @@ -83,7 +74,7 @@ function CodeSnippetPreview(props: CodeSnippetPreviewProps) { borderColor={props.borderColor} > { if (props.item.id.providerTitle === "file") { ideMessenger.post("showFile", { @@ -108,23 +99,10 @@ function CodeSnippetPreview(props: CodeSnippetPreviewProps) { }} >
- + {props.item.name}
- {props.onEdit && ( - { - e.stopPropagation(); - e.preventDefault(); - props.onEdit?.(); - }} - {...(props.editing && { color: "#f0f4" })} - > - - - )} { @@ -132,14 +110,14 @@ function CodeSnippetPreview(props: CodeSnippetPreviewProps) { props.onDelete?.(); }} > - +
@@ -153,7 +131,7 @@ function CodeSnippetPreview(props: CodeSnippetPreviewProps) { {(codeBlockRef.current?.scrollHeight ?? 0) > MAX_PREVIEW_HEIGHT && ( {collapsed ? ( diff --git a/gui/src/hooks/useChatHandler.ts b/gui/src/hooks/useChatHandler.ts index c90c044dc..5cd469c87 100644 --- a/gui/src/hooks/useChatHandler.ts +++ b/gui/src/hooks/useChatHandler.ts @@ -57,13 +57,12 @@ function useChatHandler(dispatch: Dispatch, ideMessenger: IIdeMessenger) { const active = useSelector((store: RootState) => store.state.active); const activeRef = useRef(active); - const {saveSession} = useHistory(dispatch); + const { saveSession } = useHistory(dispatch); const [save, triggerSave] = useState(false); useEffect(() => { saveSession(false); }, [save]); - useEffect(() => { activeRef.current = active; @@ -219,9 +218,8 @@ function useChatHandler(dispatch: Dispatch, ideMessenger: IIdeMessenger) { const currentFilePath = await ideMessenger.ide.getCurrentFile(); if (typeof currentFilePath === "string") { - let currentFileContents = await ideMessenger.ide.readFile( - currentFilePath, - ); + let currentFileContents = + await ideMessenger.ide.readFile(currentFilePath); if (usingFreeTrial) { currentFileContents = currentFileContents .split("\n") @@ -294,13 +292,6 @@ function useChatHandler(dispatch: Dispatch, ideMessenger: IIdeMessenger) { params: {}, }); - // For edit and comment slash commands, including the selected code in the context from store and for other commands, including the selected context alone - if (slashCommand.name === "edit" || slashCommand.name === "comment") { - updatedContextItems = [...contextItems]; - } else { - updatedContextItems = [...selectedContextItems]; - } - await _streamSlashCommand( messages, slashCommand, diff --git a/gui/src/redux/slices/stateSlice.ts b/gui/src/redux/slices/stateSlice.ts index c22d4bb1b..0e41fd26e 100644 --- a/gui/src/redux/slices/stateSlice.ts +++ b/gui/src/redux/slices/stateSlice.ts @@ -1,7 +1,6 @@ import { PayloadAction, createSlice } from "@reduxjs/toolkit"; import { JSONContent } from "@tiptap/react"; import { - ChatHistory, ChatHistoryItem, ChatMessage, ContextItemId, @@ -10,12 +9,11 @@ import { PromptLog, } from "core"; import { BrowserSerializedContinueConfig } from "core/config/load"; +import { ConfigValidationError } from "core/config/validation"; import { stripImages } from "core/llm/images"; import { createSelector } from "reselect"; -import { v4 } from "uuid"; +import { v4 as uuidv4, v4 } from "uuid"; import { RootState } from "../store"; -import { v4 as uuidv4 } from "uuid"; -import { ConfigValidationError } from "core/config/validation"; export const memoizedContextItemsSelector = createSelector( [(state: RootState) => state.state.history], @@ -57,14 +55,6 @@ const initialState: State = { configError: undefined, config: { slashCommands: [ - { - name: "edit", - description: "Edit selected code", - }, - { - name: "comment", - description: "Write comments for the selected code", - }, { name: "share", description: "Export the current chat session to markdown", @@ -151,23 +141,6 @@ export const stateSlice = createSlice({ state.history[index].contextItems = contextItems; } }, - setEditingContextItemAtIndex: ( - state, - { - payload: { index, item }, - }: PayloadAction<{ index?: number; item: ContextItemWithId }>, - ) => { - if (index === undefined) { - const isFirstContextItem = - state.contextItems[0]?.id.itemId === item.id.itemId; - - state.contextItems = isFirstContextItem - ? [] - : [{ ...item, editing: true }]; - return; - } - // TODO - }, addContextItems: (state, action: PayloadAction) => { state.contextItems = state.contextItems.concat(action.payload); }, @@ -462,7 +435,6 @@ export const { addPromptCompletionPair, setTTSActive, setActive, - setEditingContextItemAtIndex, initNewActiveMessage, setMessageAtIndex, clearLastResponse,