Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions gui/src/components/mainInput/ContinueInputBox.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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(
Expand All @@ -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(() => {
Expand Down
3 changes: 2 additions & 1 deletion gui/src/components/mainInput/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ContextProviderDescription } from "core";
import { ContextProviderDescription, SlashCommandSource } from "core";

export type ComboBoxItemType =
| "contextProvider"
Expand Down Expand Up @@ -26,4 +26,5 @@ export interface ComboBoxItem {
icon?: string;
action?: () => void;
subActions?: ComboBoxSubAction[];
slashCommandSource?: SlashCommandSource;
}
1 change: 1 addition & 0 deletions gui/src/redux/selectors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const selectSlashCommandComboBoxInputs = createSelector(
description: cmd.description,
type: "slashCommand" as ComboBoxItemType,
content: content,
source: cmd.source,
} as ComboBoxItem;
}) || []
);
Expand Down
Loading