diff --git a/app/client/packages/design-system/widgets/src/components/AIChat/src/AIChat.tsx b/app/client/packages/design-system/widgets/src/components/AIChat/src/AIChat.tsx index 44551a5de95..54e0a0e5160 100644 --- a/app/client/packages/design-system/widgets/src/components/AIChat/src/AIChat.tsx +++ b/app/client/packages/design-system/widgets/src/components/AIChat/src/AIChat.tsx @@ -6,6 +6,8 @@ import styles from "./styles.module.css"; import { ThreadMessage } from "./ThreadMessage"; import type { AIChatProps, ChatMessage } from "./types"; +const MIN_PROMPT_LENGTH = 3; + const _AIChat = (props: AIChatProps, ref: ForwardedRef) => { const { // assistantName, @@ -64,6 +66,7 @@ const _AIChat = (props: AIChatProps, ref: ForwardedRef) => { > ) => { + if (Boolean(isSubmitDisabled)) return; + if (event.key === "Enter" && (event.metaKey || event.ctrlKey)) { event.preventDefault(); onSubmit?.(); } }, - [onSubmit], + [onSubmit, isSubmitDisabled], ); useLayoutEffect(() => { @@ -112,14 +115,18 @@ export function ChatInput(props: ChatInputProps) { return ( ); } return ( - + ); })(); diff --git a/app/client/packages/design-system/widgets/src/components/ChatInput/src/types.ts b/app/client/packages/design-system/widgets/src/components/ChatInput/src/types.ts index 936fc5bbf21..649c6e8edc5 100644 --- a/app/client/packages/design-system/widgets/src/components/ChatInput/src/types.ts +++ b/app/client/packages/design-system/widgets/src/components/ChatInput/src/types.ts @@ -1,5 +1,8 @@ import type { TextAreaProps } from "@appsmith/wds"; export interface ChatInputProps extends TextAreaProps { + /** callback function when the user submits the chat input */ onSubmit?: () => void; + /** flag for disable the submit button */ + isSubmitDisabled?: boolean; } diff --git a/app/client/packages/design-system/widgets/src/components/ChatInput/stories/ChatInput.stories.tsx b/app/client/packages/design-system/widgets/src/components/ChatInput/stories/ChatInput.stories.tsx index 634451082af..3ac580744e6 100644 --- a/app/client/packages/design-system/widgets/src/components/ChatInput/stories/ChatInput.stories.tsx +++ b/app/client/packages/design-system/widgets/src/components/ChatInput/stories/ChatInput.stories.tsx @@ -66,3 +66,9 @@ export const Validation: Story = { ), }; + +export const SubmitDisabled: Story = { + args: { + isSubmitDisabled: true, + }, +};