diff --git a/src/lib/components/chat/MessageInput.svelte b/src/lib/components/chat/MessageInput.svelte index a71578513..f0d51aa9a 100644 --- a/src/lib/components/chat/MessageInput.svelte +++ b/src/lib/components/chat/MessageInput.svelte @@ -280,7 +280,7 @@
{#if atSelectedModel !== undefined}
{ dispatch('select', doc); - prompt = removeFirstHashWord(prompt); + prompt = removeLastWordFromString(prompt, command); const chatInputElement = document.getElementById('chat-textarea'); await tick(); @@ -90,7 +90,7 @@ const confirmSelectWeb = async (url) => { dispatch('url', url); - prompt = removeFirstHashWord(prompt); + prompt = removeLastWordFromString(prompt, command); const chatInputElement = document.getElementById('chat-textarea'); await tick(); @@ -101,7 +101,7 @@ const confirmSelectYoutube = async (url) => { dispatch('youtube', url); - prompt = removeFirstHashWord(prompt); + prompt = removeLastWordFromString(prompt, command); const chatInputElement = document.getElementById('chat-textarea'); await tick(); diff --git a/src/lib/utils/index.ts b/src/lib/utils/index.ts index 56922f03f..995712dfa 100644 --- a/src/lib/utils/index.ts +++ b/src/lib/utils/index.ts @@ -297,7 +297,10 @@ export const removeLastWordFromString = (inputString, wordString) => { } // Join the remaining words back into a string - const resultString = words.join(' '); + let resultString = words.join(' '); + if (resultString !== '') { + resultString += ' '; + } return resultString; };