diff --git a/core/commands/index.ts b/core/commands/index.ts index ba5c3403c..486eaccf2 100644 --- a/core/commands/index.ts +++ b/core/commands/index.ts @@ -19,7 +19,7 @@ export function slashFromCustomCommand( .slice(customCommand.name.length + 1, userInput.length) .trimStart(); } - debugger; + // Render prompt template let promptUserInput: string; if (customCommand.prompt.includes("{{{ input }}}")) { diff --git a/gui/src/components/mainInput/tiptap/editorConfig.ts b/gui/src/components/mainInput/tiptap/editorConfig.ts index 985cadc64..d79981d39 100644 --- a/gui/src/components/mainInput/tiptap/editorConfig.ts +++ b/gui/src/components/mainInput/tiptap/editorConfig.ts @@ -30,6 +30,7 @@ import { getFontSize } from "../../../util"; import { AddCodeToEdit } from "./extensions/AddCodeToEditExtension"; import { CodeBlockExtension } from "./extensions/CodeBlockExtension"; import { SlashCommand } from "./extensions/CommandsExtension"; +import { MockExtension } from "./extensions/FillerExtension"; import { Mention } from "./extensions/MentionExtension"; import { getContextProviderDropdownOptions, @@ -351,20 +352,22 @@ export function createEditorConfig(options: { }, }, }), - SlashCommand.configure({ - HTMLAttributes: { - class: "mention", - }, - suggestion: getSlashCommandDropdownOptions( - availableSlashCommandsRef, - onClose, - onOpen, - ideMessenger, - ), - renderText: (props) => { - return props.node.attrs.label; - }, - }), + props.availableSlashCommands.length + ? SlashCommand.configure({ + HTMLAttributes: { + class: "mention", + }, + suggestion: getSlashCommandDropdownOptions( + availableSlashCommandsRef, + onClose, + onOpen, + ideMessenger, + ), + renderText: (props) => { + return props.node.attrs.label; + }, + }) + : MockExtension, CodeBlockExtension, ], editorProps: { diff --git a/gui/src/components/mainInput/tiptap/extensions/FillerExtension.tsx b/gui/src/components/mainInput/tiptap/extensions/FillerExtension.tsx new file mode 100644 index 000000000..9b8baac86 --- /dev/null +++ b/gui/src/components/mainInput/tiptap/extensions/FillerExtension.tsx @@ -0,0 +1,20 @@ +import { Node } from "@tiptap/core"; + +export const MockExtension = Node.create({ + name: "mockExtension", + + addOptions() { + return { + enabled: false, + }; + }, + addCommands() { + return {}; + }, + addKeyboardShortcuts() { + return {}; + }, + addProseMirrorPlugins() { + return []; + }, +}); diff --git a/gui/src/components/mainInput/tiptap/getSuggestion.ts b/gui/src/components/mainInput/tiptap/getSuggestion.ts index f9faad863..264258dd5 100644 --- a/gui/src/components/mainInput/tiptap/getSuggestion.ts +++ b/gui/src/components/mainInput/tiptap/getSuggestion.ts @@ -203,7 +203,7 @@ export function getSlashCommandDropdownOptions( const filteredCommands = query.length > 0 ? options.filter((slashCommand) => { - const sc = slashCommand.title.toLowerCase(); + const sc = slashCommand.title.substring(1).toLowerCase(); const iv = query.toLowerCase(); return sc.startsWith(iv); }) @@ -219,7 +219,7 @@ export function getSlashCommandDropdownOptions( action: provider.action, })); - if (query.length === 0 && commandItems.length === 0) { + if (query.length === 0 && commandItems.length > 0) { commandItems.push({ title: "Explore prompts", type: "action", diff --git a/gui/src/redux/selectors/index.ts b/gui/src/redux/selectors/index.ts index bb7850dd5..3d46bf9ea 100644 --- a/gui/src/redux/selectors/index.ts +++ b/gui/src/redux/selectors/index.ts @@ -8,7 +8,7 @@ export const selectSlashCommandComboBoxInputs = createSelector( return ( slashCommands?.map((cmd) => { return { - title: cmd.name, + title: `${cmd.name}`, description: cmd.description, type: "slashCommand" as ComboBoxItemType, };