Skip to content

Commit

Permalink
Prevent user from sending another prompt while one is in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwillchen committed Aug 27, 2024
1 parent 213772b commit 5bef8d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mesop/web/src/editor_toolbar/editor_toolbar.ng.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
</button>
<textarea
#textarea
placeholder="Type in the UI change you want..."
disabled="{{isLoading}}"
placeholder="{{isLoading ? 'Generating...' : 'Type in the UI change you want...' }}"
class="floating-editor-toolbar-textarea"
[(ngModel)]="prompt"
(ngModelChange)="onPromptChange($event)"
Expand All @@ -50,9 +51,11 @@
<span>{{responseTime | number:'1.1-1'}}s</span>
</div>
}
<button mat-icon-button class="send-button" (click)="sendPrompt()">

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

<button
mat-icon-button
(click)="openHistory()"
Expand Down
3 changes: 3 additions & 0 deletions mesop/web/src/editor_toolbar/editor_toolbar_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ export class EditorToolbarService {
sourceCodeLocation?: SourceCodeLocation | undefined,
): Promise<PromptResponse> {
console.debug('sendPrompt', prompt);
if (this.eventSource) {
return Promise.reject(new Error('Prompt already in progress'));
}
// Clear the progress subject
this.generationProgressSubject.next('');
const path = window.location.pathname;
Expand Down

0 comments on commit 5bef8d1

Please sign in to comment.