Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent user from sending another prompt while one is in progress #859

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading