diff --git a/ee/tabby-ui/components/prompt-editor/index.tsx b/ee/tabby-ui/components/prompt-editor/index.tsx index 2de909b765d2..6937c559893a 100644 --- a/ee/tabby-ui/components/prompt-editor/index.tsx +++ b/ee/tabby-ui/components/prompt-editor/index.tsx @@ -22,6 +22,7 @@ import { } from '@tiptap/react' import type { Content as TiptapContent } from '@tiptap/react' +import { NEWLINE_CHARACTER } from '@/lib/constants' import { ContextInfo, ContextSource } from '@/lib/gql/generates/graphql' import { useLatest } from '@/lib/hooks/use-latest' import { cn, isCodeSourceContext, isDocSourceContext } from '@/lib/utils' @@ -106,7 +107,7 @@ export const PromptEditor = forwardRef( const doSubmit = useLatest((editor: Editor) => { if (submitting) return - const text = editor.getText() + const text = editor.getText({ blockSeparator: NEWLINE_CHARACTER }).trim() if (!text) return onSubmit?.(editor) diff --git a/ee/tabby-ui/components/textarea-search.tsx b/ee/tabby-ui/components/textarea-search.tsx index 6d1aa2cfcc24..d0c3525a5a7b 100644 --- a/ee/tabby-ui/components/textarea-search.tsx +++ b/ee/tabby-ui/components/textarea-search.tsx @@ -4,6 +4,7 @@ import { useMemo, useRef, useState } from 'react' import { Editor } from '@tiptap/react' import { Maybe } from 'graphql/jsutils/Maybe' +import { NEWLINE_CHARACTER } from '@/lib/constants' import { ContextInfo } from '@/lib/gql/generates/graphql' import { useCurrentTheme } from '@/lib/hooks/use-current-theme' import { ThreadRunContexts } from '@/lib/types' @@ -98,7 +99,11 @@ export default function TextAreaSearch({ return } - const text = editor.getText().trim() + const text = editor + .getText({ + blockSeparator: NEWLINE_CHARACTER + }) + .trim() if (!text) return const mentions = getMentionsFromText(text, contextInfo?.sources) @@ -175,7 +180,15 @@ export default function TextAreaSearch({ autoFocus={autoFocus} onFocus={() => setIsFocus(true)} onBlur={() => setIsFocus(false)} - onUpdate={({ editor }) => setValue(editor.getText().trim())} + onUpdate={({ editor }) => + setValue( + editor + .getText({ + blockSeparator: NEWLINE_CHARACTER + }) + .trim() + ) + } ref={editorRef} placement={isFollowup ? 'bottom' : 'top'} className={cn( diff --git a/ee/tabby-ui/lib/constants/index.ts b/ee/tabby-ui/lib/constants/index.ts index 2879d8a7fed5..242b7bfaea74 100644 --- a/ee/tabby-ui/lib/constants/index.ts +++ b/ee/tabby-ui/lib/constants/index.ts @@ -13,3 +13,5 @@ export const SLUG_TITLE_MAX_LENGTH = 48 export * as regex from './regex' export const ERROR_CODE_NOT_FOUND = 'NOT_FOUND' + +export const NEWLINE_CHARACTER = '\n'