From a770b5a63dd858f44d8217b515846bd0205e0d49 Mon Sep 17 00:00:00 2001 From: Will Chen Date: Mon, 26 Aug 2024 22:45:03 -0700 Subject: [PATCH] Require prompt minimum length (4 chars) (#860) --- mesop/web/src/editor_toolbar/editor_toolbar.ng.html | 7 ++++++- mesop/web/src/editor_toolbar/editor_toolbar.ts | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/mesop/web/src/editor_toolbar/editor_toolbar.ng.html b/mesop/web/src/editor_toolbar/editor_toolbar.ng.html index ab2568bd..be58c615 100644 --- a/mesop/web/src/editor_toolbar/editor_toolbar.ng.html +++ b/mesop/web/src/editor_toolbar/editor_toolbar.ng.html @@ -52,7 +52,12 @@ } - diff --git a/mesop/web/src/editor_toolbar/editor_toolbar.ts b/mesop/web/src/editor_toolbar/editor_toolbar.ts index a7d9532b..9e917965 100644 --- a/mesop/web/src/editor_toolbar/editor_toolbar.ts +++ b/mesop/web/src/editor_toolbar/editor_toolbar.ts @@ -172,6 +172,16 @@ export class EditorToolbar implements OnInit { } async sendPrompt() { + if (this.prompt.length < 4) { + this.snackBar.open( + 'Please enter a prompt at least 4 characters long', + 'Close', + { + duration: 5000, + }, + ); + return; + } const prompt = this.prompt; this.autocompleteService.addHistoryOption(prompt); this.prompt = '';