Skip to content

Commit

Permalink
Require prompt minimum length (4 chars) (#860)
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwillchen authored Aug 27, 2024
1 parent 968f8c0 commit a770b5a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mesop/web/src/editor_toolbar/editor_toolbar.ng.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@
</div>
}

<button mat-icon-button (click)="sendPrompt()" [disabled]="isLoading">
<button
mat-icon-button
(click)="sendPrompt()"
[disabled]="isLoading"
[matTooltip]="'Generate code'"
>
<mat-icon>send</mat-icon>
</button>

Expand Down
10 changes: 10 additions & 0 deletions mesop/web/src/editor_toolbar/editor_toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand Down

0 comments on commit a770b5a

Please sign in to comment.