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 <noreply@continue.dev>

* fix: edit slash command sources

---------

Co-authored-by: Continue Agent <agent@continue.dev>
Co-authored-by: Continue <noreply@continue.dev>
Co-authored-by: Dallin Romney <dallinromney@gmail.com>
This commit is contained in:
continue[bot] 2025-09-26 11:31:09 -07:00 • committed by GitHub
parent b64b7e8c02
commit d006cbda8e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 26 additions and 3 deletions

View file

@ -1,5 +1,10 @@
import { Editor, JSONContent } from "@tiptap/react";
import { ContextItemWithId, InputModifiers, RuleWithSource } from "core";
import {
ContextItemWithId,
InputModifiers,
RuleWithSource,
SlashCommandSource,
} from "core";
import { memo, useMemo } from "react";
import { defaultBorderRadius, vscBackground } from "..";
import { useAppSelector } from "../../redux/hooks";
@ -38,6 +43,15 @@ const EDIT_DISALLOWED_CONTEXT_PROVIDERS = [
"repo-map",
];
const EDIT_ALLOWED_SLASH_COMMAND_SOURCES: SlashCommandSource[] = [
"yaml-prompt-block",
"mcp-prompt",
"prompt-file-v1",
"prompt-file-v2",
"invokable-rule",
"json-custom-command",
];
function ContinueInputBox(props: ContinueInputBoxProps) {
const isStreaming = useAppSelector((state) => state.session.isStreaming);
const availableSlashCommands = useAppSelector(
@ -50,7 +64,14 @@ function ContinueInputBox(props: ContinueInputBoxProps) {
const editModeState = useAppSelector((state) => state.editModeState);
const filteredSlashCommands = useMemo(() => {
return isInEdit ? [] : availableSlashCommands;
if (isInEdit) {
return availableSlashCommands.filter((cmd) =>
cmd.slashCommandSource
? EDIT_ALLOWED_SLASH_COMMAND_SOURCES.includes(cmd.slashCommandSource)
: false,
);
}
return availableSlashCommands;
}, [isInEdit, availableSlashCommands]);
const filteredContextProviders = useMemo(() => {

View file

@ -1,4 +1,4 @@
import { ContextProviderDescription } from "core";
import { ContextProviderDescription, SlashCommandSource } from "core";
export type ComboBoxItemType =
| "contextProvider"
@ -26,4 +26,5 @@ export interface ComboBoxItem {
icon?: string;
action?: () => void;
subActions?: ComboBoxSubAction[];
slashCommandSource?: SlashCommandSource;
}

View file

@ -22,6 +22,7 @@ export const selectSlashCommandComboBoxInputs = createSelector(
description: cmd.description,
type: "slashCommand" as ComboBoxItemType,
content: content,
source: cmd.source,
} as ComboBoxItem;
}) || []
);