Skip to content

Commit d006cbd

Browse files
continue[bot]sestinjContinueRomneyDa
authored
fix: Enable prompt-based slash commands in Edit mode while filtering out built-in legacy commands (#7907)
* fix: Enable prompt-based slash commands in Edit mode while filtering out built-in legacy commands - Add source property to ComboBoxItem interface to track command origin - Update selector to include source in slash command data - Implement whitelist-based filtering for Edit mode: - Allow: yaml-prompt-block, mcp-prompt, prompt-file-v1/v2, invokable-rule - Filter out: built-in-legacy commands like /commit, /share, etc. - Replace complete removal of slash commands with selective filtering Generated with [Continue](https://continue.dev) Co-Authored-By: Continue <[email protected]> * fix: edit slash command sources --------- Co-authored-by: Continue Agent <[email protected]> Co-authored-by: Continue <[email protected]> Co-authored-by: Dallin Romney <[email protected]>
1 parent b64b7e8 commit d006cbd

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

gui/src/components/mainInput/ContinueInputBox.tsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { Editor, JSONContent } from "@tiptap/react";
2-
import { ContextItemWithId, InputModifiers, RuleWithSource } from "core";
2+
import {
3+
ContextItemWithId,
4+
InputModifiers,
5+
RuleWithSource,
6+
SlashCommandSource,
7+
} from "core";
38
import { memo, useMemo } from "react";
49
import { defaultBorderRadius, vscBackground } from "..";
510
import { useAppSelector } from "../../redux/hooks";
@@ -38,6 +43,15 @@ const EDIT_DISALLOWED_CONTEXT_PROVIDERS = [
3843
"repo-map",
3944
];
4045

46+
const EDIT_ALLOWED_SLASH_COMMAND_SOURCES: SlashCommandSource[] = [
47+
"yaml-prompt-block",
48+
"mcp-prompt",
49+
"prompt-file-v1",
50+
"prompt-file-v2",
51+
"invokable-rule",
52+
"json-custom-command",
53+
];
54+
4155
function ContinueInputBox(props: ContinueInputBoxProps) {
4256
const isStreaming = useAppSelector((state) => state.session.isStreaming);
4357
const availableSlashCommands = useAppSelector(
@@ -50,7 +64,14 @@ function ContinueInputBox(props: ContinueInputBoxProps) {
5064
const editModeState = useAppSelector((state) => state.editModeState);
5165

5266
const filteredSlashCommands = useMemo(() => {
53-
return isInEdit ? [] : availableSlashCommands;
67+
if (isInEdit) {
68+
return availableSlashCommands.filter((cmd) =>
69+
cmd.slashCommandSource
70+
? EDIT_ALLOWED_SLASH_COMMAND_SOURCES.includes(cmd.slashCommandSource)
71+
: false,
72+
);
73+
}
74+
return availableSlashCommands;
5475
}, [isInEdit, availableSlashCommands]);
5576

5677
const filteredContextProviders = useMemo(() => {

gui/src/components/mainInput/types.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ContextProviderDescription } from "core";
1+
import { ContextProviderDescription, SlashCommandSource } from "core";
22

33
export type ComboBoxItemType =
44
| "contextProvider"
@@ -26,4 +26,5 @@ export interface ComboBoxItem {
2626
icon?: string;
2727
action?: () => void;
2828
subActions?: ComboBoxSubAction[];
29+
slashCommandSource?: SlashCommandSource;
2930
}

gui/src/redux/selectors/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const selectSlashCommandComboBoxInputs = createSelector(
2222
description: cmd.description,
2323
type: "slashCommand" as ComboBoxItemType,
2424
content: content,
25+
source: cmd.source,
2526
} as ComboBoxItem;
2627
}) || []
2728
);

0 commit comments

Comments
 (0)