remove the edit slash command

This commit is contained in:
Nate 2024-11-08 18:34:23 -08:00
parent 4068900036
commit bd612261f0
11 changed files with 26 additions and 234 deletions

View file

@ -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,

View file

@ -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",

View file

@ -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"
{

View file

@ -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"

View file

@ -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"

View file

@ -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}
/>
</NodeViewWrapper>
);

View file

@ -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,
};

View file

@ -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,
});

View file

@ -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}
>
<PreviewMarkdownHeader
className="flex justify-between cursor-pointer"
className="flex cursor-pointer justify-between"
onClick={() => {
if (props.item.id.providerTitle === "file") {
ideMessenger.post("showFile", {
@ -108,23 +99,10 @@ function CodeSnippetPreview(props: CodeSnippetPreviewProps) {
}}
>
<div className="flex items-center gap-1">
<FileIcon height="20px" width="20px" filename={props.item.name} />
<FileIcon height="16px" width="16px" filename={props.item.name} />
{props.item.name}
</div>
<div className="flex items-center gap-1">
{props.onEdit && (
<StyledHeaderButtonWithText
text="Edit"
onClick={(e) => {
e.stopPropagation();
e.preventDefault();
props.onEdit?.();
}}
{...(props.editing && { color: "#f0f4" })}
>
<PencilIcon width="1.1em" height="1.1em" />
</StyledHeaderButtonWithText>
)}
<ButtonWithTooltip
text="Delete"
onClick={(e) => {
@ -132,14 +110,14 @@ function CodeSnippetPreview(props: CodeSnippetPreviewProps) {
props.onDelete?.();
}}
>
<XMarkIcon width="1.1em" height="1.1em" />
<XMarkIcon width="1em" height="1em" />
</ButtonWithTooltip>
</div>
</PreviewMarkdownHeader>
<div
contentEditable={false}
className={
collapsed ? "max-h-[33vh] overflow-hidden m-0" : "overflow-auto m-0"
collapsed ? "m-0 max-h-[33vh] overflow-hidden" : "m-0 overflow-auto"
}
ref={codeBlockRef}
>
@ -153,7 +131,7 @@ function CodeSnippetPreview(props: CodeSnippetPreviewProps) {
{(codeBlockRef.current?.scrollHeight ?? 0) > MAX_PREVIEW_HEIGHT && (
<ButtonWithTooltip
className="bottom-1 right-2 absolute"
className="absolute bottom-1 right-2"
text={collapsed ? "Expand" : "Collapse"}
>
{collapsed ? (

View file

@ -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,

View file

@ -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<ContextItemWithId[]>) => {
state.contextItems = state.contextItems.concat(action.payload);
},
@ -462,7 +435,6 @@ export const {
addPromptCompletionPair,
setTTSActive,
setActive,
setEditingContextItemAtIndex,
initNewActiveMessage,
setMessageAtIndex,
clearLastResponse,