diff --git a/ee/app/assets/javascripts/ai/tanuki_bot/components/app.vue b/ee/app/assets/javascripts/ai/tanuki_bot/components/app.vue
index a612b279092a1bd4c9f6cdd2d101c60b4dc2d194..79fff986da84e3e7cd7fbfc3280c92a4c0c64356 100644
--- a/ee/app/assets/javascripts/ai/tanuki_bot/components/app.vue
+++ b/ee/app/assets/javascripts/ai/tanuki_bot/components/app.vue
@@ -126,53 +126,45 @@ export default {
   },
   methods: {
     ...mapActions(['addDuoChatMessage', 'setMessages', 'setLoading']),
+    isClearOrResetMessage(question) {
+      return [
+        GENIE_CHAT_CLEAN_MESSAGE,
+        GENIE_CHAT_CLEAR_MESSAGE,
+        GENIE_CHAT_RESET_MESSAGE,
+      ].includes(question);
+    },
     onSendChatPrompt(question) {
-      const trimmedQuestion = question.trim();
-
-      if (
-        ![GENIE_CHAT_CLEAN_MESSAGE, GENIE_CHAT_CLEAR_MESSAGE, GENIE_CHAT_RESET_MESSAGE].includes(
-          trimmedQuestion,
-        )
-      ) {
+      if (!this.isClearOrResetMessage(question)) {
         this.setLoading();
       }
       this.$apollo
         .mutate({
           mutation: chatMutation,
           variables: {
-            question: trimmedQuestion,
+            question,
             resourceId: this.resourceId || this.userId,
             clientSubscriptionId: this.clientSubscriptionId,
           },
         })
         .then(({ data: { aiAction = {} } = {} }) => {
-          if (
-            ![
-              GENIE_CHAT_CLEAN_MESSAGE,
-              GENIE_CHAT_CLEAR_MESSAGE,
-              GENIE_CHAT_RESET_MESSAGE,
-            ].includes(trimmedQuestion)
-          ) {
+          if (!this.isClearOrResetMessage(question)) {
             this.track('submit_gitlab_duo_question', {
               property: aiAction.requestId,
             });
           }
-          if (
-            trimmedQuestion === GENIE_CHAT_CLEAN_MESSAGE ||
-            trimmedQuestion === GENIE_CHAT_CLEAR_MESSAGE
-          ) {
+          if ([GENIE_CHAT_CLEAN_MESSAGE, GENIE_CHAT_CLEAR_MESSAGE].includes(question)) {
             this.$apollo.queries.aiMessages.refetch();
           } else {
             this.addDuoChatMessage({
               ...aiAction,
-              content: trimmedQuestion,
+              content: question,
             });
           }
         })
         .catch((err) => {
           this.error = err.toString();
           this.addDuoChatMessage({
-            content: trimmedQuestion,
+            content: question,
           });
           this.setLoading(false);
         });
diff --git a/ee/spec/frontend/ai/tanuki_bot/components/app_spec.js b/ee/spec/frontend/ai/tanuki_bot/components/app_spec.js
index 35eb374c0e079e704ce7bf0d669d9d8b62a432ce..fdebb9bdb19c733d8bc016f2ed7bce01ad1edd68 100644
--- a/ee/spec/frontend/ai/tanuki_bot/components/app_spec.js
+++ b/ee/spec/frontend/ai/tanuki_bot/components/app_spec.js
@@ -179,19 +179,15 @@ describe('GitLab Duo Chat', () => {
         findGlDuoChat().vm.$emit('send-chat-prompt', MOCK_USER_MESSAGE.content);
         expect(actionSpies.setLoading).toHaveBeenCalled();
       });
-      it.each([
-        GENIE_CHAT_RESET_MESSAGE,
-        ` ${GENIE_CHAT_RESET_MESSAGE} `,
-        GENIE_CHAT_CLEAN_MESSAGE,
-        ` ${GENIE_CHAT_CLEAN_MESSAGE} `,
-        GENIE_CHAT_CLEAR_MESSAGE,
-        ` ${GENIE_CHAT_CLEAR_MESSAGE} `,
-      ])('does not set loading to `true` for "%s" message', async (msg) => {
-        actionSpies.setLoading.mockReset();
-        findGlDuoChat().vm.$emit('send-chat-prompt', msg);
-        await nextTick();
-        expect(actionSpies.setLoading).not.toHaveBeenCalled();
-      });
+      it.each([GENIE_CHAT_RESET_MESSAGE, GENIE_CHAT_CLEAN_MESSAGE, GENIE_CHAT_CLEAR_MESSAGE])(
+        'does not set loading to `true` for "%s" message',
+        async (msg) => {
+          actionSpies.setLoading.mockReset();
+          findGlDuoChat().vm.$emit('send-chat-prompt', msg);
+          await nextTick();
+          expect(actionSpies.setLoading).not.toHaveBeenCalled();
+        },
+      );
 
       describe.each`
         resourceId          | expectedResourceId
@@ -243,12 +239,7 @@ describe('GitLab Duo Chat', () => {
         });
       });
 
-      it.each([
-        GENIE_CHAT_CLEAN_MESSAGE,
-        ` ${GENIE_CHAT_CLEAN_MESSAGE} `,
-        GENIE_CHAT_CLEAR_MESSAGE,
-        ` ${GENIE_CHAT_CLEAR_MESSAGE} `,
-      ])(
+      it.each([GENIE_CHAT_CLEAN_MESSAGE, GENIE_CHAT_CLEAR_MESSAGE])(
         'refetches the `aiMessages` if the prompt is "%s" and does not call addDuoChatMessage',
         async (prompt) => {
           createComponent();
@@ -285,20 +276,16 @@ describe('GitLab Duo Chat', () => {
           await waitForPromises();
           expect(trackingSpy).toHaveBeenCalled();
         });
-        it.each([
-          GENIE_CHAT_RESET_MESSAGE,
-          ` ${GENIE_CHAT_RESET_MESSAGE} `,
-          GENIE_CHAT_CLEAN_MESSAGE,
-          ` ${GENIE_CHAT_CLEAN_MESSAGE} `,
-          GENIE_CHAT_CLEAR_MESSAGE,
-          ` ${GENIE_CHAT_CLEAR_MESSAGE} `,
-        ])('does not track if the sent message is "%s"', async (msg) => {
-          createComponent();
-          findGlDuoChat().vm.$emit('send-chat-prompt', msg);
-
-          await waitForPromises();
-          expect(trackingSpy).not.toHaveBeenCalled();
-        });
+        it.each([GENIE_CHAT_RESET_MESSAGE, GENIE_CHAT_CLEAN_MESSAGE, GENIE_CHAT_CLEAR_MESSAGE])(
+          'does not track if the sent message is "%s"',
+          async (msg) => {
+            createComponent();
+            findGlDuoChat().vm.$emit('send-chat-prompt', msg);
+
+            await waitForPromises();
+            expect(trackingSpy).not.toHaveBeenCalled();
+          },
+        );
       });
     });