Skip to content

Commit

Permalink
fix: prevent using keyboard in plyaground while request is ongoing (#…
Browse files Browse the repository at this point in the history
…1170)

Fixes #1087

Signed-off-by: Jeff MAURY <[email protected]>
  • Loading branch information
jeffmaury authored Jun 21, 2024
1 parent c666ae7 commit 39b29a1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
14 changes: 11 additions & 3 deletions packages/frontend/src/pages/Playground.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ test('send prompt should be enabled initially, with a system prompt', async () =
});
});

test('sending prompt should disable the send button', async () => {
test('sending prompt should disable the send button and the input element', async () => {
vi.mocked(studioClient.getCatalog).mockResolvedValue({
models: [
{
Expand Down Expand Up @@ -304,10 +304,12 @@ test('sending prompt should disable the send button', async () => {
await waitFor(() => {
send = screen.getByRole('button', { name: 'Send prompt' });
expect(send).toBeDisabled();
const input = screen.getByRole('textbox', { name: 'prompt' });
expect(input).toBeDisabled();
});
});

test('sending prompt not using button should disable the send button', async () => {
test('sending prompt not using button should disable the send button and the input element', async () => {
vi.mocked(studioClient.getCatalog).mockResolvedValue({
models: [
{
Expand Down Expand Up @@ -349,10 +351,12 @@ test('sending prompt not using button should disable the send button', async ()
await waitFor(() => {
prompt = screen.getByRole('button', { name: 'Send prompt' });
expect(prompt).toBeDisabled();
const input = screen.getByRole('textbox', { name: 'prompt' });
expect(input).toBeDisabled();
});
});

test('receiving complete message should enable the send button', async () => {
test('receiving complete message should enable the send button and the input element', async () => {
vi.mocked(studioClient.getCatalog).mockResolvedValue({
models: [
{
Expand Down Expand Up @@ -393,6 +397,8 @@ test('receiving complete message should enable the send button', async () => {
await waitFor(() => {
send = screen.getByRole('button', { name: 'Send prompt' });
expect(send).toBeDisabled();
const input = screen.getByRole('textbox', { name: 'prompt' });
expect(input).toBeDisabled();
});

customConversations.set([
Expand All @@ -419,6 +425,8 @@ test('receiving complete message should enable the send button', async () => {
await waitFor(() => {
send = screen.getByRole('button', { name: 'Send prompt' });
expect(send).toBeEnabled();
const input = screen.getByRole('textbox', { name: 'prompt' });
expect(input).toBeEnabled();
});
});

Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/src/pages/Playground.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ export function goToUpPage(): void {
on:keydown="{handleKeydown}"
rows="2"
class="w-full p-2 outline-none text-sm rounded-sm bg-charcoal-800 text-white placeholder-white"
placeholder="Type your prompt here"></textarea>
placeholder="Type your prompt here"
disabled="{!sendEnabled}"></textarea>

<div class="flex-none text-right m-4">
<Button
Expand Down

0 comments on commit 39b29a1

Please sign in to comment.